Skip to content

Commit

Permalink
Add positive tests too
Browse files Browse the repository at this point in the history
  • Loading branch information
alcuadrado committed Oct 30, 2024
1 parent 62d9750 commit 0d4a831
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions v-next/hardhat-zod-utils/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,23 @@ describe("unionType", () => {
assertParseResult(mySchema2.safeParse(false), "Expected a URL or number");
assertParseResult(mySchema2.safeParse("a"), "Expected a URL or number");
});

it("Should accept valid data", () => {
const mySchema = unionType(
[z.string(), z.number()],
"Expected a string or number",
);

mySchema.parse("asd");
mySchema.parse(123);

const mySchema2 = unionType(
[z.string().url(), z.number()],
"Expected a URL or number",
);
mySchema2.parse("http://example.com");
mySchema2.parse(123);
});
});

describe("conditionalUnionType", () => {
Expand Down

0 comments on commit 0d4a831

Please sign in to comment.