Files
nexu-io__open-design/tools/pack/tests/mac-paths.test.ts
Ethan Guo 06426ca029 test(tools-pack): cover mac/win paths, registry, manifest, NSIS, config validators (#2425)
* test(tools-pack): cover sanitizeNamespace, macAppBundleName, executable path

* test(tools-pack): cover stripRegistryQuotedValue branches

* test(tools-pack): cover readBuiltAppManifest and writePackagedConfig portable flag

* test(tools-pack): cover writeNsisInclude double-quote and newline escaping

* fix(tools-pack): add required requireVelaCli to ToolPackConfig fixtures

`ToolPackConfig` requires `requireVelaCli: boolean`, but the new
win-manifest / win-nsis test fixtures omitted it, so
`pnpm --filter @open-design/tools-pack typecheck` failed with
`'boolean | undefined' is not assignable to 'boolean'`.

Add `requireVelaCli: false` (the production default, per
`options.requireVelaCli === true` in config.ts) to both `makeConfig`
fixtures. Placed before the `...overrides` spread so TypeScript does not
re-widen it through the Partial (verified with tsc --strict).

Addresses review feedback on #2425.
2026-07-03 02:57:17 +00:00

51 lines
1.7 KiB
TypeScript

import { join } from "node:path";
import { describe, expect, it } from "vitest";
import { PRODUCT_NAME } from "../src/mac/constants.js";
import {
macAppBundleName,
macAppExecutablePath,
resolveMacAppOutputDirectoryName,
sanitizeNamespace,
} from "../src/mac/paths.js";
describe("sanitizeNamespace", () => {
it("keeps alphanumerics, dots, hyphens, and underscores", () => {
expect(sanitizeNamespace("Open-Design.beta_1")).toBe("Open-Design.beta_1");
});
it("replaces forbidden chars with hyphens and collapses runs", () => {
expect(sanitizeNamespace("a/b c")).toBe("a-b-c");
expect(sanitizeNamespace("a // b")).toBe("a-b");
expect(sanitizeNamespace("中文/ns")).toBe("-ns");
});
});
describe("macAppBundleName", () => {
it("formats <PRODUCT_NAME>.<sanitized-namespace>.app", () => {
expect(macAppBundleName("release-beta")).toBe(`${PRODUCT_NAME}.release-beta.app`);
expect(macAppBundleName("a b/c")).toBe(`${PRODUCT_NAME}.a-b-c.app`);
});
});
describe("macAppExecutablePath", () => {
it("joins the Contents/MacOS executable path under the bundle", () => {
const appPath = "/tmp/out/mac/Open Design.app";
expect(macAppExecutablePath(appPath)).toBe(join(appPath, "Contents", "MacOS", PRODUCT_NAME));
});
it("honors a custom executable name", () => {
const appPath = "/tmp/out/mac/Open Design.app";
expect(macAppExecutablePath(appPath, "open-design-beta")).toBe(
join(appPath, "Contents", "MacOS", "open-design-beta"),
);
});
});
describe("resolveMacAppOutputDirectoryName", () => {
it("returns mac-arm64 on arm64 hosts, otherwise mac", () => {
expect(resolveMacAppOutputDirectoryName()).toBe(process.arch === "arm64" ? "mac-arm64" : "mac");
});
});