嗨,我正试图在Ember CLI中编写第一个测试。这是我的测试结果
> ...
>
> moduleForModel('recipe/recipe', 'Recipe Model works', {
> needs: ['model:recipe/recipe'] });
> test('Recipe is a valid ember-data Model', function (assert) {
> var store = this.store();
> var recipe = this.subject({name: 'A title for a recipe'});
>
> assert.ok(recipe instanceof DS.Model); });
和模型recipe/recipe model
...
var Recipe = DS.Model.extend({
name: DS.attr('string'),
category: DS.belongsTo('recipe/category', {async: true}),
file: DS.belongsTo('filerepository/file', {async: true})
});
Recipe.reopenClass({
FIXTURES: [
{ id: 1, name: 'New Recipe'},
]
});
如果我运行给定的测试,它输出:错误:没有找到'recipe/category'的模型
如果我在model上注释//category和//file。测试通过了。目前正在使用夹具适配器。当我创建记录或在应用程序的工作流程中加载它们时,所有的关系都很好。(如store.find(配方/类别)等. .)
你需要在moduleForModel
中声明更多你依赖的模型:
needs: ['model:recipe/recipe', 'model:recipe/category', 'model:filerepository/file']