@@ -15,7 +15,7 @@ describe('myzod', () => {
15
15
}
16
16
` ,
17
17
[
18
- 'export const PrimitiveInputSchema: myzod.Type<PrimitiveInput>' ,
18
+ 'export function PrimitiveInputSchema() : myzod.Type<PrimitiveInput> { ' ,
19
19
'a: myzod.string()' ,
20
20
'b: myzod.string()' ,
21
21
'c: myzod.boolean()' ,
@@ -36,7 +36,7 @@ describe('myzod', () => {
36
36
}
37
37
` ,
38
38
[
39
- 'export const PrimitiveInputSchema: myzod.Type<PrimitiveInput>' ,
39
+ 'export function PrimitiveInputSchema() : myzod.Type<PrimitiveInput> { ' ,
40
40
// alphabet order
41
41
'a: myzod.string().optional().nullable(),' ,
42
42
'b: myzod.string().optional().nullable(),' ,
@@ -58,7 +58,7 @@ describe('myzod', () => {
58
58
}
59
59
` ,
60
60
[
61
- 'export const ArrayInputSchema: myzod.Type<ArrayInput>' ,
61
+ 'export function ArrayInputSchema() : myzod.Type<ArrayInput> { ' ,
62
62
'a: myzod.array(myzod.string().nullable()).optional().nullable(),' ,
63
63
'b: myzod.array(myzod.string()).optional().nullable(),' ,
64
64
'c: myzod.array(myzod.string()),' ,
@@ -81,11 +81,11 @@ describe('myzod', () => {
81
81
}
82
82
` ,
83
83
[
84
- 'export const AInputSchema: myzod.Type<AInput>' ,
84
+ 'export function AInputSchema() : myzod.Type<AInput> { ' ,
85
85
'b: myzod.lazy(() => BInputSchema())' ,
86
- 'export const BInputSchema: myzod.Type<BInput>' ,
86
+ 'export function BInputSchema() : myzod.Type<BInput> { ' ,
87
87
'c: myzod.lazy(() => CInputSchema())' ,
88
- 'export const CInputSchema: myzod.Type<CInput>' ,
88
+ 'export function CInputSchema() : myzod.Type<CInput> { ' ,
89
89
'a: myzod.lazy(() => AInputSchema())' ,
90
90
] ,
91
91
] ,
@@ -98,7 +98,7 @@ describe('myzod', () => {
98
98
}
99
99
` ,
100
100
[
101
- 'export const NestedInputSchema: myzod.Type<NestedInput>' ,
101
+ 'export function NestedInputSchema() : myzod.Type<NestedInput> { ' ,
102
102
'child: myzod.lazy(() => NestedInputSchema().optional().nullable()),' ,
103
103
'childrens: myzod.array(myzod.lazy(() => NestedInputSchema().nullable())).optional().nullable()' ,
104
104
] ,
@@ -116,7 +116,7 @@ describe('myzod', () => {
116
116
` ,
117
117
[
118
118
'export const PageTypeSchema = myzod.enum(PageType)' ,
119
- 'export const PageInputSchema: myzod.Type<PageInput>' ,
119
+ 'export function PageInputSchema() : myzod.Type<PageInput> { ' ,
120
120
'pageType: PageTypeSchema' ,
121
121
] ,
122
122
] ,
@@ -136,7 +136,7 @@ describe('myzod', () => {
136
136
scalar URL # unknown scalar, should be any (definedNonNullAnySchema)
137
137
` ,
138
138
[
139
- 'export const HttpInputSchema: myzod.Type<HttpInput>' ,
139
+ 'export function HttpInputSchema() : myzod.Type<HttpInput> { ' ,
140
140
'export const HttpMethodSchema = myzod.enum(HttpMethod)' ,
141
141
'method: HttpMethodSchema' ,
142
142
'url: definedNonNullAnySchema' ,
@@ -145,7 +145,7 @@ describe('myzod', () => {
145
145
] ) ( '%s' , async ( _ , textSchema , wantContains ) => {
146
146
const schema = buildSchema ( textSchema ) ;
147
147
const result = await plugin ( schema , [ ] , { schema : 'myzod' } , { } ) ;
148
- expect ( result . prepend ) . toContain ( "import myzod from 'myzod'" ) ;
148
+ expect ( result . prepend ) . toContain ( "import * as myzod from 'myzod'" ) ;
149
149
150
150
for ( const wantContain of wantContains ) {
151
151
expect ( result . content ) . toContain ( wantContain ) ;
@@ -236,7 +236,7 @@ describe('myzod', () => {
236
236
{ }
237
237
) ;
238
238
const wantContains = [
239
- 'export const PrimitiveInputSchema: myzod.Type<PrimitiveInput>' ,
239
+ 'export function PrimitiveInputSchema() : myzod.Type<PrimitiveInput> { ' ,
240
240
'a: myzod.string().min(1),' ,
241
241
'b: myzod.string().min(1),' ,
242
242
'c: myzod.boolean(),' ,
@@ -271,7 +271,7 @@ describe('myzod', () => {
271
271
{ }
272
272
) ;
273
273
const wantContains = [
274
- 'export const ScalarsInputSchema: myzod.Type<ScalarsInput>' ,
274
+ 'export function ScalarsInputSchema() : myzod.Type<ScalarsInput> { ' ,
275
275
'date: myzod.date(),' ,
276
276
'email: myzod.string()' , // TODO: Test implementation
277
277
'str: myzod.string()' ,
@@ -304,7 +304,7 @@ describe('myzod', () => {
304
304
{ }
305
305
) ;
306
306
const wantContains = [
307
- 'export const UserCreateInputSchema: myzod.Type<UserCreateInput>' ,
307
+ 'export function UserCreateInputSchema() : myzod.Type<UserCreateInput> { ' ,
308
308
'profile: myzod.string().min(1, "Please input more than 1").max(5000, "Please input less than 5000").optional().nullable()' ,
309
309
] ;
310
310
for ( const wantContain of wantContains ) {
@@ -334,7 +334,7 @@ describe('myzod', () => {
334
334
{ }
335
335
) ;
336
336
const wantContains = [
337
- 'export const UserCreateInputSchema: myzod.Type<UserCreateInput>' ,
337
+ 'export function UserCreateInputSchema() : myzod.Type<UserCreateInput> { ' ,
338
338
'profile: myzod.string().min(1, "Please input more than 1").max(5000, "Please input less than 5000")' ,
339
339
] ;
340
340
for ( const wantContain of wantContains ) {
@@ -364,7 +364,7 @@ describe('myzod', () => {
364
364
{ }
365
365
) ;
366
366
const wantContains = [
367
- 'export const UserCreateInputSchema: myzod.Type<UserCreateInput>' ,
367
+ 'export function UserCreateInputSchema() : myzod.Type<UserCreateInput> { ' ,
368
368
'profile: myzod.array(myzod.string().nullable()).min(1, "Please input more than 1").max(5000, "Please input less than 5000").optional().nullable()' ,
369
369
] ;
370
370
for ( const wantContain of wantContains ) {
0 commit comments