【发布时间】:2017-05-25 08:43:29
【问题描述】:
我正在编写一个 Ionic 应用程序并对内部代码进行测试。我有一个example,它很有帮助。但是我正在使用 Geolocation 或 Loading Controller 等其他东西作为我的功能,我不知道应该如何模拟它们。例如我在.spec.ts 中提供
{ provide: LoadingController, useClass: LoadMock }
但我不知道我应该提供什么(哪种类型和数据)。错误日志尤其没有意义。例如,我应该在这里为加载控制器提供什么。它有方法:创建、呈现和关闭。
export class LoadMock {
public create(): type??? {
return what???
}
public present(): type??? {
return what???
}
public dismiss(): type??? {
return what???
}
}
【问题讨论】:
-
what 取决于它在测试单元中的如何。答案和问题一样好。
-
@estus 我在哪里可以看到我应该通过和返回什么?
-
您在哪里使用 LoadingController。
标签: angular unit-testing typescript ionic-framework ionic3