diff options
Diffstat (limited to 'packages/browser/src')
-rw-r--r-- | packages/browser/src/methods/startRegistration.test.ts | 53 | ||||
-rw-r--r-- | packages/browser/src/setupTests.ts | 61 |
2 files changed, 61 insertions, 53 deletions
diff --git a/packages/browser/src/methods/startRegistration.test.ts b/packages/browser/src/methods/startRegistration.test.ts index f875a08..683bae8 100644 --- a/packages/browser/src/methods/startRegistration.test.ts +++ b/packages/browser/src/methods/startRegistration.test.ts @@ -356,56 +356,3 @@ describe('WebAuthnError', () => { }); }); }); - -/** - * Custom errors raised by WebAuthn - */ - -class AbortError extends Error { - constructor() { - super(); - this.name = 'AbortError'; - } -} - -class ConstraintError extends Error { - constructor() { - super(); - this.name = 'ConstraintError'; - } -} - -class InvalidStateError extends Error { - constructor() { - super(); - this.name = 'InvalidStateError'; - } -} - -class NotAllowedError extends Error { - constructor() { - super(); - this.name = 'NotAllowedError'; - } -} - -class NotSupportedError extends Error { - constructor() { - super(); - this.name = 'NotSupportedError'; - } -} - -class SecurityError extends Error { - constructor() { - super(); - this.name = 'SecurityError'; - } -} - -class UnknownError extends Error { - constructor() { - super(); - this.name = 'UnknownError'; - } -} diff --git a/packages/browser/src/setupTests.ts b/packages/browser/src/setupTests.ts index 5b6efcf..fda8840 100644 --- a/packages/browser/src/setupTests.ts +++ b/packages/browser/src/setupTests.ts @@ -24,3 +24,64 @@ Object.defineProperty(window, 'location', { hostname: '', }, }); + +/** + * Define WebAuthn's custom API errors + */ + +class AbortError extends Error { + constructor() { + super(); + this.name = 'AbortError'; + } +} + +class ConstraintError extends Error { + constructor() { + super(); + this.name = 'ConstraintError'; + } +} + +class InvalidStateError extends Error { + constructor() { + super(); + this.name = 'InvalidStateError'; + } +} + +class NotAllowedError extends Error { + constructor() { + super(); + this.name = 'NotAllowedError'; + } +} + +class NotSupportedError extends Error { + constructor() { + super(); + this.name = 'NotSupportedError'; + } +} + +class SecurityError extends Error { + constructor() { + super(); + this.name = 'SecurityError'; + } +} + +class UnknownError extends Error { + constructor() { + super(); + this.name = 'UnknownError'; + } +} + +Object.defineProperty(global, 'AbortError', { value: AbortError }); +Object.defineProperty(global, 'ConstraintError', { value: ConstraintError }); +Object.defineProperty(global, 'InvalidStateError', { value: InvalidStateError }); +Object.defineProperty(global, 'NotAllowedError', { value: NotAllowedError }); +Object.defineProperty(global, 'NotSupportedError', { value: NotSupportedError }); +Object.defineProperty(global, 'SecurityError', { value: SecurityError }); +Object.defineProperty(global, 'UnknownError', { value: UnknownError }); |