import test from "node:test"; import assert from "node:assert/strict"; import { createEmptyChunkData } from "../src/world/chunkData.js"; import { diffChunks } from "../src/editor/service.js"; import { GroundType, BlockType } from "../../shared/definitions/tiles.js"; test("chunk diffs describe ground, block, and open-closed changes", () => { const previous = createEmptyChunkData(); const next = createEmptyChunkData(); next.open = true; next.grounds[0] = GroundType.wood; next.blocks[1] = { typeId: BlockType.torch, config: null }; const bullets = diffChunks(0, 0, previous, next, false); assert.ok(bullets.includes("Chunk opened.")); assert.ok(bullets.some((line) => line.includes("Ground at 0, 0 changed from Grass to Wood."))); assert.ok(bullets.some((line) => line.includes("Block Torch placed at 1, 0."))); }); test("chunk diffs describe spawner placement", () => { const previous = createEmptyChunkData(); const next = createEmptyChunkData(); next.spawners = [{ localX: 2, localY: 3, config: { spawnerId: "0:0:50", mobTypeId: "deer", maxAlive: 2, spawnRangeTiles: 4 } }]; const bullets = diffChunks(0, 0, previous, next, true); assert.ok(bullets.some((line) => line.includes("Spawner (deer) placed at 2, 3."))); }); test("chunk diffs name the Void block", () => { const previous = createEmptyChunkData(); const next = createEmptyChunkData(); next.blocks[0] = { typeId: BlockType.void, state: null, config: null }; const bullets = diffChunks(0, 0, previous, next, true); assert.ok(bullets.some((line) => line.includes("Block Void placed at 0, 0."))); });