I have an Ember route that creates a temporary value on the store to edit. When I navigate away from the route, I want to delete the temporary value otherwise they build up. How do I write a test for this? Code below.
export default Ember.Route.extend({
model() {
this.set('newSong', this.get('store').createRecord('song'));
return this.get('store').findAll('song');
},
actions: {
saveSongRoute(songName) {
let song = this.get('new');
song.set('songName', songName);
song.save();
this.set('newSong', this.get('store').createRecord('song'));
},
willTransition: function() {
this.get('newSong').deleteRecord();
},
},
});
There are examples that use application.__container__.lookup('service:store');
, but they don't work with Ember 2.10. I think the correct way would be to stub the store like how this component example stubs a service, but I can't figure out how to inject an object into my Ember application as the store.
Aucun commentaire:
Enregistrer un commentaire