| 
									
										
										
										
											2016-10-23 22:37:15 +02:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @license | 
					
						
							|  |  |  |  * Copyright Google Inc. All Rights Reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * 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
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-24 10:53:48 -07:00
										 |  |  | import * as ts from 'typescript'; | 
					
						
							| 
									
										
										
										
											2017-01-24 09:05:34 -08:00
										 |  |  | import {Tsc} from '../src/tsc'; | 
					
						
							| 
									
										
										
										
											2017-01-24 22:51:14 +02:00
										 |  |  | import {VinylFile} from '../src/vinyl_file'; | 
					
						
							| 
									
										
										
										
											2016-05-24 10:53:48 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | describe('options parsing', () => { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-24 22:51:14 +02:00
										 |  |  |   const configData = `
 | 
					
						
							| 
									
										
										
										
											2016-05-24 10:53:48 -07:00
										 |  |  | { | 
					
						
							|  |  |  |     "angularCompilerOptions": { | 
					
						
							|  |  |  |         "googleClosureOutput": true | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     "compilerOptions": { | 
					
						
							|  |  |  |         "module": "commonjs", | 
					
						
							|  |  |  |         "outDir": "built" | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-01-24 22:51:14 +02:00
										 |  |  | }`;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   const tsc = new Tsc(() => configData, () => ['tsconfig.json']); | 
					
						
							|  |  |  |   const config = {path: 'basePath/tsconfig.json', contents: new Buffer(configData)}; | 
					
						
							| 
									
										
										
										
											2016-05-24 10:53:48 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   it('should combine all options into ngOptions', () => { | 
					
						
							| 
									
										
										
										
											2017-01-12 17:34:31 -08:00
										 |  |  |     const {parsed, ngOptions} = | 
					
						
							|  |  |  |         tsc.readConfiguration('projectDir', 'basePath', {target: ts.ScriptTarget.ES2015}); | 
					
						
							| 
									
										
										
										
											2016-05-24 10:53:48 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     expect(ngOptions).toEqual({ | 
					
						
							| 
									
										
										
										
											2016-05-26 10:45:37 -07:00
										 |  |  |       genDir: 'basePath', | 
					
						
							| 
									
										
										
										
											2016-05-24 10:53:48 -07:00
										 |  |  |       googleClosureOutput: true, | 
					
						
							|  |  |  |       module: ts.ModuleKind.CommonJS, | 
					
						
							|  |  |  |       outDir: 'basePath/built', | 
					
						
							| 
									
										
										
										
											2017-01-12 17:34:31 -08:00
										 |  |  |       configFilePath: undefined, | 
					
						
							|  |  |  |       target: ts.ScriptTarget.ES2015 | 
					
						
							| 
									
										
										
										
											2016-05-24 10:53:48 -07:00
										 |  |  |     }); | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2017-01-24 22:51:14 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   it('should combine all options into ngOptions from vinyl like object', () => { | 
					
						
							| 
									
										
										
										
											2017-01-24 09:05:34 -08:00
										 |  |  |     const {parsed, ngOptions} = tsc.readConfiguration(config as VinylFile, 'basePath'); | 
					
						
							| 
									
										
										
										
											2017-01-24 22:51:14 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     expect(ngOptions).toEqual({ | 
					
						
							|  |  |  |       genDir: 'basePath', | 
					
						
							|  |  |  |       googleClosureOutput: true, | 
					
						
							|  |  |  |       module: ts.ModuleKind.CommonJS, | 
					
						
							|  |  |  |       outDir: 'basePath/built', | 
					
						
							|  |  |  |       configFilePath: undefined | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2016-05-24 10:53:48 -07:00
										 |  |  | }); |