2018-02-13 14:26:06 -05: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-03-13 14:00:53 -04:00
|
|
|
import * as fs from 'fs';
|
2018-02-13 14:26:06 -05:00
|
|
|
import * as path from 'path';
|
|
|
|
import * as shx from 'shelljs';
|
|
|
|
|
|
|
|
shx.cd(path.join(process.env['TEST_SRCDIR'], 'angular', 'packages', 'common', 'npm_package'));
|
|
|
|
|
2018-03-13 14:00:53 -04:00
|
|
|
describe('@angular/common ng_package', () => {
|
2018-02-13 14:26:06 -05:00
|
|
|
it('should have right bundle files', () => {
|
|
|
|
expect(shx.ls('-R', 'bundles').stdout.split('\n').filter(n => !!n).sort()).toEqual([
|
|
|
|
'common-http-testing.umd.js',
|
|
|
|
'common-http-testing.umd.js.map',
|
|
|
|
'common-http-testing.umd.min.js',
|
|
|
|
'common-http-testing.umd.min.js.map',
|
|
|
|
'common-http.umd.js',
|
|
|
|
'common-http.umd.js.map',
|
|
|
|
'common-http.umd.min.js',
|
|
|
|
'common-http.umd.min.js.map',
|
|
|
|
'common-testing.umd.js',
|
|
|
|
'common-testing.umd.js.map',
|
|
|
|
'common-testing.umd.min.js',
|
|
|
|
'common-testing.umd.min.js.map',
|
|
|
|
'common.umd.js',
|
|
|
|
'common.umd.js.map',
|
|
|
|
'common.umd.min.js',
|
|
|
|
'common.umd.min.js.map',
|
|
|
|
]);
|
|
|
|
});
|
2018-03-20 12:58:05 -04:00
|
|
|
|
|
|
|
it('should have right fesm files', () => {
|
2018-02-13 14:26:06 -05:00
|
|
|
const expected = [
|
|
|
|
'common.js',
|
|
|
|
'common.js.map',
|
|
|
|
'http',
|
|
|
|
'http.js',
|
|
|
|
'http.js.map',
|
|
|
|
'http/testing.js',
|
|
|
|
'http/testing.js.map',
|
|
|
|
'testing.js',
|
|
|
|
'testing.js.map',
|
|
|
|
];
|
2018-03-20 12:58:05 -04:00
|
|
|
expect(shx.ls('-R', 'fesm5').stdout.split('\n').filter(n => !!n).sort()).toEqual(expected);
|
|
|
|
expect(shx.ls('-R', 'fesm2015').stdout.split('\n').filter(n => !!n).sort()).toEqual(expected);
|
2018-02-13 14:26:06 -05:00
|
|
|
});
|
2018-03-13 14:00:53 -04:00
|
|
|
describe('should have module resolution properties in the package.json file for', () => {
|
|
|
|
// https://github.com/angular/common-builds/blob/master/package.json
|
|
|
|
it('/', () => {
|
|
|
|
const actual = JSON.parse(fs.readFileSync('package.json', {encoding: 'utf-8'}));
|
|
|
|
expect(actual['main']).toEqual('./bundles/common.umd.js');
|
|
|
|
});
|
|
|
|
// https://github.com/angular/common-builds/blob/master/http/package.json
|
|
|
|
it('/http', () => {
|
|
|
|
const actual = JSON.parse(fs.readFileSync('http/package.json', {encoding: 'utf-8'}));
|
|
|
|
expect(actual['main']).toEqual('../bundles/common-http.umd.js');
|
2018-03-20 12:58:05 -04:00
|
|
|
expect(actual['es2015']).toEqual('../fesm2015/http.js');
|
|
|
|
expect(actual['module']).toEqual('../fesm5/http.js');
|
2018-03-13 14:00:53 -04:00
|
|
|
expect(actual['typings']).toEqual('./http.d.ts');
|
|
|
|
});
|
|
|
|
// https://github.com/angular/common-builds/blob/master/testing/package.json
|
|
|
|
it('/testing', () => {
|
|
|
|
const actual = JSON.parse(fs.readFileSync('testing/package.json', {encoding: 'utf-8'}));
|
|
|
|
expect(actual['main']).toEqual('../bundles/common-testing.umd.js');
|
|
|
|
});
|
|
|
|
// https://github.com/angular/common-builds/blob/master/http/testing/package.json
|
|
|
|
it('/http/testing', () => {
|
|
|
|
const actual = JSON.parse(fs.readFileSync('http/testing/package.json', {encoding: 'utf-8'}));
|
|
|
|
expect(actual['main']).toEqual('../../bundles/common-http-testing.umd.js');
|
2018-03-20 12:58:05 -04:00
|
|
|
expect(actual['es2015']).toEqual('../../fesm2015/http/testing.js');
|
|
|
|
expect(actual['module']).toEqual('../../fesm5/http/testing.js');
|
2018-03-13 14:00:53 -04:00
|
|
|
expect(actual['typings']).toEqual('./testing.d.ts');
|
|
|
|
});
|
|
|
|
});
|
2018-02-13 14:26:06 -05:00
|
|
|
});
|