@@ -6,12 +6,12 @@ import {
66 IntrospectionField ,
77 IntrospectionSchema ,
88 printSchema ,
9- TypeKind
9+ TypeKind ,
1010} from 'graphql' ;
1111import { GRAPHQL_SDL_FILE_HEADER } from '../../lib/graphql.constants' ;
1212import {
1313 GraphQLSchemaBuilderModule ,
14- GraphQLSchemaFactory
14+ GraphQLSchemaFactory ,
1515} from '../../lib/schema-builder' ;
1616import { DirectionsResolver } from '../code-first/directions/directions.resolver' ;
1717import { AbstractResolver } from '../code-first/other/abstract.resolver' ;
@@ -25,9 +25,10 @@ import {
2525 getQuery ,
2626 getQueryByName ,
2727 getSubscription ,
28- getSubscriptionByName
28+ getSubscriptionByName ,
2929} from '../utils/introspection-schema.utils' ;
3030import { printedSchemaSnapshot } from '../utils/printed-schema.snapshot' ;
31+ import { CatsResolver } from '../code-first/cats/cats.resolver' ;
3132
3233describe ( 'Code-first - schema factory' , ( ) => {
3334 let schemaFactory : GraphQLSchemaFactory ;
@@ -49,6 +50,7 @@ describe('Code-first - schema factory', () => {
4950 [
5051 RecipesResolver ,
5152 DirectionsResolver ,
53+ CatsResolver ,
5254 AbstractResolver ,
5355 IRecipesResolver ,
5456 ] ,
@@ -66,17 +68,18 @@ describe('Code-first - schema factory', () => {
6668 printedSchemaSnapshot ,
6769 ) ;
6870 } ) ;
69- it ( 'should define 5 queries' , async ( ) => {
71+ it ( 'should define 6 queries' , async ( ) => {
7072 const type = getQuery ( introspectionSchema ) ;
7173
72- expect ( type . fields . length ) . toEqual ( 5 ) ;
74+ expect ( type . fields . length ) . toEqual ( 6 ) ;
7375 expect ( type . fields . map ( ( item ) => item . name ) ) . toEqual (
7476 expect . arrayContaining ( [
7577 'recipes' ,
7678 'search' ,
7779 'categories' ,
7880 'move' ,
7981 'recipe' ,
82+ 'catType' ,
8083 ] ) ,
8184 ) ;
8285 } ) ;
@@ -152,6 +155,40 @@ describe('Code-first - schema factory', () => {
152155 ) ;
153156 } ) ;
154157
158+ it ( 'should define "CatType" enum to use CAPITALIZED_UNDERSCORE' , ( ) => {
159+ const type = introspectionSchema . types . find (
160+ ( { name } ) => name === 'CatType' ,
161+ ) ;
162+
163+ expect ( type ) . toEqual (
164+ expect . objectContaining ( {
165+ kind : TypeKind . ENUM ,
166+ name : 'CatType' ,
167+ description : 'Distinguish cats' ,
168+ enumValues : [
169+ {
170+ deprecationReason : null ,
171+ description : null ,
172+ isDeprecated : false ,
173+ name : 'PERSIAN_CAT' ,
174+ } ,
175+ {
176+ deprecationReason : null ,
177+ description : null ,
178+ isDeprecated : false ,
179+ name : 'MAINE_COON' ,
180+ } ,
181+ {
182+ deprecationReason : null ,
183+ description : null ,
184+ isDeprecated : false ,
185+ name : 'RAGDOLL' ,
186+ } ,
187+ ] ,
188+ } ) ,
189+ ) ;
190+ } ) ;
191+
155192 it ( 'should define "SearchResultUnion" union' , ( ) => {
156193 const type = introspectionSchema . types . find (
157194 ( { name } ) => name === 'SearchResultUnion' ,
0 commit comments