Improved tests for reading model folder

This commit is contained in:
Alexander Cerutti
2023-04-20 08:30:42 +02:00
parent 5a74057a95
commit a625184252

View File

@@ -989,8 +989,6 @@ describe("PKPass", () => {
const buffers = pkpass.getAsRaw();
console.log(buffers, modelFiles);
for (let fileName of Object.keys(buffers)) {
/** Skipping generated files */
if (
@@ -1006,6 +1004,35 @@ describe("PKPass", () => {
}
});
it("should throw an error if a model folder doesn't exist", () => {
expect(() =>
PKPass.from({
model: path.resolve(
__dirname,
"this/model/doesnt/exists.pass",
),
}),
).rejects.toBeInstanceOf(Error);
});
it("should enforce .pass model extension", async () => {
expect(
async () =>
await PKPass.from({
model: path.resolve(
__dirname,
"../examples/models/examplePass",
),
certificates: {
signerCert: SIGNER_CERT,
signerKey: SIGNER_KEY,
signerKeyPassphrase: SIGNER_KEY_PASSPHRASE,
wwdr: WWDR,
},
}),
).not.toThrow();
});
it("should silently filter out manifest and signature files", async () => {
pkpass = await PKPass.from({
model: path.resolve(__dirname, EXAMPLE_PATH_RELATIVE),