Skip to content

Commit

Permalink
Format zod helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
pklaschka committed Sep 9, 2024
1 parent f2a5a4e commit 14e9dd4
Showing 1 changed file with 45 additions and 45 deletions.
90 changes: 45 additions & 45 deletions lib/common/zod-helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,50 @@ import { assertEquals } from "@std/assert";
import { zBoolString } from "$common/zod-helpers.ts";

Deno.test("zBoolString", async (t) => {
const truthyValues = ["1", "true", "yes", "on", "enabled"];
const falsyValues = ["0", "false", "no", "off", "disabled"];
const invalidValues = ["", "2", "foo", "bar", "baz"];
const truthyValues = ["1", "true", "yes", "on", "enabled"];
const falsyValues = ["0", "false", "no", "off", "disabled"];
const invalidValues = ["", "2", "foo", "bar", "baz"];

await t.step("true for truthy values", () => {
for (const value of truthyValues) {
assertEquals(
zBoolString().parse(value),
true,
`${value} should resolve to true`,
);
assertEquals(
zBoolString().parse(value.toUpperCase()),
true,
`${value.toUpperCase()} should resolve to true`,
);
}
});
await t.step("false for falsy values", () => {
for (const value of falsyValues) {
assertEquals(
zBoolString().parse(value),
false,
`${value} should resolve to false`,
);
assertEquals(
zBoolString().parse(value.toUpperCase()),
false,
`${value.toUpperCase()} should resolve to false`,
);
}
});
await t.step("false for invalid values", () => {
for (const value of invalidValues) {
assertEquals(
zBoolString().parse(value),
false,
`${value} should resolve to false`,
);
assertEquals(
zBoolString().parse(value.toUpperCase()),
false,
`${value.toUpperCase()} should resolve to false`,
);
}
});
await t.step("true for truthy values", () => {
for (const value of truthyValues) {
assertEquals(
zBoolString().parse(value),
true,
`${value} should resolve to true`,
);
assertEquals(
zBoolString().parse(value.toUpperCase()),
true,
`${value.toUpperCase()} should resolve to true`,
);
}
});
await t.step("false for falsy values", () => {
for (const value of falsyValues) {
assertEquals(
zBoolString().parse(value),
false,
`${value} should resolve to false`,
);
assertEquals(
zBoolString().parse(value.toUpperCase()),
false,
`${value.toUpperCase()} should resolve to false`,
);
}
});
await t.step("false for invalid values", () => {
for (const value of invalidValues) {
assertEquals(
zBoolString().parse(value),
false,
`${value} should resolve to false`,
);
assertEquals(
zBoolString().parse(value.toUpperCase()),
false,
`${value.toUpperCase()} should resolve to false`,
);
}
});
});

0 comments on commit 14e9dd4

Please sign in to comment.