-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into dependabot/npm_and_yarn/packages/avsc-isomet…
…ric/webpack-5.94.0
- Loading branch information
Showing
55 changed files
with
3,950 additions
and
3,268 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
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
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
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,75 @@ | ||
import { AxiosError, AxiosHeaders } from 'axios' | ||
import { describe, expect, test } from 'vitest' | ||
import { fromAxiosError } from './errors' | ||
|
||
const commonHeaders = new AxiosHeaders() | ||
const commonResponseProperties = { | ||
statusText: '', | ||
headers: commonHeaders, | ||
config: { headers: commonHeaders }, | ||
} | ||
|
||
describe('fromAxiosError: ', async () => { | ||
test('returns default HttpError (500) when response status is not available', () => { | ||
const request = { path: '/enrollment/get-child' } | ||
const response = { | ||
...commonResponseProperties, | ||
status: 0, | ||
data: {}, | ||
} | ||
const incomingError = new AxiosError('', '', undefined, request, response) | ||
const returnedError = fromAxiosError(incomingError) | ||
|
||
expect(returnedError.message).toBe('Internal Server Error') // fallback since response does not contain statusText property | ||
expect(returnedError.statusCode).toBe(500) // fallback since response does not contain legit status | ||
expect(returnedError.cause.name).toBe('AxiosError') | ||
expect(returnedError.cause.stack).toBeDefined() | ||
expect(returnedError.cause.cause).toStrictEqual({}) | ||
}) | ||
|
||
test('returns appropriate HttpError (404) based on response status and data', () => { | ||
const request = { path: '/enrollment/get-child' } | ||
const response = { | ||
...commonResponseProperties, | ||
status: 404, | ||
data: { | ||
code: 'CHILD_NOT_FOUND', | ||
description: 'There is no child with that pnr', | ||
status: 404, | ||
statusText: 'CHILD_NOT_FOUND', | ||
}, | ||
} | ||
const incomingError = new AxiosError('', '', undefined, request, response) | ||
const returnedError = fromAxiosError(incomingError) | ||
|
||
expect(returnedError.message).toBe('Internal Server Error') // fallback since response does not contain statusText property | ||
expect(returnedError.statusCode).toBe(404) | ||
expect(returnedError.cause.cause).toStrictEqual(response.data) | ||
}) | ||
|
||
test('returns appropriate HttpError (401) based on response status and data', () => { | ||
const request = { path: '/accounts/balance' } | ||
const response = { | ||
...commonResponseProperties, | ||
statusText: 'Unauthorized', | ||
status: 401, | ||
data: { | ||
code: 'AUTH_ERROR', | ||
description: 'Token expired', | ||
status: 401, | ||
}, | ||
} | ||
const incomingError = new AxiosError( | ||
'Unauthorized', | ||
'AUTH_ERROR', | ||
undefined, | ||
request, | ||
response | ||
) | ||
const returnedError = fromAxiosError(incomingError) | ||
|
||
expect(returnedError.message).toBe('Unauthorized') | ||
expect(returnedError.statusCode).toBe(401) | ||
expect(returnedError.cause.cause).toStrictEqual(response.data) | ||
}) | ||
}) |
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
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
Oops, something went wrong.