chore: ability to add unit test boilerplate (#2462)

This commit is contained in:
Jesús Rodríguez 2016-09-24 21:03:08 +02:00 committed by GitHub
parent 6c7f330620
commit 90100bffd9
3 changed files with 32 additions and 4 deletions

View File

@ -38,6 +38,7 @@ var DOCS_PATH = path.join(PUBLIC_PATH, 'docs');
var EXAMPLES_PATH = path.join(DOCS_PATH, '_examples');
var EXAMPLES_PROTRACTOR_PATH = path.join(EXAMPLES_PATH, '_protractor');
var EXAMPLES_TESTING_PATH = path.join(EXAMPLES_PATH, 'testing/ts');
var NOT_API_DOCS_GLOB = path.join(PUBLIC_PATH, './{docs/*/latest/!(api),!(docs)}/**/*.*');
var RESOURCES_PATH = path.join(PUBLIC_PATH, 'resources');
var LIVE_EXAMPLES_PATH = path.join(RESOURCES_PATH, 'live-examples');
@ -105,6 +106,11 @@ var _exampleProtractorBoilerplateFiles = [
'tsconfig.json'
];
var _exampleUnitTestingBoilerplateFiles = [
'karma-test-shim.js',
'karma.conf.js'
];
var _exampleConfigFilename = 'example-config.json';
var _styleLessName = 'a2docs.less';
@ -497,9 +503,17 @@ function copyExampleBoilerplate() {
.then(function() {
var protractorSourceFiles =
_exampleProtractorBoilerplateFiles
.map(function(name) {return path.join(EXAMPLES_PROTRACTOR_PATH, name);});;
.map(function(name) {return path.join(EXAMPLES_PROTRACTOR_PATH, name); });
var e2eSpecPaths = getE2eSpecPaths(EXAMPLES_PATH);
return copyFiles(protractorSourceFiles, e2eSpecPaths, destFileMode);
})
// copy the unit test boilerplate
.then(function() {
var unittestSourceFiles =
_exampleUnitTestingBoilerplateFiles
.map(function(name) { return path.join(EXAMPLES_TESTING_PATH, name); });
var unittestPaths = getUnitTestingPaths(EXAMPLES_PATH);
return copyFiles(unittestSourceFiles, unittestPaths, destFileMode);
});
}
@ -1130,6 +1144,14 @@ function getDartExampleWebPaths(basePath) {
return paths;
}
function getUnitTestingPaths(basePath) {
var examples = getPaths(basePath, _exampleConfigFilename, true);
return examples.filter((example) => {
var exampleConfig = fs.readJsonSync(`${example}/${_exampleConfigFilename}`, {throws: false});
return exampleConfig && !!exampleConfig.unittesting;
});
}
function getPaths(basePath, filename, includeBase) {
var filenames = getFilenames(basePath, filename, includeBase);
var paths = filenames.map(function(fileName) {

View File

@ -0,0 +1,3 @@
{
"unittesting": true
}

View File

@ -0,0 +1,3 @@
{
"unittesting": true
}