11/* eslint-disable no-unused-expressions, no-template-curly-in-string */
22
3- import { GraphQLString , GraphQLFloat , GraphQLBoolean , GraphQLList , GraphQLEnumType , GraphQLSchema , GraphQLObjectType , graphql } from 'graphql' ;
43import {
5- GraphQLDate ,
6- GraphQLBuffer ,
7- GraphQLGeneric ,
8- GraphQLJSON ,
9- } from 'graphql-compose' ;
4+ GraphQLString ,
5+ GraphQLFloat ,
6+ GraphQLBoolean ,
7+ GraphQLList ,
8+ GraphQLEnumType ,
9+ GraphQLSchema ,
10+ GraphQLObjectType ,
11+ graphql ,
12+ } from 'graphql' ;
13+ import { GraphQLDate , GraphQLBuffer , GraphQLGeneric , GraphQLJSON } from 'graphql-compose' ;
1014import { UserModel } from '../__mocks__/userModel' ;
1115import {
1216 deriveComplexType ,
@@ -39,19 +43,33 @@ describe('fieldConverter', () => {
3943 } ) ;
4044
4145 it ( 'should throw Exception, if model does `schema.path` property' , ( ) => {
42- expect ( ( ) => { getFieldsFromModel ( { a : 1 } ) ; } ) . toThrowError ( / i n c o r r e c t m o n g o o s e m o d e l / ) ;
43- expect ( ( ) => { getFieldsFromModel ( { schema : { } } ) ; } ) . toThrowError ( / i n c o r r e c t m o n g o o s e m o d e l / ) ;
46+ expect ( ( ) => {
47+ getFieldsFromModel ( { a : 1 } ) ;
48+ } ) . toThrowError ( / i n c o r r e c t m o n g o o s e m o d e l / ) ;
49+ expect ( ( ) => {
50+ getFieldsFromModel ( { schema : { } } ) ;
51+ } ) . toThrowError ( / i n c o r r e c t m o n g o o s e m o d e l / ) ;
4452 } ) ;
4553 } ) ;
4654
4755 describe ( 'deriveComplexType()' , ( ) => {
4856 it ( 'should throw error on incorrect mongoose field' , ( ) => {
4957 const err = / i n c o r r e c t m o n g o o s e f i e l d / ;
50- expect ( ( ) => { deriveComplexType ( ) ; } ) . toThrowError ( err ) ;
51- expect ( ( ) => { deriveComplexType ( 123 ) ; } ) . toThrowError ( err ) ;
52- expect ( ( ) => { deriveComplexType ( { a : 1 } ) ; } ) . toThrowError ( err ) ;
53- expect ( ( ) => { deriveComplexType ( { path : 'name' } ) ; } ) . toThrowError ( err ) ;
54- expect ( ( ) => { deriveComplexType ( { path : 'name' , instance : 'Abc' } ) ; } ) . not . toThrowError ( err ) ;
58+ expect ( ( ) => {
59+ deriveComplexType ( ) ;
60+ } ) . toThrowError ( err ) ;
61+ expect ( ( ) => {
62+ deriveComplexType ( 123 ) ;
63+ } ) . toThrowError ( err ) ;
64+ expect ( ( ) => {
65+ deriveComplexType ( { a : 1 } ) ;
66+ } ) . toThrowError ( err ) ;
67+ expect ( ( ) => {
68+ deriveComplexType ( { path : 'name' } ) ;
69+ } ) . toThrowError ( err ) ;
70+ expect ( ( ) => {
71+ deriveComplexType ( { path : 'name' , instance : 'Abc' } ) ;
72+ } ) . not . toThrowError ( err ) ;
5573 } ) ;
5674
5775 it ( 'should derive DOCUMENT_ARRAY' , ( ) => {
@@ -174,12 +192,13 @@ describe('fieldConverter', () => {
174192 } ) ,
175193 } ) ;
176194
177-
178195 const user = new UserModel ( {
179196 name : 'Test empty subDoc' ,
180197 } ) ;
181198 await user . save ( ) ;
182- const result = await graphql ( schema , `{
199+ const result = await graphql (
200+ schema ,
201+ `{
183202 user(_id: "${ user . _id } ") {
184203 name
185204 subDoc {
@@ -189,7 +208,8 @@ describe('fieldConverter', () => {
189208 }
190209 }
191210 }
192- }` ) ;
211+ }`
212+ ) ;
193213 expect ( result . data . user ) . toEqual ( {
194214 name : 'Test empty subDoc' ,
195215 subDoc : null ,
@@ -218,7 +238,9 @@ describe('fieldConverter', () => {
218238 subDoc : { field2 : { field21 : 'ok' } } ,
219239 } ) ;
220240 await user2 . save ( ) ;
221- const result2 = await graphql ( schema , `{
241+ const result2 = await graphql (
242+ schema ,
243+ `{
222244 user(_id: "${ user2 . _id } ") {
223245 name
224246 subDoc {
@@ -228,7 +250,8 @@ describe('fieldConverter', () => {
228250 }
229251 }
230252 }
231- }` ) ;
253+ }`
254+ ) ;
232255 expect ( result2 . data . user ) . toEqual ( {
233256 name : 'Test non empty subDoc' ,
234257 subDoc : {
0 commit comments