2018-07-16 03:49:56 -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
|
|
|
|
*/
|
|
|
|
|
2018-07-30 13:06:51 -04:00
|
|
|
import {join} from 'path';
|
2018-07-16 03:49:56 -04:00
|
|
|
|
|
|
|
import {mainNgcc} from '../../src/ngcc/src/main';
|
|
|
|
|
|
|
|
import {TestSupport, isInBazel, setup} from '../test_support';
|
|
|
|
|
2018-08-09 08:54:20 -04:00
|
|
|
const OUTPUT_PATH = 'node_modules_ngtsc';
|
|
|
|
|
2018-07-16 03:49:56 -04:00
|
|
|
describe('ngcc behavioral tests', () => {
|
|
|
|
if (!isInBazel()) {
|
|
|
|
// These tests should be excluded from the non-Bazel build.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-07-30 13:06:51 -04:00
|
|
|
// Temporary local debugging aid. Set to `true` to turn on.
|
|
|
|
const preserveOutput = false;
|
|
|
|
const onSpecCompleted = (format: string) => {
|
|
|
|
if (preserveOutput) {
|
|
|
|
const {tmpdir} = require('os');
|
|
|
|
const {cp, mkdir, rm, set} = require('shelljs');
|
2018-07-16 03:49:56 -04:00
|
|
|
|
2018-07-30 13:06:51 -04:00
|
|
|
const tempRootDir = join(tmpdir(), 'ngcc-spec', format);
|
2018-08-09 08:54:20 -04:00
|
|
|
const outputDir = OUTPUT_PATH;
|
2018-07-16 03:49:56 -04:00
|
|
|
|
2018-07-30 13:06:51 -04:00
|
|
|
set('-e');
|
|
|
|
rm('-rf', tempRootDir);
|
|
|
|
mkdir('-p', tempRootDir);
|
|
|
|
cp('-R', join(support.basePath, outputDir), tempRootDir);
|
2018-07-16 03:49:56 -04:00
|
|
|
|
2018-07-30 13:06:51 -04:00
|
|
|
global.console.log(`Copied '${outputDir}' to '${tempRootDir}'.`);
|
|
|
|
}
|
|
|
|
};
|
2018-07-16 03:49:56 -04:00
|
|
|
|
2018-07-30 13:06:51 -04:00
|
|
|
let support: TestSupport;
|
|
|
|
beforeEach(() => support = setup());
|
2018-07-16 03:49:56 -04:00
|
|
|
|
2018-07-24 09:53:23 -04:00
|
|
|
it('should run ngcc without errors for fesm2015', () => {
|
2018-07-30 13:06:51 -04:00
|
|
|
const commonPath = join(support.basePath, 'node_modules/@angular/common');
|
|
|
|
const format = 'fesm2015';
|
2018-07-16 03:49:56 -04:00
|
|
|
|
2018-08-09 08:54:20 -04:00
|
|
|
expect(mainNgcc([format, commonPath, OUTPUT_PATH])).toBe(0);
|
2018-07-16 03:49:56 -04:00
|
|
|
|
2018-07-30 13:06:51 -04:00
|
|
|
onSpecCompleted(format);
|
2018-07-16 03:49:56 -04:00
|
|
|
});
|
2018-07-24 09:53:23 -04:00
|
|
|
|
2018-07-25 06:06:32 -04:00
|
|
|
it('should run ngcc without errors for fesm5', () => {
|
2018-07-30 13:06:51 -04:00
|
|
|
const commonPath = join(support.basePath, 'node_modules/@angular/common');
|
|
|
|
const format = 'fesm5';
|
2018-07-25 06:06:32 -04:00
|
|
|
|
2018-08-09 08:54:20 -04:00
|
|
|
expect(mainNgcc([format, commonPath, OUTPUT_PATH])).toBe(0);
|
2018-07-25 06:06:32 -04:00
|
|
|
|
2018-07-30 13:06:51 -04:00
|
|
|
onSpecCompleted(format);
|
2018-07-25 06:06:32 -04:00
|
|
|
});
|
|
|
|
|
2018-07-24 09:53:23 -04:00
|
|
|
it('should run ngcc without errors for esm2015', () => {
|
2018-07-30 13:06:51 -04:00
|
|
|
const commonPath = join(support.basePath, 'node_modules/@angular/common');
|
|
|
|
const format = 'esm2015';
|
2018-07-24 09:53:23 -04:00
|
|
|
|
2018-08-09 08:54:20 -04:00
|
|
|
expect(mainNgcc([format, commonPath, OUTPUT_PATH])).toBe(0);
|
2018-07-24 09:53:23 -04:00
|
|
|
|
2018-07-30 13:06:51 -04:00
|
|
|
onSpecCompleted(format);
|
2018-07-24 09:53:23 -04:00
|
|
|
});
|
2018-07-25 06:06:32 -04:00
|
|
|
|
|
|
|
it('should run ngcc without errors for esm5', () => {
|
2018-07-30 13:06:51 -04:00
|
|
|
const commonPath = join(support.basePath, 'node_modules/@angular/common');
|
|
|
|
const format = 'esm5';
|
2018-07-25 06:06:32 -04:00
|
|
|
|
2018-08-09 08:54:20 -04:00
|
|
|
expect(mainNgcc([format, commonPath, OUTPUT_PATH])).toBe(0);
|
2018-07-25 06:06:32 -04:00
|
|
|
|
2018-07-30 13:06:51 -04:00
|
|
|
onSpecCompleted(format);
|
2018-07-25 06:06:32 -04:00
|
|
|
});
|
2018-07-16 03:49:56 -04:00
|
|
|
});
|