Skip to content

Commit

Permalink
chore (ui): add test for zod schema nullable (#4712)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgrammel authored Feb 5, 2025
1 parent 244dd77 commit 97b446f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/ui-utils/src/__snapshots__/zod-schema.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`zodSchema > json schema conversion > nullable > should support nullable 1`] = `
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"location": {
"type": [
"string",
"null",
],
},
},
"required": [
"location",
],
"type": "object",
}
`;

exports[`zodSchema > json schema conversion > should create a schema with simple types 1`] = `
{
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
12 changes: 12 additions & 0 deletions packages/ui-utils/src/zod-schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,18 @@ describe('zodSchema', () => {

expect(schema.jsonSchema).toMatchSnapshot();
});

describe('nullable', () => {
it('should support nullable', () => {
const schema = zodSchema(
z.object({
location: z.string().nullable(),
}),
);

expect(schema.jsonSchema).toMatchSnapshot();
});
});
});

describe('output validation', () => {
Expand Down

0 comments on commit 97b446f

Please sign in to comment.