lundi 5 janvier 2015

Ember-cli unit tests with relationships 'needs'

I am working on my unit tests and it feels like I am doing something incorrect. I have a 'main' object that has many relationships



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 })


And each time I work on the unit tests for its related items (person, category,impact), I'm having to reproduce all of the needs values that my 'main' object has. It just doesn't feel right for my location unit test to need category when it only cares about a string for its name and its relationship back to the 'main' object



// 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']
});


Am I doing something wrong or is there a better way to build my unit tests to deal with the relationships?


I am on ember-cli 0.1.5, ember 1.9.1, and ember-data beta 14





Aucun commentaire:

Enregistrer un commentaire