嗨,我正在尝试在 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'},
]
});
如果我运行给定的测试,它会输出:错误:找不到“配方/类别”的模型
如果我在模型上评论 //category 和 //file。测试通过。目前使用夹具适配器。当我创建记录或将它们加载到应用程序的工作流程中时,所有关系都可以正常工作。(如 store.find('recipe/category') 等..)