-
-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy patherror-test.js
56 lines (46 loc) · 1.75 KB
/
error-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { module, test } from 'qunit';
import { Response } from 'ember-fetch';
import {
isUnauthorizedResponse,
isForbiddenResponse,
isNotFoundResponse,
isGoneResponse,
isInvalidResponse,
isBadRequestResponse,
isServerErrorResponse,
isAbortError,
isConflictResponse
} from 'ember-fetch/errors';
module('Errors', function() {
test('isUnauthorizedResponse', function(assert) {
assert.ok(isUnauthorizedResponse(new Response(null, { status: 401 })));
});
test('isForbiddenResponse', function(assert) {
assert.ok(isForbiddenResponse(new Response(null, { status: 403 })));
});
test('isNotFoundResponse', function(assert) {
assert.ok(isNotFoundResponse(new Response(null, { status: 404 })));
assert.notOk(isNotFoundResponse(new Response(null, { status: 400 })));
});
test('isGoneResponse', function(assert) {
assert.ok(isGoneResponse(new Response(null, { status: 410 })));
assert.notOk(isGoneResponse(new Response(null, { status: 400 })));
});
test('isInvalidResponse', function(assert) {
assert.ok(isInvalidResponse(new Response(null, { status: 422 })));
});
test('isBadRequestResponse', function(assert) {
assert.ok(isBadRequestResponse(new Response(null, { status: 400 })));
});
test('isServerErrorResponse', function(assert) {
assert.notOk(isServerErrorResponse(new Response(null, { status: 499 })));
assert.ok(isServerErrorResponse(new Response(null, { status: 500 })));
assert.ok(isServerErrorResponse(new Response(null, { status: 599 })));
});
test('isAbortError', function(assert) {
assert.ok(isAbortError(new DOMException('AbortError', 'AbortError')));
});
test('isConflictResponse', function(assert) {
assert.ok(isConflictResponse(new Response(null, { status: 409 })));
});
});