@@ -320,6 +320,7 @@ describe('zod', () => {
320320 expect ( result . prepend ) . toContain ( "import { SayI } from './types'" ) ;
321321 expect ( result . content ) . toContain ( 'export function SayISchema(): z.ZodObject<Properties<SayI>> {' ) ;
322322 } ) ;
323+
323324 describe ( 'issues #19' , ( ) => {
324325 it ( 'string field' , async ( ) => {
325326 const schema = buildSchema ( /* GraphQL */ `
@@ -351,6 +352,7 @@ describe('zod', () => {
351352 expect ( result . content ) . toContain ( wantContain ) ;
352353 }
353354 } ) ;
355+
354356 it ( 'not null field' , async ( ) => {
355357 const schema = buildSchema ( /* GraphQL */ `
356358 input UserCreateInput {
@@ -381,6 +383,7 @@ describe('zod', () => {
381383 expect ( result . content ) . toContain ( wantContain ) ;
382384 }
383385 } ) ;
386+
384387 it ( 'list field' , async ( ) => {
385388 const schema = buildSchema ( /* GraphQL */ `
386389 input UserCreateInput {
@@ -412,6 +415,7 @@ describe('zod', () => {
412415 }
413416 } ) ;
414417 } ) ;
418+
415419 describe ( 'PR #112' , ( ) => {
416420 it ( 'with notAllowEmptyString' , async ( ) => {
417421 const schema = buildSchema ( /* GraphQL */ `
@@ -476,6 +480,7 @@ describe('zod', () => {
476480 }
477481 } ) ;
478482 } ) ;
483+
479484 describe ( 'with withObjectType' , ( ) => {
480485 const schema = buildSchema ( /* GraphQL */ `
481486 input ScalarsInput {
@@ -732,6 +737,41 @@ describe('zod', () => {
732737 expect ( result . content ) . toContain ( wantContain ) ;
733738 }
734739 } ) ;
740+
741+ it ( 'generate enum union types' , async ( ) => {
742+ const schema = buildSchema ( /* GraphQL */ `
743+ enum PageType {
744+ PUBLIC
745+ BASIC_AUTH
746+ }
747+
748+ enum MethodType {
749+ GET
750+ POST
751+ }
752+
753+ union AnyType = PageType | MethodType
754+ ` ) ;
755+
756+ const result = await plugin (
757+ schema ,
758+ [ ] ,
759+ {
760+ schema : 'zod' ,
761+ withObjectType : true ,
762+ } ,
763+ { }
764+ ) ;
765+
766+ const wantContains = [
767+ 'export function AnyTypeSchema() {' ,
768+ 'return z.union([PageTypeSchema, MethodTypeSchema])' ,
769+ '}' ,
770+ ] ;
771+ for ( const wantContain of wantContains ) {
772+ expect ( result . content ) . toContain ( wantContain ) ;
773+ }
774+ } ) ;
735775 } ) ;
736776
737777 it ( 'properly generates custom directive values' , async ( ) => {
0 commit comments