vendredi 27 mars 2015

Can't mock return from ember-data destroyRecord for testing

I'm trying to test deleting a user account using fauxjax and ember-data. I am getting this error back: Assertion Failed: Expected an object as 'data' in a call to 'push' @model:user: , but was undefined


I can't find what to do in this case with testing. Here is my test and code:


Test:



test('delete user account', function(assert) {
loginUser();
$.fauxjax.new({
request: {
type: 'GET',
url: ENV.apiDomain.concat('/users/1'),
dataType: 'json',
headers: {Authorization: 'abc123'}
},
response: {
content: {}
}
});

visit('/account/delete');

click('#yes');
andThen(function() {
assert.equal(currentPath(), 'index');
});
});


and my action:



confirmDelete: function() {
var controller = this;
this.store.find('user', localStorage.userId).then(function(user){
user.destroyRecord();
controller.send('logout');
});
},

Aucun commentaire:

Enregistrer un commentaire