Skip to content

Commit

Permalink
Update tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
lgarron committed Jan 17, 2023
1 parent aa509f5 commit cf64a49
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 22 deletions.
41 changes: 19 additions & 22 deletions src/dev/demo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@ import {
} from "../../webauthn-json/browser-ponyfill";

function registeredCredentials(): PublicKeyCredentialDescriptorJSON[] {
return getRegistrations().map(
(reg) => ({
id: reg.rawId,
type: reg.type,
}),
);
return getRegistrations().map((reg) => ({
id: reg.rawId,
type: reg.type,
}));
}

async function register(): Promise<void> {
Expand Down Expand Up @@ -70,22 +68,21 @@ async function testSupported() {

window.addEventListener("load", () => {
try {
document.querySelector("#register")!.addEventListener(
"click",
withStatus("#register .status", register),
);
document.querySelector("#authenticate")!.addEventListener(
"click",
withStatus("#authenticate .status", authenticate),
);
document.querySelector("#clear")!.addEventListener(
"click",
withStatus("#clear .status", clear),
);
document.querySelector("#supported")!.addEventListener(
"click",
testSupported,
);
document
.querySelector("#register")!
.addEventListener("click", withStatus("#register .status", register));
document
.querySelector("#authenticate")!
.addEventListener(
"click",
withStatus("#authenticate .status", authenticate),
);
document
.querySelector("#clear")!
.addEventListener("click", withStatus("#clear .status", clear));
document
.querySelector("#supported")!
.addEventListener("click", testSupported);
} catch (e) {
console.error(e);
}
Expand Down
11 changes: 11 additions & 0 deletions src/webauthn-json/webauthn-schema.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ import {
import { convert } from "./convert";
import "./arraybuffer.jest";

const unimplemented: any = () => {
throw new Error("unimplemented");
};

describe("webauthn schema", () => {
test("converts CredentialCreationOptionsJSON", () => {
const cco: CredentialCreationOptionsJSON = {
Expand Down Expand Up @@ -67,6 +71,9 @@ describe("webauthn schema", () => {
clientDataJSON: new Uint8Array([9, 10, 11, 12]),
attestationObject: new Uint8Array([13, 14, 15, 16]),
getTransports: () => ["usb"],
getAuthenticatorData: unimplemented,
getPublicKey: unimplemented,
getPublicKeyAlgorithm: unimplemented,
} as AuthenticatorAttestationResponse,
getClientExtensionResults: () =>
({
Expand Down Expand Up @@ -109,6 +116,10 @@ describe("webauthn schema", () => {
response: {
clientDataJSON: new Uint8Array([9, 10, 11, 12]),
attestationObject: new Uint8Array([13, 14, 15, 16]),
getAuthenticatorData: unimplemented,
getPublicKey: unimplemented,
getPublicKeyAlgorithm: unimplemented,
getTransports: unimplemented,
} as AuthenticatorAttestationResponse,
getClientExtensionResults: () =>
({
Expand Down

0 comments on commit cf64a49

Please sign in to comment.