diff options
Diffstat (limited to 'packages/browser/src/methods/startRegistration.test.ts')
-rw-r--r-- | packages/browser/src/methods/startRegistration.test.ts | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/packages/browser/src/methods/startRegistration.test.ts b/packages/browser/src/methods/startRegistration.test.ts index 58d9acd..70eb975 100644 --- a/packages/browser/src/methods/startRegistration.test.ts +++ b/packages/browser/src/methods/startRegistration.test.ts @@ -8,6 +8,7 @@ import { generateCustomError } from '../helpers/__jest__/generateCustomError'; import { browserSupportsWebauthn } from '../helpers/browserSupportsWebauthn'; import bufferToBase64URLString from '../helpers/bufferToBase64URLString'; import { WebAuthnError } from '../helpers/structs'; +import { webauthnAbortService } from '../helpers/webAuthnAbortService'; import utf8StringToBuffer from '../helpers/utf8StringToBuffer'; @@ -211,6 +212,18 @@ test('should return "cable" transport from response', async () => { expect(response.transports).toEqual(["cable"]); }); +test('should cancel an existing call when executed again', async () => { + const abortSpy = jest.spyOn(AbortController.prototype, 'abort'); + // Reset the abort service so we get an accurate call count + // @ts-ignore + webauthnAbortService.controller = undefined; + + // Fire off a request and immediately attempt a second one + startRegistration(goodOpts1); + await startRegistration(goodOpts1); + expect(abortSpy).toHaveBeenCalledTimes(1); +}); + describe('WebAuthnError', () => { describe('AbortError', () => { const AbortError = generateCustomError('AbortError'); |