嗨,我正试着用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); });以及模型配方/配方模型
...
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'},
]
});如果我运行给定的测试,它会输出:错误:没有找到“食谱/类别”的模型
如果我评论//类别和//文件的模型。测试通过了。目前使用的是夹具适配器。当我创建记录或将它们加载到应用程序的工作流中时,所有的关系都可以正常工作。(比如store.find(‘食谱/类别’)等等)
发布于 2015-08-22 10:22:04
您需要在moduleForModel中声明更多依赖的模型
needs: ['model:recipe/recipe', 'model:recipe/category', 'model:filerepository/file']https://stackoverflow.com/questions/32154195
复制相似问题