Rya*_*sch 11 unit-testing ember.js ember-testing ember-cli
我正在进行单元测试,感觉我做错了.我有一个'主'对象有很多关系
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 })
Run Code Online (Sandbox Code Playgroud)
每次我在单元测试及其相关项目的工作时间(person
,category
,impact
),我有重现所有的needs
,我的"主"对象有值.category
当我只关心字符串的名称及其与'main'对象之间的关系时,我觉得我的位置单元测试不合适
// 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']
});
Run Code Online (Sandbox Code Playgroud)
我做错了什么或有更好的方法来构建我的单元测试来处理关系?
我在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() { });
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
369 次 |
最近记录: |