mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 16:25:21 +00:00
Added constructor check for buffers
This commit is contained in:
@@ -32,6 +32,18 @@ describe("PKPass", () => {
|
||||
);
|
||||
});
|
||||
|
||||
describe("constructor", () => {
|
||||
it("should warn about a non-object buffer parameter", () => {
|
||||
console.warn = jasmine.createSpy("warn");
|
||||
|
||||
pass = new PKPass(undefined, baseCerts);
|
||||
|
||||
expect(console.warn).toHaveBeenCalledWith(
|
||||
Messages.INIT.INVALID_BUFFERS.replace("%s", "undefined"),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("setBeacons", () => {
|
||||
it("should reset instance.props['beacons'] if 'null' is passed as value", () => {
|
||||
pass.setBeacons({
|
||||
|
||||
@@ -130,6 +130,7 @@ export default class PKPass extends Bundle {
|
||||
) {
|
||||
super("application/vnd.apple.pkpass");
|
||||
|
||||
if (buffers && typeof buffers === "object") {
|
||||
const buffersEntries = Object.entries(buffers);
|
||||
|
||||
for (
|
||||
@@ -140,6 +141,11 @@ export default class PKPass extends Bundle {
|
||||
const [fileName, contentBuffer] = buffer;
|
||||
this.addBuffer(fileName, contentBuffer);
|
||||
}
|
||||
} else {
|
||||
console.warn(
|
||||
Messages.format(Messages.INIT.INVALID_BUFFERS, typeof buffers),
|
||||
);
|
||||
}
|
||||
|
||||
if (props) {
|
||||
/** Overrides validation and pushing in props */
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
export const INIT = {
|
||||
INVALID_BUFFERS:
|
||||
"Cannot set buffers in constructor: expected object but received %s",
|
||||
} as const;
|
||||
|
||||
export const CERTIFICATES = {
|
||||
INVALID:
|
||||
"Invalid certificate(s) loaded. %s. Please provide valid WWDR certificates and developer signer certificate and key (with passphrase).\nRefer to docs to obtain them",
|
||||
|
||||
Reference in New Issue
Block a user