0

こんにちは、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') など)

4

1 に答える 1

1

で依存するモデルをさらに宣言する必要がありますmoduleForModel

needs: ['model:recipe/recipe', 'model:recipe/category', 'model:filerepository/file']
于 2015-08-22T10:22:04.033 に答える