This repository has been archived by the owner on May 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(copy): added tests for copyConfigToWatchConfig
- Loading branch information
1 parent
8924704
commit 26f6db8
Showing
2 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import * as copy from './copy'; | ||
|
||
import * as config from './util/config'; | ||
|
||
describe('copy task', () => { | ||
describe('copyConfigToWatchConfig', () => { | ||
it('should do something', () => { | ||
// arrange | ||
const context = { }; | ||
const configFile = 'configFile'; | ||
const sampleConfig: copy.CopyConfig = { | ||
copyAssets: { | ||
src: ['{{SRC}}/assets/**/*'], | ||
dest: '{{WWW}}/assets' | ||
}, | ||
copyIndexContent: { | ||
src: ['{{SRC}}/index.html', '{{SRC}}/manifest.json', '{{SRC}}/service-worker.js'], | ||
dest: '{{WWW}}' | ||
}, | ||
copyFonts: { | ||
src: ['{{ROOT}}/node_modules/ionicons/dist/fonts/**/*', '{{ROOT}}/node_modules/ionic-angular/fonts/**/*'], | ||
dest: '{{WWW}}/assets/fonts' | ||
}, | ||
copyPolyfills: { | ||
src: ['{{ROOT}}/node_modules/ionic-angular/polyfills/polyfills.js'], | ||
dest: '{{BUILD}}' | ||
}, | ||
someOtherOption: { | ||
src: ['{{ROOT}}/whatever'], | ||
dest: '{{BUILD}}' | ||
} | ||
}; | ||
let combinedSource: string[] = []; | ||
Object.keys(sampleConfig).forEach(entry => combinedSource = combinedSource.concat(sampleConfig[entry].src)); | ||
|
||
spyOn(config, config.generateContext.name).and.returnValue(context); | ||
spyOn(config, config.getUserConfigFile.name).and.returnValue(configFile); | ||
spyOn(config, config.fillConfigDefaults.name).and.returnValue(sampleConfig); | ||
|
||
// act | ||
const result = copy.copyConfigToWatchConfig(null); | ||
|
||
// assert | ||
expect(config.generateContext).toHaveBeenCalledWith(null); | ||
expect(config.getUserConfigFile).toHaveBeenCalledWith(context, copy.taskInfo, ''); | ||
expect(config.fillConfigDefaults).toHaveBeenCalledWith(configFile, copy.taskInfo.defaultConfigFile); | ||
(result.paths as string[]).forEach(glob => { | ||
expect(combinedSource.indexOf(glob)).not.toEqual(-1); | ||
}); | ||
expect(result.callback).toBeDefined(); | ||
expect(result.options).toBeDefined(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters