@@ -6,14 +6,23 @@ import ts from 'typescript'
66import  {  writeConfigurationDefaults  }  from  './writeConfigurationDefaults' 
77
88describe ( 'writeConfigurationDefaults()' ,  ( )  =>  { 
9+   let  consoleLogSpy : jest . SpyInstance 
10+ 
11+   beforeEach ( ( )  =>  { 
12+     consoleLogSpy  =  jest . spyOn ( console ,  'log' ) . mockImplementation ( ) 
13+   } ) 
14+ 
15+   afterEach ( ( )  =>  { 
16+     consoleLogSpy . mockRestore ( ) 
17+   } ) 
18+ 
919  it ( 'applies suggested and mandatory defaults to existing tsconfig.json and logs them' ,  async  ( )  =>  { 
1020    const  tmpDir  =  await  mkdtemp ( join ( tmpdir ( ) ,  'nextjs-test-' ) ) 
1121    const  tsConfigPath  =  join ( tmpDir ,  'tsconfig.json' ) 
1222    const  isFirstTimeSetup  =  false 
1323    const  hasAppDir  =  true 
1424    const  distDir  =  '.next' 
1525    const  hasPagesDir  =  false 
16-     const  logSpy  =  jest . spyOn ( console ,  'log' ) 
1726
1827    await  writeFile ( tsConfigPath ,  JSON . stringify ( {  compilerOptions : { }  } ) ,  { 
1928      encoding : 'utf8' , 
@@ -69,7 +78,7 @@ describe('writeConfigurationDefaults()', () => {
6978    ` ) 
7079
7180    expect ( 
72-       logSpy . mock . calls 
81+       consoleLogSpy . mock . calls 
7382        . flat ( ) 
7483        . join ( '\n' ) 
7584        // eslint-disable-next-line no-control-regex 
@@ -120,4 +129,36 @@ describe('writeConfigurationDefaults()', () => {
120129      " 
121130    ` ) 
122131  } ) 
132+ 
133+   it ( 'does not warn about disabled strict mode if strict mode was already enabled' ,  async  ( )  =>  { 
134+     const  tmpDir  =  await  mkdtemp ( join ( tmpdir ( ) ,  'nextjs-test-' ) ) 
135+     const  tsConfigPath  =  join ( tmpDir ,  'tsconfig.json' ) 
136+     const  isFirstTimeSetup  =  false 
137+     const  hasAppDir  =  true 
138+     const  distDir  =  '.next' 
139+     const  hasPagesDir  =  false 
140+ 
141+     await  writeFile ( 
142+       tsConfigPath , 
143+       JSON . stringify ( {  compilerOptions : {  strict : true  }  } ) , 
144+       {  encoding : 'utf8'  } 
145+     ) 
146+ 
147+     await  writeConfigurationDefaults ( 
148+       ts , 
149+       tsConfigPath , 
150+       isFirstTimeSetup , 
151+       hasAppDir , 
152+       distDir , 
153+       hasPagesDir 
154+     ) 
155+ 
156+     expect ( 
157+       consoleLogSpy . mock . calls 
158+         . flat ( ) 
159+         . join ( '\n' ) 
160+         // eslint-disable-next-line no-control-regex 
161+         . replace ( / \x1B \[ \d + m / g,  '' )  // remove color control characters 
162+     ) . not . toMatch ( 'Strict-mode is set to false by default.' ) 
163+   } ) 
123164} ) 
0 commit comments