import { describe, expect, it } from "vitest"; import { existsSync, readFileSync } from "node:fs"; import { dirname, join, resolve } from "node:path"; import { fileURLToPath } from "node:url"; import { scumCatalogEntries, scumCatalogIconUrl } from "../examples/scum-server-plugin/features/scum-catalog.js"; const pluginRoot = resolve(dirname(fileURLToPath(import.meta.url)), "../examples/scum-server-plugin"); const catalogSource = readFileSync(join(pluginRoot, "features/scum-catalog.ts"), "utf8"); describe("scum catalog icons", () => { it("resolves icons on demand instead of importing each icon as its own module", () => { expect(catalogSource).not.toContain("import.meta.glob"); expect(scumCatalogIconUrl("npcs/zombie11.webp")).toContain("zombie11.webp"); expect(scumCatalogIconUrl("npcs/does-not-exist.webp")).toBe(""); }); it("ships an icon file for every entry that declares one", () => { const missing = scumCatalogEntries.filter((entry) => entry.icon && !existsSync(join(pluginRoot, "assets/scum-catalog", entry.icon))); expect(missing.map((entry) => entry.icon)).toEqual([]); }); });