Skip to content

Commit f39a192

Browse files
committed
🧪 add tests
1 parent f48a8da commit f39a192

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

tests/myzod.spec.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,26 @@ describe('myzod', () => {
222222
expect(result.content).toContain('phrase: myzod.string()');
223223
});
224224

225+
it('with importFrom & useTypeImports', async () => {
226+
const schema = buildSchema(/* GraphQL */ `
227+
input Say {
228+
phrase: String!
229+
}
230+
`);
231+
const result = await plugin(
232+
schema,
233+
[],
234+
{
235+
schema: 'myzod',
236+
importFrom: './types',
237+
useTypeImports: true,
238+
},
239+
{}
240+
);
241+
expect(result.prepend).toContain("import type { Say } from './types'");
242+
expect(result.content).toContain('phrase: myzod.string()');
243+
});
244+
225245
it('with enumsAsTypes', async () => {
226246
const schema = buildSchema(/* GraphQL */ `
227247
enum PageType {

tests/yup.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,25 @@ describe('yup', () => {
220220
expect(result.content).toContain('phrase: yup.string().defined()');
221221
});
222222

223+
it('with importFrom & useTypeImports', async () => {
224+
const schema = buildSchema(/* GraphQL */ `
225+
input Say {
226+
phrase: String!
227+
}
228+
`);
229+
const result = await plugin(
230+
schema,
231+
[],
232+
{
233+
importFrom: './types',
234+
useTypeImports: true,
235+
},
236+
{}
237+
);
238+
expect(result.prepend).toContain("import type { Say } from './types'");
239+
expect(result.content).toContain('phrase: yup.string().defined()');
240+
});
241+
223242
it('with enumsAsTypes', async () => {
224243
const schema = buildSchema(/* GraphQL */ `
225244
enum PageType {

tests/zod.spec.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,26 @@ describe('zod', () => {
223223
expect(result.content).toContain('phrase: z.string()');
224224
});
225225

226+
it('with importFrom & useTypeImports', async () => {
227+
const schema = buildSchema(/* GraphQL */ `
228+
input Say {
229+
phrase: String!
230+
}
231+
`);
232+
const result = await plugin(
233+
schema,
234+
[],
235+
{
236+
schema: 'zod',
237+
importFrom: './types',
238+
useTypeImports: true,
239+
},
240+
{}
241+
);
242+
expect(result.prepend).toContain("import type { Say } from './types'");
243+
expect(result.content).toContain('phrase: z.string()');
244+
});
245+
226246
it('with enumsAsTypes', async () => {
227247
const schema = buildSchema(/* GraphQL */ `
228248
enum PageType {

0 commit comments

Comments
 (0)