I have a component that uses store: Ember.inject.service()
as per this answer https://stackoverflow.com/a/29816081/2482265. 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.
Update
Some of my components fire an action in record.save().then()
so I can subscribe to this in the test with a normal this.on('assertMyAction', () => { ... })
. But some of my components do not need to fire an action back out so I'll need a different way to know store.record.save has forfilled before checking the some of the finer properties on the record.