summaryrefslogtreecommitdiffhomepage
path: root/packages/browser/src/methods/startRegistration.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/browser/src/methods/startRegistration.test.ts')
-rw-r--r--packages/browser/src/methods/startRegistration.test.ts14
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');