Skip to content

Implement some unfinished tests for valibot #755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 7, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
test: support nested input object
  • Loading branch information
MH4GF committed Jul 30, 2024
commit a7a7b97261d73611095b204f3faaf7c0f77ae9c9
23 changes: 22 additions & 1 deletion tests/valibot.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,28 @@ describe('valibot', () => {
"
`);
})
it.todo('nested input object')
it('nested input object', async () => {
const schema = buildSchema(/* GraphQL */ `
input NestedInput {
child: NestedInput
childrens: [NestedInput]
}
`);
const scalars = undefined
const result = await plugin(schema, [], { schema: 'valibot', scalars }, {});

expect(result.content).toMatchInlineSnapshot(`
"

export function NestedInputSchema(): v.GenericSchema<NestedInput> {
return v.object({
child: v.lazy(() => v.nullish(NestedInputSchema())),
childrens: v.nullish(v.array(v.lazy(() => v.nullable(NestedInputSchema()))))
})
}
"
`)
})
it('enum', async () => {
const schema = buildSchema(/* GraphQL */ `
enum PageType {
Expand Down