@@ -57,6 +57,13 @@ describe('get codegen configuration', () => {
57
57
expect ( getConfigReturn . getGeneratedFragmentsPath ( ) ) . toEqual ( path . join ( 'src' , 'graphql' , 'fragments' ) ) ;
58
58
} ) ;
59
59
60
+ it ( 'returns correct maxDepth as a Number' , ( ) => {
61
+ fs . existsSync = jest . fn ( ) . mockReturnValue ( true ) ;
62
+ graphQLConfig . getGraphQLConfig = jest . fn ( ) . mockReturnValue ( MOCK_CODEGEN_CONFIG ) ;
63
+ const getConfigReturn = getCodegenConfig ( MOCK_PROJECT_ROOT ) ;
64
+ expect ( getConfigReturn . getQueryMaxDepth ( ) ) . toEqual ( 4 ) ;
65
+ } ) ;
66
+
60
67
it ( 'uses the includes property if the generated documents path does not exist' , ( ) => {
61
68
const configWithoutDocumentsPath = { ...MOCK_CODEGEN_CONFIG } ;
62
69
delete configWithoutDocumentsPath . config . extensions . amplify . docsFilePath ;
@@ -93,4 +100,13 @@ describe('get codegen configuration', () => {
93
100
const getConfigReturn = getCodegenConfig ( MOCK_PROJECT_ROOT ) ;
94
101
expect ( getConfigReturn . getGeneratedTypesPath ( ) ) . toBeUndefined ( ) ;
95
102
} ) ;
103
+
104
+ it ( 'returns undefined if maxDepth does not exist' , ( ) => {
105
+ const configWithoutMaxDepth = { ...MOCK_CODEGEN_CONFIG } ;
106
+ delete configWithoutMaxDepth . config . extensions . amplify . maxDepth ;
107
+ fs . existsSync = jest . fn ( ) . mockReturnValue ( true ) ;
108
+ graphQLConfig . getGraphQLConfig = jest . fn ( ) . mockReturnValue ( configWithoutMaxDepth ) ;
109
+ const getConfigReturn = getCodegenConfig ( MOCK_PROJECT_ROOT ) ;
110
+ expect ( getConfigReturn . getQueryMaxDepth ( ) ) . toBeUndefined ( ) ;
111
+ } ) ;
96
112
} ) ;
0 commit comments