我正在尝试在ember-cli应用程序中测试模型关系,但它一直告诉我:未找到'rateType'的模型。似乎找不到我的模型。
文件
~app/models/account.js
~app/models/rate-type.js
帐户模型
export default DS.Model.extend({
...
rateType: DS.belongsTo('rateType'),
});
测试
import Ember from 'ember';
import { test, moduleForModel } from 'ember-qunit';
import Account from 'app/models/account';
import RateType from 'app/models/rate-type';
moduleForModel('account', 'Account Model', {
// Specify the other units that are required for this test.
needs: ['model:rate-type']
});
test('rateType relationship', function() {
expect(0);
this.subject(); //error here
// var relationships = Ember.get(Account, 'relationships');
// deepEqual(relationships.get('rate-type'), [
// { name: 'rateType', kind: 'belongsTo' }
// ]);
});
我试过了 Camel 套的需求属性,但一点都不喜欢。
needs: ['model:rateType', 'model:fuelGroup']
最佳答案
我认为您需要的是needs关键字:
moduleForModel('post', 'Unit | Model | post', {
needs: ['model:comment', 'model:user']
});
我在这里的文档中找到它:http://guides.emberjs.com/v1.10.0/testing/testing-models/
关于ember.js - 测试 Ember 数据模型-找不到关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24690211/