From 39d4d0094d121a1cf61196ad4b638cfda9ac0b7b Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Tue, 28 Dec 2021 01:06:08 +0100 Subject: [PATCH] Added some tests for PKPass[createManifestSymbol] --- spec/PKPass.ts | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/spec/PKPass.ts b/spec/PKPass.ts index ffc6751..ec35a18 100644 --- a/spec/PKPass.ts +++ b/spec/PKPass.ts @@ -12,6 +12,7 @@ import { passTypeSymbol, importMetadataSymbol, closePassSymbol, + createManifestSymbol, } from "../lib/PKPass"; describe("PKPass", () => { @@ -1034,6 +1035,38 @@ describe("PKPass", () => { }); }); + describe("[createManifestSymbol]", () => { + it("should create a list of SHA-1s", () => { + pass.addBuffer("icon.png", Buffer.alloc(0)); + pass.addBuffer("icon@2x.png", Buffer.alloc(0)); + pass.addBuffer("icon@3x.png", Buffer.alloc(0)); + + expect( + JSON.parse(pass[createManifestSymbol]().toString("utf-8")), + ).toEqual({ + "icon.png": "da39a3ee5e6b4b0d3255bfef95601890afd80709", + "icon@2x.png": "da39a3ee5e6b4b0d3255bfef95601890afd80709", + "icon@3x.png": "da39a3ee5e6b4b0d3255bfef95601890afd80709", + }); + }); + + it("List of Sha-1 of localized files should not contain Windows '\\' slash", () => { + if (path.sep === "\\") { + pass.addBuffer("en.lproj\\icon.png", Buffer.alloc(0)); + pass.addBuffer("en.lproj\\icon@2x.png", Buffer.alloc(0)); + pass.addBuffer("en.lproj\\icon@3x.png", Buffer.alloc(0)); + + const parsedResult = Object.keys( + JSON.parse(pass[createManifestSymbol]().toString("utf-8")), + ); + + expect(parsedResult[0]).toMatch(/en\.lproj\/icon\.png/); + expect(parsedResult[1]).toMatch(/en\.lproj\/icon@2x\.png/); + expect(parsedResult[1]).toMatch(/en\.lproj\/icon@3x\.png/); + } + }); + }); + describe("[static] from", () => { it("should throw if source is unavailable", async () => { await expectAsync(