@@ -57,6 +57,13 @@ describe('get codegen configuration', () => {
5757 expect ( getConfigReturn . getGeneratedFragmentsPath ( ) ) . toEqual ( path . join ( 'src' , 'graphql' , 'fragments' ) ) ;
5858 } ) ;
5959
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+
6067 it ( 'uses the includes property if the generated documents path does not exist' , ( ) => {
6168 const configWithoutDocumentsPath = { ...MOCK_CODEGEN_CONFIG } ;
6269 delete configWithoutDocumentsPath . config . extensions . amplify . docsFilePath ;
@@ -93,4 +100,13 @@ describe('get codegen configuration', () => {
93100 const getConfigReturn = getCodegenConfig ( MOCK_PROJECT_ROOT ) ;
94101 expect ( getConfigReturn . getGeneratedTypesPath ( ) ) . toBeUndefined ( ) ;
95102 } ) ;
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+ } ) ;
96112} ) ;
0 commit comments