lundi 2 novembre 2015

How to test model is successfully added to the store in a components integration test

I have a component that uses store: Ember.inject.service() as per this answer http://ift.tt/1N7W4Tm. When the user hits submit a new record in created in the store - e.g:

var address = {
  line1: this.get('line1'),
  line2: this.get('line2'),
  line3: this.get('line3'),
  town: this.get('town'),
  county: this.get('county'),
  postCode: this.get('postCode'),
  account: account
};

var record = this.get('store').createRecord('address', address);

record.save().then(() => { ... });

I now want to write the integration test for this component, I fill out the fields and then trigger a click on the submit button, thats all fine, but how do I check an address was added to the store?

I saw mention of

var container = this.container;
var store = container.lookup('service:store') || container.lookup('store:main');

But couldn't work out the last step to give me a useful assert.




Aucun commentaire:

Enregistrer un commentaire