diff options
author | Matthew Miller <matthew@millerti.me> | 2022-07-04 08:04:44 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-04 08:04:44 -0700 |
commit | 184cbb4457285817db4ded722d7b54528988e2e0 (patch) | |
tree | 3b895f8c273e924dd6fdd52c50fd2528575dc41d /packages/browser/src/methods/startRegistration.test.ts | |
parent | 524e7f881624f36aa17f406bb25fa23d02449652 (diff) | |
parent | 5a5b5a3bdf7c709493fc9e63f0f02eed99f25baf (diff) |
Merge pull request #214 from MasterKale/feat/conditional-ui
feat/conditional-ui
Diffstat (limited to 'packages/browser/src/methods/startRegistration.test.ts')
-rw-r--r-- | packages/browser/src/methods/startRegistration.test.ts | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/packages/browser/src/methods/startRegistration.test.ts b/packages/browser/src/methods/startRegistration.test.ts index fcd4a2c..93400c4 100644 --- a/packages/browser/src/methods/startRegistration.test.ts +++ b/packages/browser/src/methods/startRegistration.test.ts @@ -8,10 +8,11 @@ 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'; -import startRegistration from './startRegistration'; +import { startRegistration } from './startRegistration'; jest.mock('../helpers/browserSupportsWebauthn'); @@ -211,6 +212,17 @@ 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 + webauthnAbortService.reset(); + + // 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'); |