build(aio): refactor dgeni packages
This is to tidy up the `author-packagse`, which currently duplicates a lot of the configuration in the main packages. We need to DRY this up so that we don't fall foul of a change in one being missed in the other.
This commit is contained in:

committed by
Pete Bacon Darwin

parent
7a8bd99ab1
commit
3cad5da5a4
12
aio/tools/transforms/angular-content-package/processors/copyContentAssets.js
vendored
Normal file
12
aio/tools/transforms/angular-content-package/processors/copyContentAssets.js
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
module.exports = function copyContentAssetsProcessor(copyFolder) {
|
||||
return {
|
||||
$runAfter: ['files-written'],
|
||||
assetMappings: [],
|
||||
$process() {
|
||||
this.assetMappings.forEach(map => {
|
||||
copyFolder(map.from, map.to);
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
@ -0,0 +1,27 @@
|
||||
const testPackage = require('../../helpers/test-package');
|
||||
const Dgeni = require('dgeni');
|
||||
const factory = require('./copyContentAssets');
|
||||
|
||||
describe('extractDecoratedClasses processor', function() {
|
||||
let dgeni, injector, processor;
|
||||
|
||||
beforeEach(function() {
|
||||
dgeni = new Dgeni([testPackage('angular-content-package')]);
|
||||
injector = dgeni.configureInjector();
|
||||
processor = injector.get('copyContentAssetsProcessor');
|
||||
});
|
||||
|
||||
it('should exist', () => {
|
||||
expect(processor).toBeDefined();
|
||||
});
|
||||
|
||||
it('should call copyFolder with each mapping', () => {
|
||||
const mockCopyFolder = jasmine.createSpy();
|
||||
processor = factory(mockCopyFolder);
|
||||
processor.assetMappings.push({ from: 'a/b/c', to: 'x/y/z' });
|
||||
processor.assetMappings.push({ from: '1/2/3', to: '4/5/6' });
|
||||
processor.$process();
|
||||
expect(mockCopyFolder).toHaveBeenCalledWith('a/b/c', 'x/y/z');
|
||||
expect(mockCopyFolder).toHaveBeenCalledWith('1/2/3', '4/5/6');
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user