jos*_*ota 7 unit-testing ember.js
鉴于Ember 1.0.0最近达成了,我想开始使用它进行测试.我正在使用Yeoman 1.0和Karma.我想单元测试模型,但我发现很难完成隔离.
我现在的例子是:
describe("Expense", function() {
return it("has a computed property called `explained`", function() {
var expense = App.Expense.create({
name: "My first expense",
value: 34
});
return expect(expense.get("explained")).to.equal("My first expense -- 34");
});
});
Run Code Online (Sandbox Code Playgroud)
截至1.0.0,我收到以下错误:
Error: You should not call `create` on a model. Instead, call
`store.createRecord` with the attributes you would like to set.
Run Code Online (Sandbox Code Playgroud)
我应该如何访问商店以创建模型实例?更理想的情况是,如何在不诉诸商店的情况下简单地生成这样的模型,这是否可行?为了测试IMO模型,生成整个应用程序是没有意义的.
谢谢.
| 归档时间: |
|
| 查看次数: |
1314 次 |
| 最近记录: |