forked from aws-amplify/amplify-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
release: Amplify JS release (aws-amplify#13502)
- Loading branch information
Showing
72 changed files
with
488 additions
and
366 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
Validating CODEOWNERS rules …
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ concurrency: | |
on: | ||
push: | ||
branches: | ||
- next/main | ||
- replace-with-your-branch | ||
|
||
jobs: | ||
e2e: | ||
|
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
59 changes: 37 additions & 22 deletions
59
packages/auth/__tests__/providers/cognito/assertServiceError.test.ts
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 |
---|---|---|
@@ -1,39 +1,54 @@ | ||
import { AmplifyErrorCode } from '@aws-amplify/core/internals/utils'; | ||
|
||
import { assertServiceError } from '../../../src/errors/utils/assertServiceError'; | ||
import { AuthError } from '../../../src/errors/AuthError'; | ||
import { InitiateAuthException } from '../../../src/providers/cognito/types/errors'; | ||
|
||
describe('asserts service errors', () => { | ||
test('it should throw an unknown error when error is null', () => { | ||
try { | ||
const error = null; | ||
expect(assertServiceError(error)).toThrow(); | ||
} catch (error: any) { | ||
expect(error).toBeInstanceOf(AuthError); | ||
expect(error.name).toBe(AmplifyErrorCode.Unknown); | ||
} | ||
const error = null; | ||
expect(() => { | ||
assertServiceError(error); | ||
}).toThrow( | ||
new AuthError({ | ||
name: AmplifyErrorCode.Unknown, | ||
message: 'An unknown error has occurred.', | ||
underlyingError: error, | ||
}), | ||
); | ||
}); | ||
|
||
test('it should throw an unknown error when error is a TypeError', () => { | ||
try { | ||
const error = new TypeError('TypeError'); | ||
expect(assertServiceError(error)).toThrow(); | ||
} catch (error: any) { | ||
expect(error).toBeInstanceOf(AuthError); | ||
expect(error.name).toBe(AmplifyErrorCode.Unknown); | ||
} | ||
const error = new TypeError('TypeError'); | ||
expect(() => { | ||
assertServiceError(error); | ||
}).toThrow( | ||
new AuthError({ | ||
name: AmplifyErrorCode.Unknown, | ||
message: 'An unknown error has occurred.', | ||
underlyingError: error, | ||
}), | ||
); | ||
}); | ||
|
||
test('it should throw an unknown error when error does not have a name', () => { | ||
try { | ||
const error = new Error('Error'); | ||
expect(assertServiceError(error)).toThrow(); | ||
} catch (error: any) { | ||
expect(error).toBeInstanceOf(AuthError); | ||
expect(error.name).toBe(AmplifyErrorCode.Unknown); | ||
} | ||
const error = new Error('Error'); | ||
expect(() => { | ||
assertServiceError(error); | ||
}).toThrow( | ||
new AuthError({ | ||
name: AmplifyErrorCode.Unknown, | ||
message: 'An unknown error has occurred.', | ||
underlyingError: error, | ||
}), | ||
); | ||
}); | ||
|
||
test('it should not throw if the error is coming from the service', () => { | ||
const error = new Error('Service Error'); | ||
error.name = InitiateAuthException.InternalErrorException; | ||
expect(assertServiceError(error)).toBeUndefined(); | ||
expect(() => { | ||
assertServiceError(error); | ||
}).not.toThrow(); | ||
}); | ||
}); |
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.