@@ -313,7 +313,7 @@ describe('yup', () => {
313313 expect ( result . prepend ) . toContain ( "import { SayI } from './types'" ) ;
314314 expect ( result . content ) . toContain ( 'export function SayISchema(): yup.SchemaOf<SayI> {' ) ;
315315 } ) ;
316- describe ( 'GraphQl Type Support ' , ( ) => {
316+ describe ( 'with withObjectType ' , ( ) => {
317317 const schema = buildSchema ( /* GraphQL */ `
318318 input ScalarsInput {
319319 date: Date!
@@ -333,9 +333,21 @@ describe('yup', () => {
333333 isMember: Boolean
334334 createdAt: Date!
335335 }
336+
337+ type Mutation {
338+ _empty: String
339+ }
340+
341+ type Query {
342+ _empty: String
343+ }
344+
345+ type Subscription {
346+ _empty: String
347+ }
336348 ` ) ;
337349
338- it ( 'not generate if useObjectTypes false' , async ( ) => {
350+ it ( 'not generate if withObjectType false' , async ( ) => {
339351 const result = await plugin (
340352 schema ,
341353 [ ] ,
@@ -347,13 +359,13 @@ describe('yup', () => {
347359 expect ( result . content ) . not . toContain ( 'export function UserSchema(): yup.SchemaOf<User> {' ) ;
348360 } ) ;
349361
350- it ( 'generate both input & type if useObjectTypes true' , async ( ) => {
362+ it ( 'generate both input & type if withObjectType true' , async ( ) => {
351363 const result = await plugin (
352364 schema ,
353365 [ ] ,
354366 {
355367 schema : 'yup' ,
356- useObjectTypes : true ,
368+ withObjectType : true ,
357369 scalarSchemas : {
358370 Date : 'yup.date()' ,
359371 Email : 'yup.string().email()' ,
@@ -365,25 +377,29 @@ describe('yup', () => {
365377 // ScalarsInput
366378 'export function ScalarsInputSchema(): yup.SchemaOf<ScalarsInput> {' ,
367379 'return yup.object({' ,
368- 'date: yup.date().defined()' ,
380+ 'date: yup.date().defined(), ' ,
369381 'email: yup.string().email()' ,
370382 // User Create Input
371383 'export function UserCreateInputSchema(): yup.SchemaOf<UserCreateInput> {' ,
372- 'name: yup.string().defined()' ,
384+ 'name: yup.string().defined(), ' ,
373385 'email: yup.string().email().defined()' ,
374386 // User
375387 'export function UserSchema(): yup.SchemaOf<User> {' ,
376- "__typename: yup.mixed().oneOf(['User', undefined])" ,
377- 'id: yup.string().defined()' ,
378- 'name: yup.string()' ,
379- 'age: yup.number()' ,
380- 'isMember: yup.boolean()' ,
381- 'email: yup.string().email()' ,
388+ "__typename: yup.mixed().oneOf(['User', undefined]), " ,
389+ 'id: yup.string().defined(), ' ,
390+ 'name: yup.string(), ' ,
391+ 'age: yup.number(), ' ,
392+ 'isMember: yup.boolean(), ' ,
393+ 'email: yup.string().email(), ' ,
382394 'createdAt: yup.date().defined()' ,
383395 ] ;
384396 for ( const wantContain of wantContains ) {
385397 expect ( result . content ) . toContain ( wantContain ) ;
386398 }
399+
400+ for ( const wantNotContain of [ 'Query' , 'Mutation' , 'Subscription' ] ) {
401+ expect ( result . content ) . not . toContain ( wantNotContain ) ;
402+ }
387403 } ) ;
388404 } ) ;
389405} ) ;
0 commit comments