import { test, expect, describe } from "bun:test"; import committed from "../../generated/block-meta.json"; import packageJson from "../../package.json"; import { dumpBlockMeta } from "../../src/level-blocks/meta.ts"; import { standardRegistry } from "../../src/level-blocks/standard.ts"; describe("generated/block-meta.json", () => { test("matches a fresh dump of the standard registry", () => { // JSON.parse(JSON.stringify(...)) drops `undefined`-valued keys and the // readonly-ness the in-memory dump carries, matching the on-disk shape. const fresh = JSON.parse( JSON.stringify(dumpBlockMeta(standardRegistry())), ) as typeof committed; expect(committed).toEqual(fresh); // If this fails, the registry (a block schema/shadow or the composition // grammar) changed: re-run `bun run scripts/generate-block-meta.ts` and // commit generated/block-meta.json. }); test("is stamped with the current levelset version and format 1", () => { const fresh = dumpBlockMeta(standardRegistry()); expect((committed as { levelsetVersion: string }).levelsetVersion).toBe( fresh.levelsetVersion, ); expect((committed as { formatVersion: number }).formatVersion).toBe(1); }); test("has a stable public JSON subpath in source and published exports", () => { expect(packageJson.exports["./block-meta.json"]).toBe( "./generated/block-meta.json", ); expect(packageJson.publishConfig.exports["./block-meta.json"]).toBe( "./generated/block-meta.json", ); expect(packageJson.files).toContain("generated"); }); });