BlueGit

timfa questward

Files

questward / server / tests / editor-diff.test.js

editor-diff.test.js

editor-diff.test.js 828 B Download Raw
1import test from "node:test";
2import assert from "node:assert/strict";
3import { createEmptyChunkData } from "../src/world/chunkData.js";
4import { diffChunks } from "../src/editor/service.js";
5import { GroundType, BlockType } from "../../shared/definitions/tiles.js";
6
7test("chunk diffs describe ground, block, and open-closed changes", () =>
8{
9 const previous = createEmptyChunkData();
10 const next = createEmptyChunkData();
11 next.open = true;
12 next.grounds[0] = GroundType.wood;
13 next.blocks[1] = { typeId: BlockType.torch, config: null };
14 const bullets = diffChunks(0, 0, previous, next, false);
15 assert.ok(bullets.includes("Chunk opened."));
16 assert.ok(bullets.some((line) => line.includes("Ground at 0, 0 changed from Grass to Wood.")));
17 assert.ok(bullets.some((line) => line.includes("Block Torch placed at 1, 0.")));
18});