Unit testing 具有关系的Ember cli单元测试';需要';

Unit testing 具有关系的Ember cli单元测试';需要';,unit-testing,ember.js,ember-cli,ember-testing,Unit Testing,Ember.js,Ember Cli,Ember Testing,我正在进行单元测试,感觉好像做了不正确的事情。我有一个“主要”对象,它有很多关系 author: belongsTo('person', { async: true }), title: attr('string'), category: belongsTo('category', { async: true }), impact: belongsTo('impact', { async: true }), status: attr('string'), createdDate: attr('m

我正在进行单元测试,感觉好像做了不正确的事情。我有一个“主要”对象,它有很多关系

author: belongsTo('person', { async: true }),
title: attr('string'),
category: belongsTo('category', { async: true }),
impact: belongsTo('impact', { async: true }),
status: attr('string'),
createdDate: attr('moment'),
submittedDate: attr('moment'),
authorOrg: belongsTo('organization', { async: true }),
locations: hasMany('location', { async: true }),
audits: hasMany('audit', { async: true })
每次我为它的相关项(
person
category
impact
)进行单元测试时,我都必须重现我的“main”对象所具有的所有
需求
值。当我的位置单元测试只关心一个字符串作为它的名称以及它与“main”对象的关系时,它觉得需要
category
是不对的

// location/model-test.js
import {
  moduleForModel,
  test
} from 'ember-qunit';

moduleForModel('location', 'Location', {
  // Specify the other units that are required for this test.
  needs: ['model:main', 'model:person', 'model:category',
      'model:impact', 'model:organization', 'model:location']
});
我是做错了什么,还是有更好的方法来构建我的单元测试来处理这些关系


我使用的是ember cli 0.1.5、ember 1.9.1和ember data beta 14

,我使用定义一个包装函数,将说明符添加到模块标签中,然后每当我想要一个新模块时,我都使用这个方便函数:

var anotherModule = function(suffix) {
  moduleForModel('location', 'Location - ' + suffix, {
    needs: ['model:main', 'model:person', 'model:category',
      'model:impact', 'model:organization', 'model:location']
  });
};

anotherModule("module 1");
test("test 1.1", function() { });
test("test 1.1", function() { });

anotherModule("module 2");
test("test 2.1", function() { });