diff options
author | Matthew Miller <matthew@millerti.me> | 2023-06-25 10:45:31 -0700 |
---|---|---|
committer | Matthew Miller <matthew@millerti.me> | 2023-06-25 10:45:31 -0700 |
commit | 10a19c7a5db55e97714554c56e1448378dfd376c (patch) | |
tree | 06ac0ae746e0d23b28bcdb9bed3ba8dbd20f8b81 /packages/browser/src/methods | |
parent | 87c3275a771272a84bb178374b381bcaefbdacec (diff) |
Add tests
Diffstat (limited to 'packages/browser/src/methods')
-rw-r--r-- | packages/browser/src/methods/startRegistration.test.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/packages/browser/src/methods/startRegistration.test.ts b/packages/browser/src/methods/startRegistration.test.ts index debaba3..f8c0e5a 100644 --- a/packages/browser/src/methods/startRegistration.test.ts +++ b/packages/browser/src/methods/startRegistration.test.ts @@ -250,6 +250,33 @@ test('should return authenticatorAttachment if present', async () => { expect(response.authenticatorAttachment).toEqual('cross-platform'); }); +test('should return convenience values if present', async () => { + /** + * I call them "convenience values" because the getters for public key algorithm, + * public key bytes, and authenticator data are alternative ways to access information + * that's already buried in the response. + */ + // Mock extension return values from authenticator + mockNavigatorCreate.mockImplementation((): Promise<any> => { + return new Promise(resolve => { + resolve({ + response: { + getPublicKeyAlgorithm: () => 777, + getPublicKey: () => new Uint8Array([0, 0, 0, 0]).buffer, + getAuthenticatorData: () => new Uint8Array([0, 0, 0, 0]).buffer, + }, + getClientExtensionResults: () => { }, + }); + }); + }); + + const response = await startRegistration(goodOpts1); + + expect(response.response.publicKeyAlgorithm).toEqual(777); + expect(response.response.publicKey).toEqual('AAAAAA'); + expect(response.response.authenticatorData).toEqual('AAAAAA'); +}); + describe('WebAuthnError', () => { describe('AbortError', () => { const AbortError = generateCustomError('AbortError'); |