@@ -6,12 +6,12 @@ import {
6
6
IntrospectionField ,
7
7
IntrospectionSchema ,
8
8
printSchema ,
9
- TypeKind
9
+ TypeKind ,
10
10
} from 'graphql' ;
11
11
import { GRAPHQL_SDL_FILE_HEADER } from '../../lib/graphql.constants' ;
12
12
import {
13
13
GraphQLSchemaBuilderModule ,
14
- GraphQLSchemaFactory
14
+ GraphQLSchemaFactory ,
15
15
} from '../../lib/schema-builder' ;
16
16
import { DirectionsResolver } from '../code-first/directions/directions.resolver' ;
17
17
import { AbstractResolver } from '../code-first/other/abstract.resolver' ;
@@ -25,9 +25,10 @@ import {
25
25
getQuery ,
26
26
getQueryByName ,
27
27
getSubscription ,
28
- getSubscriptionByName
28
+ getSubscriptionByName ,
29
29
} from '../utils/introspection-schema.utils' ;
30
30
import { printedSchemaSnapshot } from '../utils/printed-schema.snapshot' ;
31
+ import { CatsResolver } from '../code-first/cats/cats.resolver' ;
31
32
32
33
describe ( 'Code-first - schema factory' , ( ) => {
33
34
let schemaFactory : GraphQLSchemaFactory ;
@@ -49,6 +50,7 @@ describe('Code-first - schema factory', () => {
49
50
[
50
51
RecipesResolver ,
51
52
DirectionsResolver ,
53
+ CatsResolver ,
52
54
AbstractResolver ,
53
55
IRecipesResolver ,
54
56
] ,
@@ -66,17 +68,18 @@ describe('Code-first - schema factory', () => {
66
68
printedSchemaSnapshot ,
67
69
) ;
68
70
} ) ;
69
- it ( 'should define 5 queries' , async ( ) => {
71
+ it ( 'should define 6 queries' , async ( ) => {
70
72
const type = getQuery ( introspectionSchema ) ;
71
73
72
- expect ( type . fields . length ) . toEqual ( 5 ) ;
74
+ expect ( type . fields . length ) . toEqual ( 6 ) ;
73
75
expect ( type . fields . map ( ( item ) => item . name ) ) . toEqual (
74
76
expect . arrayContaining ( [
75
77
'recipes' ,
76
78
'search' ,
77
79
'categories' ,
78
80
'move' ,
79
81
'recipe' ,
82
+ 'catType' ,
80
83
] ) ,
81
84
) ;
82
85
} ) ;
@@ -152,6 +155,40 @@ describe('Code-first - schema factory', () => {
152
155
) ;
153
156
} ) ;
154
157
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
+
155
192
it ( 'should define "SearchResultUnion" union' , ( ) => {
156
193
const type = introspectionSchema . types . find (
157
194
( { name } ) => name === 'SearchResultUnion' ,
0 commit comments