77 GraphQLString ,
88} from 'graphql' ;
99import getSchemaFromData from './getSchemaFromData' ;
10+ import e from 'cors' ;
1011
1112const data = {
1213 posts : [
@@ -128,12 +129,10 @@ test('creates three query fields per data type', () => {
128129 const queries = getSchemaFromData ( data ) . getQueryType ( ) . getFields ( ) ;
129130 expect ( queries [ 'Post' ] . type . name ) . toEqual ( PostType . name ) ;
130131 expect ( queries [ 'Post' ] . args ) . toEqual ( [
131- {
132- defaultValue : undefined ,
133- description : null ,
132+ expect . objectContaining ( {
134133 name : 'id' ,
135134 type : new GraphQLNonNull ( GraphQLID ) ,
136- } ,
135+ } ) ,
137136 ] ) ;
138137 expect ( queries [ 'allPosts' ] . type . toString ( ) ) . toEqual ( '[Post]' ) ;
139138 expect ( queries [ 'allPosts' ] . args [ 0 ] . name ) . toEqual ( 'page' ) ;
@@ -150,12 +149,10 @@ test('creates three query fields per data type', () => {
150149
151150 expect ( queries [ 'User' ] . type . name ) . toEqual ( UserType . name ) ;
152151 expect ( queries [ 'User' ] . args ) . toEqual ( [
153- {
154- defaultValue : undefined ,
155- description : null ,
152+ expect . objectContaining ( {
156153 name : 'id' ,
157154 type : new GraphQLNonNull ( GraphQLID ) ,
158- } ,
155+ } ) ,
159156 ] ) ;
160157 expect ( queries [ 'allUsers' ] . type . toString ( ) ) . toEqual ( '[User]' ) ;
161158 expect ( queries [ 'allUsers' ] . args [ 0 ] . name ) . toEqual ( 'page' ) ;
@@ -175,93 +172,69 @@ test('creates three mutation fields per data type', () => {
175172 const mutations = getSchemaFromData ( data ) . getMutationType ( ) . getFields ( ) ;
176173 expect ( mutations [ 'createPost' ] . type . name ) . toEqual ( PostType . name ) ;
177174 expect ( mutations [ 'createPost' ] . args ) . toEqual ( [
178- {
175+ expect . objectContaining ( {
179176 name : 'title' ,
180177 type : new GraphQLNonNull ( GraphQLString ) ,
181- defaultValue : undefined ,
182- description : null ,
183- } ,
184- {
178+ } ) ,
179+ expect . objectContaining ( {
185180 name : 'views' ,
186181 type : new GraphQLNonNull ( GraphQLInt ) ,
187- defaultValue : undefined ,
188- description : null ,
189- } ,
190- {
182+ } ) ,
183+ expect . objectContaining ( {
191184 name : 'user_id' ,
192185 type : new GraphQLNonNull ( GraphQLID ) ,
193- defaultValue : undefined ,
194- description : null ,
195- } ,
186+ } ) ,
196187 ] ) ;
197188 expect ( mutations [ 'updatePost' ] . type . name ) . toEqual ( PostType . name ) ;
198189 expect ( mutations [ 'updatePost' ] . args ) . toEqual ( [
199- {
190+ expect . objectContaining ( {
200191 name : 'id' ,
201192 type : new GraphQLNonNull ( GraphQLID ) ,
202- defaultValue : undefined ,
203- description : null ,
204- } ,
205- {
193+ } ) ,
194+ expect . objectContaining ( {
206195 name : 'title' ,
207196 type : GraphQLString ,
208- defaultValue : undefined ,
209- description : null ,
210- } ,
211- {
197+ } ) ,
198+ expect . objectContaining ( {
212199 name : 'views' ,
213200 type : GraphQLInt ,
214- defaultValue : undefined ,
215- description : null ,
216- } ,
217- {
201+ } ) ,
202+ expect . objectContaining ( {
218203 name : 'user_id' ,
219204 type : GraphQLID ,
220- defaultValue : undefined ,
221- description : null ,
222- } ,
205+ } ) ,
223206 ] ) ;
224207 expect ( mutations [ 'removePost' ] . type . name ) . toEqual ( PostType . name ) ;
225208 expect ( mutations [ 'removePost' ] . args ) . toEqual ( [
226- {
209+ expect . objectContaining ( {
227210 name : 'id' ,
228211 type : new GraphQLNonNull ( GraphQLID ) ,
229- defaultValue : undefined ,
230- description : null ,
231- } ,
212+ } ) ,
232213 ] ) ;
233214 expect ( mutations [ 'createUser' ] . type . name ) . toEqual ( UserType . name ) ;
234215 expect ( mutations [ 'createUser' ] . args ) . toEqual ( [
235- {
216+ expect . objectContaining ( {
236217 name : 'name' ,
237218 type : new GraphQLNonNull ( GraphQLString ) ,
238- defaultValue : undefined ,
239- description : null ,
240- } ,
219+ } ) ,
241220 ] ) ;
242221 expect ( mutations [ 'updateUser' ] . type . name ) . toEqual ( UserType . name ) ;
243222 expect ( mutations [ 'updateUser' ] . args ) . toEqual ( [
244- {
223+ expect . objectContaining ( {
245224 name : 'id' ,
246225 type : new GraphQLNonNull ( GraphQLID ) ,
247- defaultValue : undefined ,
248- description : null ,
249- } ,
250- {
226+ } ) ,
227+ expect . objectContaining ( {
251228 name : 'name' ,
252229 type : GraphQLString ,
253- defaultValue : undefined ,
254- description : null ,
255- } ,
230+ } ) ,
256231 ] ) ;
257232 expect ( mutations [ 'removeUser' ] . type . name ) . toEqual ( UserType . name ) ;
258233 expect ( mutations [ 'removeUser' ] . args ) . toEqual ( [
259- {
260- defaultValue : undefined ,
261- description : null ,
234+ expect . objectContaining ( {
262235 name : 'id' ,
263236 type : new GraphQLNonNull ( GraphQLID ) ,
264- } ,
237+ } ) ,
265238 ] ) ;
266239} ) ;
267240
@@ -270,30 +243,18 @@ test('creates the mutation *Input type for createMany', () => {
270243 const createManyPostInputType = mutations [ 'createManyPost' ] . args [ 0 ] . type ;
271244 expect ( createManyPostInputType . toString ( ) ) . toEqual ( '[PostInput]' ) ;
272245 expect ( createManyPostInputType . ofType . getFields ( ) ) . toEqual ( {
273- title : {
246+ title : expect . objectContaining ( {
274247 type : new GraphQLNonNull ( GraphQLString ) ,
275248 name : 'title' ,
276- astNode : undefined ,
277- defaultValue : undefined ,
278- description : undefined ,
279- extensions : undefined ,
280- } ,
281- views : {
249+ } ) ,
250+ views : expect . objectContaining ( {
282251 type : new GraphQLNonNull ( GraphQLInt ) ,
283252 name : 'views' ,
284- astNode : undefined ,
285- defaultValue : undefined ,
286- description : undefined ,
287- extensions : undefined ,
288- } ,
289- user_id : {
253+ } ) ,
254+ user_id : expect . objectContaining ( {
290255 type : new GraphQLNonNull ( GraphQLID ) ,
291256 name : 'user_id' ,
292- astNode : undefined ,
293- defaultValue : undefined ,
294- description : undefined ,
295- extensions : undefined ,
296- } ,
257+ } ) ,
297258 } ) ;
298259} ) ;
299260
0 commit comments