Added setNFCCapability implementation along with tests

This commit is contained in:
Alexander Cerutti
2021-09-19 22:45:37 +02:00
parent a3195e7d21
commit 389aa96532
2 changed files with 42 additions and 5 deletions

View File

@@ -95,4 +95,36 @@ describe("PKPass", () => {
);
});
});
describe("setNFCCapability", () => {
it("should reset instance.props['nfc'] if 'null' is passed as value", () => {
const pass = new PKPass({}, {});
pass.setNFCCapability({
encryptionPublicKey: "mimmo",
message: "No message for you here",
});
expect(pass.props["nfc"]).toEqual({
encryptionPublicKey: "mimmo",
message: "No message for you here",
});
pass.setNFCCapability(null);
expect(pass.props["nfc"]).toBeUndefined();
});
it("should not accept invalid objects", () => {
const pass = new PKPass({}, {});
pass.setNFCCapability({
// @ts-expect-error
requiresAuth: false,
encryptionPublicKey: "Nope",
});
expect(pass.props["nfc"]).toBeUndefined();
});
});
});