ember.js - in Ember Data how do you manually load a Record with a hasMany association for unit testing? -


i'm unit testing computed properties on ds.model .

// trivial example i'm not testing app.modela = ds.model.extend({     sub_models : ds.hasmany('app.modelb'),      lengthofbees : function() {          return this.sub_models.length;     }.property('sub_models.length') }) 

how manually create record has association? providing json record no associations easy.. app.modelx = app.modelx.createrecord({ attriba : 'valuea'});

but don't know syntax createrecord when want supply hasmany associations. how do that?

assuming using ember-data rev 12 should work

  test("findmany qunit test example", function() {     store.load(person, {id: 9, name: "toran billups"});     person = store.find(person, 9);     store.loadhasmany(person, 'tasks', [ 1, 2 ]);      var tasks = get(person, 'tasks'); //to fire http request      equal(get(tasks, 'length'), 2, "");   }); 

and if loadhasmany doesn't work in version of ember-data try instead

  test("findmany qunit test example", function() {     store.load(person, {id: 9, name: "toran billups", tasks: [1, 2]});     person = store.find(person, 9);      var tasks = get(person, 'tasks'); //to fire http request      equal(get(tasks, 'length'), 2, "");   }); 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -