Skip to content

Commit

Permalink
stash work
Browse files Browse the repository at this point in the history
  • Loading branch information
runspired committed Apr 6, 2023
1 parent 9779917 commit ddbd835
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Fetch from '@ember-data/request/fetch';
import Store, { CacheHandler, recordIdentifierFor } from '@ember-data/store';
import type { Document } from '@ember-data/store/-private/document';
import type { NotificationType } from '@ember-data/store/-private/managers/notification-manager';
import { Collection } from '@ember-data/store/-private/record-arrays/identifier-array';
import type {
CollectionResourceDataDocument,
ResourceDataDocument,
Expand Down Expand Up @@ -1454,4 +1455,23 @@ module('Store | CacheHandler - @ember-data/store', function (hooks) {
assert.strictEqual(handlerCalls, 2, 'fetch handler should only be called twice');
});
});

module('Errors', function () {
test('fetching a resource document that errors', async function (assert) {
const { owner } = this;

const store = owner.lookup('service:store') as TestStore;
try {
await store.request<Collection>({
url: '/assets/users/2.json',
});
assert.ok(false, 'we should error');
} catch (errorDocument: unknown) {
assertIsErrorDocument(assert, errorDocument);
assert.true(errorDocument.message.startsWith('[404] Not Found - '), 'We receive the correct error');
assert.strictEqual(errorDocument.response?.statusText, 'Not Found', 'Correct error code');
assert.strictEqual(errorDocument.response?.status, 404, 'correct code');
}
});
});
});

0 comments on commit ddbd835

Please sign in to comment.