Skip to content

Commit

Permalink
Add test for capturing error details
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill Heaton committed Sep 15, 2018
1 parent c76d07c commit 755bc27
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tests/integration/adapter/rest-adapter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2551,7 +2551,7 @@ test('gracefully handles exceptions in handleResponse where the ajax request err
});

test('treats status code 0 as an abort', function(assert) {
assert.expect(1);
assert.expect(3);

adapter._ajaxRequest = function(hash) {
hash.error({
Expand All @@ -2568,6 +2568,13 @@ test('treats status code 0 as an abort', function(assert) {
return run(() => {
return store.findRecord('post', '1').catch(err => {
assert.ok(err instanceof DS.AbortError, 'reason should be an instance of DS.AbortError');
assert.equal(err.errors.length, 1, 'AbortError includes errors with request/response details');
let expectedError = {
title: "Adapter Error",
detail: "Request failed: GET /posts/1",
status: 0
};
assert.deepEqual(err.errors[0], expectedError, 'method, url and, status are captured as details');
});
});
});
Expand Down

0 comments on commit 755bc27

Please sign in to comment.