BlueGit

timfa questward

Files

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

editor-diff.test.js

spawner tweaks
timfa Tim Falken · pushed by timfa · 2 months ago
661b81e5 History
editor-diff.test.js 1.2 KiB 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});
19
20test("chunk diffs describe spawner placement", () =>
21{
22 const previous = createEmptyChunkData();
23 const next = createEmptyChunkData();
24 next.spawners = [{
25 localX: 2,
26 localY: 3,
27 config: { spawnerId: "0:0:50", mobTypeId: "deer", maxAlive: 2, spawnRangeTiles: 4 }
28 }];
29 const bullets = diffChunks(0, 0, previous, next, true);
30 assert.ok(bullets.some((line) => line.includes("Spawner (deer) placed at 2, 3.")));
31});