49 lines
2.1 KiB
TypeScript
49 lines
2.1 KiB
TypeScript
// @vitest-environment node
|
|
import { readFile } from "node:fs/promises";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { describe, expect, it } from "vitest";
|
|
import { displayHostAssetUrls } from "../src/display-assets.js";
|
|
|
|
const packageDirectory = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
|
|
|
|
describe("display host asset locator", () => {
|
|
it("exports only frozen immutable href strings for the two exact built files", () => {
|
|
expect(Object.isFrozen(displayHostAssetUrls)).toBe(true);
|
|
expect(displayHostAssetUrls).toEqual({
|
|
html: new URL("dist/browser/display/index.html", `file://${packageDirectory}/`).href,
|
|
script: new URL("dist/browser/display/app.js", `file://${packageDirectory}/`).href,
|
|
});
|
|
expect(typeof displayHostAssetUrls.html).toBe("string");
|
|
expect(typeof displayHostAssetUrls.script).toBe("string");
|
|
});
|
|
|
|
it("publishes the locator through a narrow package subpath, not the shell root barrel", async () => {
|
|
const manifest = JSON.parse(
|
|
await readFile(path.join(packageDirectory, "package.json"), "utf8"),
|
|
) as { exports?: Record<string, unknown> };
|
|
expect(manifest.exports?.["./display-assets"]).toEqual({
|
|
import: "./dist/display-assets.js",
|
|
types: "./dist/display-assets.d.ts",
|
|
});
|
|
|
|
const rootSource = await readFile(path.join(packageDirectory, "src/index.ts"), "utf8");
|
|
expect(rootSource).not.toContain("displayHostAssetUrls");
|
|
expect(rootSource).not.toContain("display-assets");
|
|
});
|
|
|
|
it("uses a fixed root script asset and only structural full-viewport page styles", async () => {
|
|
const html = await readFile(path.join(packageDirectory, "display.html"), "utf8");
|
|
|
|
expect(html).toContain('id="ekklesia-display"');
|
|
expect(html).toContain('src="/assets/ekklesia-display/app.js"');
|
|
expect(html).toContain('name="viewport"');
|
|
expect(html).toContain("height: 100%");
|
|
expect(html).toContain("margin: 0");
|
|
expect(html).not.toContain("<nav");
|
|
expect(html).not.toContain("<header");
|
|
expect(html).not.toContain("<aside");
|
|
expect(html).not.toContain("fullscreen");
|
|
});
|
|
});
|