Files
RuneStone/tests/unit/release/featureChunks.spec.ts
T
Knotty Wyvern ab868bbe8e Make Background a native feature
- Background replaces the Background Slideshow plugin and the background image of Appearance. It shows a folder as a slideshow, or one image.
- It is on by default. Its module loads at launch only when a folder or an image is chosen.
- Rust keeps the one folder in background-folder.json. The interface never sends a path. Eight background_* commands replace the six deprecated backgrounds_* commands.
- The first start moves the slideshow folder and settings, and keeps the saved image as the image source.
- One blur worker with a cache, fewer folder reads, and a decode before each fade. The hub writes only the changed properties.
- Remove the deprecated folder methods of api.backgrounds. set, get, and subscribe stay for the Project Management plugin.
- Show the view buttons in the workbench test without text, after UI-056.
- Update the tests, the measurement tool, the docs, and UI-057.
2026-10-29 17:25:17 -07:00

42 lines
2.5 KiB
TypeScript

import { test } from "node:test";
import assert from "node:assert/strict";
import { checkChunks, featureModule, staticClosure } from "../../../scripts/featureChunks.mjs";
const root = "D:/RuneStone/";
const chunk = (fileName: string, fields: Record<string, unknown> = {}) => ({ fileName, isEntry: false, isDynamicEntry: false, facadeModuleId: null, imports: [], moduleIds: [], size: 10, ...fields });
test("the static closure follows imports from each entry, and not dynamic imports", () => {
const chunks = [
chunk("app.js", { isEntry: true, imports: ["shared.js"] }),
chunk("node.js", { isEntry: true }),
chunk("shared.js", { imports: ["deep.js"] }),
chunk("deep.js"),
chunk("git.js", { isDynamicEntry: true, imports: ["shared.js"] }),
];
assert.deepEqual([...staticClosure(chunks)].sort(), ["app.js", "deep.js", "node.js", "shared.js"]);
});
test("feature folders and feature libraries count as feature modules, and the runtime does not", () => {
assert.equal(featureModule(`${root}src/lib/features/git/index.ts`), true);
assert.equal(featureModule("D:\\RuneStone\\src\\lib\\features\\git\\model.ts"), true);
assert.equal(featureModule(`${root}src/lib/features/catalog.ts`), false);
assert.equal(featureModule(`${root}node_modules/.pnpm/@[email protected]/node_modules/@xterm/xterm/lib/xterm.mjs`), true);
assert.equal(featureModule(`${root}node_modules/pdfjs-dist/build/pdf.mjs`), true);
assert.equal(featureModule(`${root}node_modules/svelte/src/index.js`), false);
});
test("a feature module in a start chunk fails, and a separate dynamic chunk passes", () => {
const good = [
chunk("app.js", { isEntry: true, moduleIds: [`${root}src/lib/features/catalog.ts`] }),
chunk("git.js", { isDynamicEntry: true, facadeModuleId: `${root}src/lib/features/git/index.ts`, moduleIds: [`${root}src/lib/features/git/index.ts`], size: 2048 }),
];
assert.deepEqual(checkChunks(good, ["git"]), { problems: [], sizes: { git: 2048 } });
const bad = [
chunk("app.js", { isEntry: true, imports: ["shared.js"] }),
chunk("shared.js", { moduleIds: [`${root}src/lib/features/git/model.ts`] }),
chunk("git.js", { isDynamicEntry: true, facadeModuleId: `${root}src/lib/features/git/index.ts` }),
];
assert.deepEqual(checkChunks(bad, ["git"]).problems, ["shared.js loads at start and contains src/lib/features/git/model.ts"]);
assert.deepEqual(checkChunks([chunk("app.js", { isEntry: true })], ["git"]).problems, ["No chunk starts at src/lib/features/git/index.ts."]);
});