7
7
GraphQLString ,
8
8
} from 'graphql' ;
9
9
import getSchemaFromData from './getSchemaFromData' ;
10
+ import e from 'cors' ;
10
11
11
12
const data = {
12
13
posts : [
@@ -128,12 +129,10 @@ test('creates three query fields per data type', () => {
128
129
const queries = getSchemaFromData ( data ) . getQueryType ( ) . getFields ( ) ;
129
130
expect ( queries [ 'Post' ] . type . name ) . toEqual ( PostType . name ) ;
130
131
expect ( queries [ 'Post' ] . args ) . toEqual ( [
131
- {
132
- defaultValue : undefined ,
133
- description : null ,
132
+ expect . objectContaining ( {
134
133
name : 'id' ,
135
134
type : new GraphQLNonNull ( GraphQLID ) ,
136
- } ,
135
+ } ) ,
137
136
] ) ;
138
137
expect ( queries [ 'allPosts' ] . type . toString ( ) ) . toEqual ( '[Post]' ) ;
139
138
expect ( queries [ 'allPosts' ] . args [ 0 ] . name ) . toEqual ( 'page' ) ;
@@ -150,12 +149,10 @@ test('creates three query fields per data type', () => {
150
149
151
150
expect ( queries [ 'User' ] . type . name ) . toEqual ( UserType . name ) ;
152
151
expect ( queries [ 'User' ] . args ) . toEqual ( [
153
- {
154
- defaultValue : undefined ,
155
- description : null ,
152
+ expect . objectContaining ( {
156
153
name : 'id' ,
157
154
type : new GraphQLNonNull ( GraphQLID ) ,
158
- } ,
155
+ } ) ,
159
156
] ) ;
160
157
expect ( queries [ 'allUsers' ] . type . toString ( ) ) . toEqual ( '[User]' ) ;
161
158
expect ( queries [ 'allUsers' ] . args [ 0 ] . name ) . toEqual ( 'page' ) ;
@@ -175,93 +172,69 @@ test('creates three mutation fields per data type', () => {
175
172
const mutations = getSchemaFromData ( data ) . getMutationType ( ) . getFields ( ) ;
176
173
expect ( mutations [ 'createPost' ] . type . name ) . toEqual ( PostType . name ) ;
177
174
expect ( mutations [ 'createPost' ] . args ) . toEqual ( [
178
- {
175
+ expect . objectContaining ( {
179
176
name : 'title' ,
180
177
type : new GraphQLNonNull ( GraphQLString ) ,
181
- defaultValue : undefined ,
182
- description : null ,
183
- } ,
184
- {
178
+ } ) ,
179
+ expect . objectContaining ( {
185
180
name : 'views' ,
186
181
type : new GraphQLNonNull ( GraphQLInt ) ,
187
- defaultValue : undefined ,
188
- description : null ,
189
- } ,
190
- {
182
+ } ) ,
183
+ expect . objectContaining ( {
191
184
name : 'user_id' ,
192
185
type : new GraphQLNonNull ( GraphQLID ) ,
193
- defaultValue : undefined ,
194
- description : null ,
195
- } ,
186
+ } ) ,
196
187
] ) ;
197
188
expect ( mutations [ 'updatePost' ] . type . name ) . toEqual ( PostType . name ) ;
198
189
expect ( mutations [ 'updatePost' ] . args ) . toEqual ( [
199
- {
190
+ expect . objectContaining ( {
200
191
name : 'id' ,
201
192
type : new GraphQLNonNull ( GraphQLID ) ,
202
- defaultValue : undefined ,
203
- description : null ,
204
- } ,
205
- {
193
+ } ) ,
194
+ expect . objectContaining ( {
206
195
name : 'title' ,
207
196
type : GraphQLString ,
208
- defaultValue : undefined ,
209
- description : null ,
210
- } ,
211
- {
197
+ } ) ,
198
+ expect . objectContaining ( {
212
199
name : 'views' ,
213
200
type : GraphQLInt ,
214
- defaultValue : undefined ,
215
- description : null ,
216
- } ,
217
- {
201
+ } ) ,
202
+ expect . objectContaining ( {
218
203
name : 'user_id' ,
219
204
type : GraphQLID ,
220
- defaultValue : undefined ,
221
- description : null ,
222
- } ,
205
+ } ) ,
223
206
] ) ;
224
207
expect ( mutations [ 'removePost' ] . type . name ) . toEqual ( PostType . name ) ;
225
208
expect ( mutations [ 'removePost' ] . args ) . toEqual ( [
226
- {
209
+ expect . objectContaining ( {
227
210
name : 'id' ,
228
211
type : new GraphQLNonNull ( GraphQLID ) ,
229
- defaultValue : undefined ,
230
- description : null ,
231
- } ,
212
+ } ) ,
232
213
] ) ;
233
214
expect ( mutations [ 'createUser' ] . type . name ) . toEqual ( UserType . name ) ;
234
215
expect ( mutations [ 'createUser' ] . args ) . toEqual ( [
235
- {
216
+ expect . objectContaining ( {
236
217
name : 'name' ,
237
218
type : new GraphQLNonNull ( GraphQLString ) ,
238
- defaultValue : undefined ,
239
- description : null ,
240
- } ,
219
+ } ) ,
241
220
] ) ;
242
221
expect ( mutations [ 'updateUser' ] . type . name ) . toEqual ( UserType . name ) ;
243
222
expect ( mutations [ 'updateUser' ] . args ) . toEqual ( [
244
- {
223
+ expect . objectContaining ( {
245
224
name : 'id' ,
246
225
type : new GraphQLNonNull ( GraphQLID ) ,
247
- defaultValue : undefined ,
248
- description : null ,
249
- } ,
250
- {
226
+ } ) ,
227
+ expect . objectContaining ( {
251
228
name : 'name' ,
252
229
type : GraphQLString ,
253
- defaultValue : undefined ,
254
- description : null ,
255
- } ,
230
+ } ) ,
256
231
] ) ;
257
232
expect ( mutations [ 'removeUser' ] . type . name ) . toEqual ( UserType . name ) ;
258
233
expect ( mutations [ 'removeUser' ] . args ) . toEqual ( [
259
- {
260
- defaultValue : undefined ,
261
- description : null ,
234
+ expect . objectContaining ( {
262
235
name : 'id' ,
263
236
type : new GraphQLNonNull ( GraphQLID ) ,
264
- } ,
237
+ } ) ,
265
238
] ) ;
266
239
} ) ;
267
240
@@ -270,30 +243,18 @@ test('creates the mutation *Input type for createMany', () => {
270
243
const createManyPostInputType = mutations [ 'createManyPost' ] . args [ 0 ] . type ;
271
244
expect ( createManyPostInputType . toString ( ) ) . toEqual ( '[PostInput]' ) ;
272
245
expect ( createManyPostInputType . ofType . getFields ( ) ) . toEqual ( {
273
- title : {
246
+ title : expect . objectContaining ( {
274
247
type : new GraphQLNonNull ( GraphQLString ) ,
275
248
name : 'title' ,
276
- astNode : undefined ,
277
- defaultValue : undefined ,
278
- description : undefined ,
279
- extensions : undefined ,
280
- } ,
281
- views : {
249
+ } ) ,
250
+ views : expect . objectContaining ( {
282
251
type : new GraphQLNonNull ( GraphQLInt ) ,
283
252
name : 'views' ,
284
- astNode : undefined ,
285
- defaultValue : undefined ,
286
- description : undefined ,
287
- extensions : undefined ,
288
- } ,
289
- user_id : {
253
+ } ) ,
254
+ user_id : expect . objectContaining ( {
290
255
type : new GraphQLNonNull ( GraphQLID ) ,
291
256
name : 'user_id' ,
292
- astNode : undefined ,
293
- defaultValue : undefined ,
294
- description : undefined ,
295
- extensions : undefined ,
296
- } ,
257
+ } ) ,
297
258
} ) ;
298
259
} ) ;
299
260
0 commit comments