Fix tests
This commit is contained in:
+1
-1
@@ -63,7 +63,7 @@ Deno.test("bad biome json is reported", () => {
|
||||
assert(validate_biome({ ...PLAIN, colors: { grass: "green" } }).some((p) => p.startsWith("colors.grass")));
|
||||
// which kinds of tree there are is up to the trees feature, see tests/wood_test.ts
|
||||
assertEquals(validate_biome({ ...PLAIN, trees: { chance: 2, kinds: ["palm"] } }), [
|
||||
"trees.chance must be a number from 0 to 1",
|
||||
"trees.chance must be at most 1",
|
||||
]);
|
||||
assert(validate_biome({ ...PLAIN, trees: { chance: 1, kinds: [] } }).some((p) => p.startsWith("trees.kinds")));
|
||||
assert(validate_biome({ id: "my_mod:flat" }).some((p) => p.startsWith("surface")));
|
||||
|
||||
+13
-5
@@ -155,13 +155,21 @@ Deno.test("a table's json says what's wrong with it", () => {
|
||||
const table = { id: "t:x", pools: [{ entries: [{ item: "t:a" }] }] };
|
||||
assertEquals(validate_loot_table(table), []);
|
||||
const problems = (json: unknown) => validate_loot_table(json).join("\n");
|
||||
assert(problems({ ...table, pools: [{ entries: [] }] }).includes("entries must be a list"));
|
||||
assert(problems({ ...table, pools: [{ entries: [] }] }).includes("entries can't be empty"));
|
||||
assert(problems({ ...table, pools: [{ rolls: -1, entries: [{ item: "t:a" }] }] }).includes("rolls"));
|
||||
assert(problems({ ...table, pools: [{ entries: [{ type: "tag", tag: "t:gems" }] }] }).includes("#tag"));
|
||||
assert(problems({ ...table, pools: [{ entries: [{ type: "loot_table" }] }] }).includes("table is needed"));
|
||||
assert(problems({ ...table, conditions: [{ condition: "full_moon" }] }).includes("isn't a loot condition"));
|
||||
assert(problems({ ...table, functions: [{ function: "enchant" }] }).includes("isn't a loot function"));
|
||||
assert(problems({ ...table, conditions: [{ condition: "random_chance", chance: 2 }] }).includes("0 to 1"));
|
||||
assert(
|
||||
problems({ ...table, pools: [{ entries: [{ type: "loot_table" }] }] }).includes(
|
||||
"table must be a loot table id",
|
||||
),
|
||||
);
|
||||
assert(problems({ ...table, conditions: [{ condition: "full_moon" }] }).includes("condition must be one of"));
|
||||
assert(problems({ ...table, functions: [{ function: "enchant" }] }).includes("function must be one of"));
|
||||
assert(
|
||||
problems({ ...table, conditions: [{ condition: "random_chance", chance: 2 }] }).includes(
|
||||
"chance must be at most 1",
|
||||
),
|
||||
);
|
||||
// a mod's own are only checked once its script registers them
|
||||
assertEquals(validate_loot_table({ ...table, conditions: [{ condition: "m:full_moon" }] }), []);
|
||||
});
|
||||
|
||||
@@ -43,14 +43,16 @@ Deno.test("a texture's .json that doesn't fit its png says why", () => {
|
||||
assertEquals(validate_texture_json({ animation: {} }, size), []);
|
||||
assertEquals(validate_texture_json([], size), ['must be { "animation": { ... } }']);
|
||||
assertEquals(validate_texture_json({ animation: { frametime: 0 } }, size), [
|
||||
"animation.frametime must be a whole number of ticks, at least 1",
|
||||
"animation.frametime must be 1 or more",
|
||||
]);
|
||||
assertEquals(validate_texture_json({ animation: { height: 20 } }, size), [
|
||||
"the png is 16×48, which doesn't split into 16×20 frames",
|
||||
]);
|
||||
assertEquals(validate_texture_json({ animation: { frames: [0, 3, { index: 1 }] } }, size), [
|
||||
"animation.frames[1]: the png has frames 0 to 2",
|
||||
"animation.frames[2]: time must be a whole number of ticks, at least 1",
|
||||
assertEquals(validate_texture_json({ animation: { frames: [0, 3] } }, size), [
|
||||
"animation.frames[1] isn't one of the png's frames, 0 to 2",
|
||||
]);
|
||||
assertEquals(validate_texture_json({ animation: { frames: [{ index: 1 }] } }, size), [
|
||||
"animation.frames[0].time is required",
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -111,7 +113,7 @@ Deno.test("a texture's .json is checked, packed into the .bmod and read back", a
|
||||
"broken.bmod",
|
||||
),
|
||||
Error,
|
||||
"textures/goo.json: animation.frames[0]: the png has frames 0 to 1",
|
||||
"textures/goo.json: animation.frames[0] isn't one of the png's frames, 0 to 1",
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user