mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-16 00:25:30 +00:00
Added setNFCCapability implementation along with tests
This commit is contained in:
@@ -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();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -388,16 +388,21 @@ export default class PKPass extends Bundle {
|
|||||||
* Allows to specify details to make this, an
|
* Allows to specify details to make this, an
|
||||||
* NFC-capable pass.
|
* NFC-capable pass.
|
||||||
*
|
*
|
||||||
|
* Pass `null` as parameter to remove it at all.
|
||||||
|
*
|
||||||
* @see https://developer.apple.com/documentation/walletpasses/pass/nfc
|
* @see https://developer.apple.com/documentation/walletpasses/pass/nfc
|
||||||
* @param data
|
* @param data
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
|
|
||||||
setNFCCapability(data: Schemas.NFC): this {
|
setNFCCapability(nfc: Schemas.NFC | null): this {
|
||||||
/**
|
if (nfc === null) {
|
||||||
* @TODO implement
|
delete this[propsSymbol]["nfc"];
|
||||||
* @TODO specify a way to get current one deleted
|
return this;
|
||||||
*/
|
}
|
||||||
|
|
||||||
|
this[propsSymbol]["nfc"] =
|
||||||
|
Schemas.getValidated(nfc, Schemas.NFC) ?? undefined;
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user