|
| 1 | +import assert from "node:assert/strict"; |
| 2 | +import { describe, it } from "node:test"; |
| 3 | +import path from "node:path"; |
| 4 | +import { readInfoPlist } from "./apple"; |
| 5 | +import { setupTempDirectory } from "../test-utils"; |
| 6 | + |
| 7 | +describe("apple", () => { |
| 8 | + describe("Info.plist lookup", () => { |
| 9 | + it("should find Info.plist files in unversioned frameworks", async (context) => { |
| 10 | + const infoPlistContents = `<?xml version="1.0" encoding="UTF-8"?>...`; |
| 11 | + const infoPlistSubPath = "Info.plist"; |
| 12 | + const tempDirectoryPath = setupTempDirectory(context, { |
| 13 | + [infoPlistSubPath]: infoPlistContents, |
| 14 | + }); |
| 15 | + |
| 16 | + const result = await readInfoPlist(tempDirectoryPath); |
| 17 | + |
| 18 | + assert.strictEqual(result.contents, infoPlistContents); |
| 19 | + assert.strictEqual( |
| 20 | + result.infoPlistPath, |
| 21 | + path.join(tempDirectoryPath, infoPlistSubPath), |
| 22 | + ); |
| 23 | + }); |
| 24 | + |
| 25 | + it("should find Info.plist files in versioned frameworks", async (context) => { |
| 26 | + const infoPlistContents = `<?xml version="1.0" encoding="UTF-8"?>...`; |
| 27 | + const infoPlistSubPath = "Versions/Current/Resources/Info.plist"; |
| 28 | + const tempDirectoryPath = setupTempDirectory(context, { |
| 29 | + [infoPlistSubPath]: infoPlistContents, |
| 30 | + }); |
| 31 | + |
| 32 | + const result = await readInfoPlist(tempDirectoryPath); |
| 33 | + |
| 34 | + assert.strictEqual(result.contents, infoPlistContents); |
| 35 | + assert.strictEqual( |
| 36 | + result.infoPlistPath, |
| 37 | + path.join(tempDirectoryPath, infoPlistSubPath), |
| 38 | + ); |
| 39 | + }); |
| 40 | + |
| 41 | + it("should throw if Info.plist is missing from framework", async (context) => { |
| 42 | + const tempDirectoryPath = setupTempDirectory(context, {}); |
| 43 | + |
| 44 | + await assert.rejects( |
| 45 | + async () => readInfoPlist(tempDirectoryPath), |
| 46 | + /Unable to read Info.plist for framework at path ".*?", as an Info.plist file couldn't be found./, |
| 47 | + ); |
| 48 | + }); |
| 49 | + }); |
| 50 | +}); |
0 commit comments