63 lines
2.6 KiB
JavaScript
63 lines
2.6 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import {
|
|
parseNativeWaterBuildArgs,
|
|
selectNativeWaterChunkKeys,
|
|
} from "./native-water-build-utils.mjs";
|
|
|
|
test("water builder parses recipe, source and output options without losing paths", () => {
|
|
assert.deepEqual(parseNativeWaterBuildArgs([
|
|
"--recipe", "recipes/the-origin.json",
|
|
"--source-root", "F:/rom source",
|
|
"--output-root", "runewaker-export-work/the-origin/native-water-source",
|
|
"--audit-cache-root", "runewaker-export-work/the-origin",
|
|
]), {
|
|
help: false,
|
|
recipe: "recipes/the-origin.json",
|
|
"source-root": "F:/rom source",
|
|
"output-root": "runewaker-export-work/the-origin/native-water-source",
|
|
"audit-cache-root": "runewaker-export-work/the-origin",
|
|
});
|
|
assert.throws(() => parseNativeWaterBuildArgs(["--typo", "x"]), /Unknown option/);
|
|
assert.throws(() => parseNativeWaterBuildArgs(["--recipe", "one", "--recipe", "two"]), /only be supplied once/);
|
|
});
|
|
|
|
test("water builder binds a ground selection to the identical WDB and uses exact coordinates", () => {
|
|
const sourceWdbSha256 = "a".repeat(64);
|
|
const selected = selectNativeWaterChunkKeys({
|
|
wdbChunkKeys: [0x00020002, 0x00030004, 0x00040005],
|
|
sourceWdbSha256,
|
|
groundManifest: {
|
|
source: { wdbSha256: sourceWdbSha256 },
|
|
chunks: [
|
|
{ id: "chunk-x2-z2", coordinate: { x: 2, z: 2 } },
|
|
{ key: 0x00030004 },
|
|
],
|
|
},
|
|
});
|
|
assert.deepEqual(selected.selectedKeys, [0x00020002, 0x00030004]);
|
|
assert.equal(selected.selection.chunkCount, 2);
|
|
assert.throws(() => selectNativeWaterChunkKeys({
|
|
wdbChunkKeys: [0x00020002],
|
|
sourceWdbSha256,
|
|
groundManifest: { source: { wdbSha256: "b".repeat(64) }, chunks: [{ coordinate: { x: 2, z: 2 } }] },
|
|
}), /does not match/);
|
|
assert.throws(() => selectNativeWaterChunkKeys({
|
|
wdbChunkKeys: [0x00020002],
|
|
sourceWdbSha256,
|
|
groundManifest: { source: { wdbSha256: sourceWdbSha256 }, chunks: [{ id: "chunk-x2-z2" }, { id: "chunk-x2-z2" }] },
|
|
}), /repeats chunk/);
|
|
assert.throws(() => selectNativeWaterChunkKeys({
|
|
wdbChunkKeys: [0x00020002],
|
|
sourceWdbSha256,
|
|
groundManifest: { source: { wdbSha256: sourceWdbSha256 }, chunks: [{ coordinate: { x: 9, z: 9 } }] },
|
|
}), /absent from the source WDB/);
|
|
});
|
|
|
|
test("water builder defaults to every WDB chunk when no ground manifest is supplied", () => {
|
|
const result = selectNativeWaterChunkKeys({ wdbChunkKeys: [9, 3, 5], sourceWdbSha256: "c".repeat(64) });
|
|
assert.deepEqual(result.selectedKeys, [3, 5, 9]);
|
|
assert.equal(result.selection.kind, "all-wdb-chunks");
|
|
});
|