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