| 
									
										
										
										
											2018-09-11 09:38:28 +02:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @license | 
					
						
							| 
									
										
										
										
											2020-05-19 12:08:49 -07:00
										 |  |  |  * Copyright Google LLC All Rights Reserved. | 
					
						
							| 
									
										
										
										
											2018-09-11 09:38:28 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Use of this source code is governed by an MIT-style license that can be | 
					
						
							|  |  |  |  * found in the LICENSE file at https://angular.io/license
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import * as path from 'path'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import {readConfiguration} from '../src/perform_compile'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-07 12:43:43 -07:00
										 |  |  | import {setup, TestSupport} from './test_support'; | 
					
						
							| 
									
										
										
										
											2018-09-11 09:38:28 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | describe('perform_compile', () => { | 
					
						
							|  |  |  |   let support: TestSupport; | 
					
						
							|  |  |  |   let basePath: string; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   beforeEach(() => { | 
					
						
							|  |  |  |     support = setup(); | 
					
						
							|  |  |  |     basePath = support.basePath; | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   function writeSomeConfigs() { | 
					
						
							|  |  |  |     support.writeFiles({ | 
					
						
							|  |  |  |       'tsconfig-level-1.json': `{
 | 
					
						
							|  |  |  |           "extends": "./tsconfig-level-2.json", | 
					
						
							|  |  |  |           "angularCompilerOptions": { | 
					
						
							|  |  |  |             "annotateForClosureCompiler": true | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       `,
 | 
					
						
							|  |  |  |       'tsconfig-level-2.json': `{
 | 
					
						
							|  |  |  |           "extends": "./tsconfig-level-3.json", | 
					
						
							|  |  |  |           "angularCompilerOptions": { | 
					
						
							|  |  |  |             "skipMetadataEmit": true | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       `,
 | 
					
						
							|  |  |  |       'tsconfig-level-3.json': `{
 | 
					
						
							|  |  |  |           "angularCompilerOptions": { | 
					
						
							|  |  |  |             "annotateForClosureCompiler": false, | 
					
						
							|  |  |  |             "annotationsAs": "decorators" | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       `,
 | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it('should merge tsconfig "angularCompilerOptions"', () => { | 
					
						
							|  |  |  |     writeSomeConfigs(); | 
					
						
							|  |  |  |     const {options} = readConfiguration(path.resolve(basePath, 'tsconfig-level-1.json')); | 
					
						
							|  |  |  |     expect(options.annotateForClosureCompiler).toBe(true); | 
					
						
							|  |  |  |     expect(options.annotationsAs).toBe('decorators'); | 
					
						
							|  |  |  |     expect(options.skipMetadataEmit).toBe(true); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-21 08:46:40 +02:00
										 |  |  |   it(`should return 'enableIvy: true' when enableIvy is not defined in "angularCompilerOptions"`, | 
					
						
							|  |  |  |      () => { | 
					
						
							|  |  |  |        writeSomeConfigs(); | 
					
						
							|  |  |  |        const {options} = readConfiguration(path.resolve(basePath, 'tsconfig-level-1.json')); | 
					
						
							|  |  |  |        expect(options.enableIvy).toBe(true); | 
					
						
							|  |  |  |      }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it(`should return 'enableIvy: false' when enableIvy is disabled in "angularCompilerOptions"`, | 
					
						
							|  |  |  |      () => { | 
					
						
							|  |  |  |        writeSomeConfigs(); | 
					
						
							|  |  |  |        support.writeFiles({ | 
					
						
							|  |  |  |          'tsconfig-level-3.json': `{
 | 
					
						
							|  |  |  |           "angularCompilerOptions": { | 
					
						
							|  |  |  |             "enableIvy": false | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       `,
 | 
					
						
							|  |  |  |        }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |        const {options} = readConfiguration(path.resolve(basePath, 'tsconfig-level-1.json')); | 
					
						
							|  |  |  |        expect(options.enableIvy).toBe(false); | 
					
						
							|  |  |  |      }); | 
					
						
							| 
									
										
										
										
											2018-09-11 09:38:28 +02:00
										 |  |  | }); |