Skip to content

Commit 5a567db

Browse files
committed
test: add test with importFrom & useTypeImports
1 parent 2484a06 commit 5a567db

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests/valibot.spec.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,39 @@ describe('valibot', () => {
238238
expect(result.content).toMatchInlineSnapshot(`
239239
"
240240
241+
export function SaySchema(): v.GenericSchema<Say> {
242+
return v.object({
243+
phrase: v.string()
244+
})
245+
}
246+
"
247+
`);
248+
});
249+
it('with importFrom & useTypeImports', async () => {
250+
const schema = buildSchema(/* GraphQL */ `
251+
input Say {
252+
phrase: String!
253+
}
254+
`);
255+
const result = await plugin(
256+
schema,
257+
[],
258+
{
259+
schema: 'valibot',
260+
importFrom: './types',
261+
useTypeImports: true,
262+
},
263+
{},
264+
);
265+
expect(result.prepend).toMatchInlineSnapshot(`
266+
[
267+
"import * as v from 'valibot'",
268+
"import type { Say } from './types'",
269+
]
270+
`);
271+
expect(result.content).toMatchInlineSnapshot(`
272+
"
273+
241274
export function SaySchema(): v.GenericSchema<Say> {
242275
return v.object({
243276
phrase: v.string()

0 commit comments

Comments
 (0)