Skip to content

Commit

Permalink
Tests for failure and succeed afterwards.
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrokiefer committed Feb 22, 2015
1 parent c953c45 commit 19c055b
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/factory_guy_test_mixin_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,39 @@ asyncTest("#handleUpdate with model that fail with custom response", function ()
start();
}
);
});
});

asyncTest("#handleUpdate with model that fail and then succeeds", function () {
Em.run(function () {
var profile = make('profile');

var updateMock = testHelper.handleUpdate(profile).andFail({
status: 400,
response: "{error: 'invalid data'}"
});

profile.set('description', 'new desc');
profile.save().then(
function () {
},
function (reason) {
equal(reason.responseText, "{error: 'invalid data'}", "Could not save model.");
}
).then(function () {
updateMock.andSucceed();

ok(!profile.get('valid'), "Profile is invalid.");

profile.save().then(
function () {
ok(!profile.get('saving'), "Saved model");
ok(profile.get('description') == 'new desc', "Description was updated.");
start();
}
);
});
});
});

/////// handleDelete //////////
Expand Down

0 comments on commit 19c055b

Please sign in to comment.