Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

chore: ability to add unit test boilerplate #2462

Merged
merged 1 commit into from
Sep 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -97,14 +98,19 @@ var _exampleBoilerplateFiles = [
'tsconfig.json',
'tslint.json',
'typings.json'
];
];

var _exampleDartWebBoilerPlateFiles = ['a2docs.css', 'styles.css'];

var _exampleProtractorBoilerplateFiles = [
'tsconfig.json'
];

var _exampleUnitTestingBoilerplateFiles = [
'karma-test-shim.js',
'karma.conf.js'
];

var _exampleConfigFilename = 'example-config.json';

var _styleLessName = 'a2docs.less';
Expand Down Expand Up @@ -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);
});
}

Expand Down Expand Up @@ -894,7 +908,7 @@ function harpCompile() {
} else {
gutil.log(`Harp full site compile, including API docs for all languages.`);
if (skipLangs)
gutil.log(`Ignoring API docs skip set (${skipLangs}) because full ` +
gutil.log(`Ignoring API docs skip set (${skipLangs}) because full ` +
`site has not been built yet or some API HTML files are missing.`);
}

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -1164,7 +1186,7 @@ function watchAndSync(options, cb) {

// When using the --focus=name flag, only **/name/**/*.* example files and
// **/name.jade files are watched. This is useful for performance reasons.
// Example: gulp serve-and-sync --focus=architecture
// Example: gulp serve-and-sync --focus=architecture
var focus = argv.focus;

if (options.devGuide) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"unittesting": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"unittesting": true
}