-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replaced URL with manual query parsing and added fixed ClientResponse…
…Error wrapping
- Loading branch information
1 parent
ecc1c2e
commit 04b699f
Showing
19 changed files
with
193 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { assert } from 'chai'; | ||
import ClientResponseError from '@/ClientResponseError'; | ||
|
||
describe('ClientResponseError', function() { | ||
describe('constructor()', function() { | ||
it('with object-like value', function() { | ||
const err = new ClientResponseError({ | ||
url: "http://example.com", | ||
status: 400, | ||
response: {message: "test message"}, | ||
isAbort: true, | ||
originalError: "test" | ||
}); | ||
|
||
assert.equal(err.url, "http://example.com"); | ||
assert.equal(err.status, 400); | ||
assert.deepEqual(err.response, {message: "test message"}); | ||
assert.equal(err.isAbort, true); | ||
assert.equal(err.originalError, "test"); | ||
assert.equal(err.message, "test message"); | ||
}); | ||
|
||
it('with non-object value', function() { | ||
const err = new ClientResponseError("test"); | ||
|
||
assert.equal(err.url, ""); | ||
assert.equal(err.status, 0); | ||
assert.deepEqual(err.response, {}); | ||
assert.equal(err.isAbort, false); | ||
assert.equal(err.originalError, "test"); | ||
assert.equal(err.message, "Something went wrong while processing your request."); | ||
}); | ||
|
||
it('with plain error', function() { | ||
const plainErr = new Error("test") | ||
const err = new ClientResponseError(plainErr); | ||
|
||
assert.equal(err.url, ""); | ||
assert.equal(err.status, 0); | ||
assert.deepEqual(err.response, {}); | ||
assert.equal(err.isAbort, false); | ||
assert.equal(err.originalError, plainErr); | ||
assert.equal(err.message, "Something went wrong while processing your request."); | ||
}); | ||
|
||
it('with ClientResponseError error', function() { | ||
const err0 = new ClientResponseError({ | ||
url: "http://example.com", | ||
status: 400, | ||
response: {message: "test message"}, | ||
isAbort: true, | ||
originalError: "test" | ||
}); | ||
const err = new ClientResponseError(err0); | ||
|
||
assert.equal(err.url, "http://example.com"); | ||
assert.equal(err.status, 400); | ||
assert.deepEqual(err.response, {message: "test message"}); | ||
assert.equal(err.isAbort, true); | ||
assert.equal(err.originalError, "test"); | ||
assert.equal(err.message, "test message"); | ||
}); | ||
|
||
it('with abort error', function() { | ||
const err0 = new DOMException("test"); | ||
const err = new ClientResponseError(err0); | ||
|
||
assert.equal(err.url, ""); | ||
assert.equal(err.status, 0); | ||
assert.deepEqual(err.response, {}); | ||
assert.equal(err.isAbort, true); | ||
assert.equal(err.originalError, err0); | ||
assert.include(err.message, "request was autocancelled"); | ||
}); | ||
}); | ||
}); |