Skip to content

Commit a7a7b97

Browse files
committed
test: support nested input object
1 parent 502c041 commit a7a7b97

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

tests/valibot.spec.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,28 @@ describe('valibot', () => {
129129
"
130130
`);
131131
})
132-
it.todo('nested input object')
132+
it('nested input object', async () => {
133+
const schema = buildSchema(/* GraphQL */ `
134+
input NestedInput {
135+
child: NestedInput
136+
childrens: [NestedInput]
137+
}
138+
`);
139+
const scalars = undefined
140+
const result = await plugin(schema, [], { schema: 'valibot', scalars }, {});
141+
142+
expect(result.content).toMatchInlineSnapshot(`
143+
"
144+
145+
export function NestedInputSchema(): v.GenericSchema<NestedInput> {
146+
return v.object({
147+
child: v.lazy(() => v.nullish(NestedInputSchema())),
148+
childrens: v.nullish(v.array(v.lazy(() => v.nullable(NestedInputSchema()))))
149+
})
150+
}
151+
"
152+
`)
153+
})
133154
it('enum', async () => {
134155
const schema = buildSchema(/* GraphQL */ `
135156
enum PageType {

0 commit comments

Comments
 (0)