Validators using zod
This commit is contained in:
@@ -61,16 +61,16 @@ Deno.test("a liquid's still texture is its top and bottom, the flowing one its s
|
||||
Deno.test("check-mods catches liquids that can't work", () => {
|
||||
assertEquals(validate_block(OIL), []);
|
||||
const problems = (json: Record<string, unknown>) => validate_block({ ...OIL, ...json });
|
||||
assertEquals(problems({ liquid: { range: 8 } }), ["liquid.range must be a whole number from 1 to 7"]);
|
||||
assertEquals(problems({ liquid: { range: 8 } }), ["liquid.range must be at most 7"]);
|
||||
assertEquals(problems({ liquid: true }), ["liquid must be { range, ticks, renewable }, or {}"]);
|
||||
assertEquals(problems({ liquid: { ticks: 0 } }), ["liquid.ticks must be a whole number of 1 or more"]);
|
||||
assertEquals(problems({ liquid: { speed: 2 } }), ["liquid.speed isn't a liquid property"]);
|
||||
assertEquals(problems({ liquid: { ticks: 0 } }), ["liquid.ticks must be 1 or more"]);
|
||||
assertEquals(problems({ liquid: { speed: 2 } }), ['liquid can\'t have "speed"']);
|
||||
assertEquals(problems({ textures: { top: "a:b" } }), [
|
||||
"a liquid's textures must be a texture id or { still, flowing }",
|
||||
"textures must be a texture id or { still, flowing } for a liquid",
|
||||
]);
|
||||
assertEquals(problems({ model: "engine:cross" }), ["a liquid can't have model, the engine draws it"]);
|
||||
assertEquals(problems({ model: "engine:cross" }), ["model isn't for liquids, the engine draws them"]);
|
||||
assertEquals(problems({ states: [{ name: "level", bits: 2, default: 0 }] }), [
|
||||
'a liquid gets a "level" state of its own',
|
||||
`states can't have "level", a liquid gets that state of its own`,
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user