Skip to content

Commit

Permalink
Add addQuestionMarks test case
Browse files Browse the repository at this point in the history
  • Loading branch information
colinhacks committed Apr 14, 2024
1 parent edc5ddf commit 0a80b66
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions deno/lib/__tests__/generics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,11 @@ test("assignability", () => {
};
createSchemaAndParse("foo", z.string(), { foo: "" });
});

test("nested no undefined", () => {
const inner = z.string().or(z.array(z.string()));
const outer = z.object({ inner });
type outerSchema = z.infer<typeof outer>;
z.util.assertEqual<outerSchema, { inner: string | string[] }>(true);
expect(outer.safeParse({ inner: undefined }).success).toEqual(false);
});
8 changes: 8 additions & 0 deletions src/__tests__/generics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,11 @@ test("assignability", () => {
};
createSchemaAndParse("foo", z.string(), { foo: "" });
});

test("nested no undefined", () => {
const inner = z.string().or(z.array(z.string()));
const outer = z.object({ inner });
type outerSchema = z.infer<typeof outer>;
z.util.assertEqual<outerSchema, { inner: string | string[] }>(true);
expect(outer.safeParse({ inner: undefined }).success).toEqual(false);
});

0 comments on commit 0a80b66

Please sign in to comment.