build(aio): support overriding the Angular packages in examples with locally built ones
This commit is contained in:

committed by
Alex Rickabaugh

parent
ecff8e6c93
commit
c8c2ab012a
@ -12,6 +12,7 @@ describe('example-boilerplate tool', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
spyOn(exampleBoilerPlate, 'installNodeModules');
|
||||
spyOn(exampleBoilerPlate, 'overridePackage');
|
||||
spyOn(exampleBoilerPlate, 'getFoldersContaining').and.returnValue(exampleFolders);
|
||||
spyOn(fs, 'ensureSymlinkSync');
|
||||
spyOn(exampleBoilerPlate, 'copyFile');
|
||||
@ -23,6 +24,16 @@ describe('example-boilerplate tool', () => {
|
||||
expect(exampleBoilerPlate.installNodeModules).toHaveBeenCalledWith(path.resolve(__dirname, 'shared'));
|
||||
});
|
||||
|
||||
it('should override the Angular node_modules with the locally built Angular packages if `useLocal` is true', () => {
|
||||
const numberOfAngularPackages = 12;
|
||||
const numberOfAngularToolsPackages = 1;
|
||||
exampleBoilerPlate.add(true);
|
||||
expect(exampleBoilerPlate.overridePackage).toHaveBeenCalledTimes(numberOfAngularPackages + numberOfAngularToolsPackages);
|
||||
// for example
|
||||
expect(exampleBoilerPlate.overridePackage).toHaveBeenCalledWith(path.resolve(__dirname, '../../../dist/packages-dist'), 'core');
|
||||
expect(exampleBoilerPlate.overridePackage).toHaveBeenCalledWith(path.resolve(__dirname, '../../../dist/tools/@angular'), 'tsc-wrapped');
|
||||
});
|
||||
|
||||
it('should process all the example folders', () => {
|
||||
exampleBoilerPlate.add();
|
||||
expect(exampleBoilerPlate.getFoldersContaining).toHaveBeenCalledWith(path.resolve(__dirname, '../../content/examples'), 'example-config.json', 'node_modules');
|
||||
@ -76,6 +87,23 @@ describe('example-boilerplate tool', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('overridePackage', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(shelljs, 'rm');
|
||||
spyOn(fs, 'ensureSymlinkSync');
|
||||
});
|
||||
|
||||
it('should remove the original package from the shared node_modules folder', () => {
|
||||
exampleBoilerPlate.overridePackage('base/path', 'somePackage');
|
||||
expect(shelljs.rm).toHaveBeenCalledWith('-rf', path.resolve(__dirname, 'shared/node_modules/@angular/somePackage'));
|
||||
});
|
||||
|
||||
it('should symlink the source folder to the shared node_modules folder', () => {
|
||||
exampleBoilerPlate.overridePackage('base/path', 'somePackage');
|
||||
expect(fs.ensureSymlinkSync).toHaveBeenCalledWith(path.resolve('base/path/somePackage'), path.resolve(__dirname, 'shared/node_modules/@angular/somePackage'));
|
||||
});
|
||||
});
|
||||
|
||||
describe('getFoldersContaining', () => {
|
||||
it('should use glob.sync', () => {
|
||||
spyOn(glob, 'sync').and.returnValue(['a/b/config.json', 'c/d/config.json']);
|
||||
@ -112,4 +140,4 @@ describe('example-boilerplate tool', () => {
|
||||
expect(result).toEqual({});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user