Bumped gulp-shenanigans to 0.6.16

This commit is contained in:
Josh Goldberg
2017-09-18 14:12:29 -04:00
parent e73001f44f
commit 54a052531a
7 changed files with 8283 additions and 213 deletions
+3
View File
@@ -1,9 +1,12 @@
dist/**
docs/generated/**
lib/**
test/*.ts
test/utils/MochaLoader.ts
*.css
*.d.ts
*.js*
!*.json
!gulpfile.js
*.html
node_modules/
+8276
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -44,7 +44,7 @@
},
"devDependencies": {
"gulp": "^3.9.1",
"gulp-shenanigans": "^0.6.14"
"gulp-shenanigans": "^0.6.16"
},
"scripts": {
"gulp": "gulp",
-79
View File
@@ -1,79 +0,0 @@
/* This file was auto-generated by gulp-shenanigans */
import { MochaLoader } from "./utils/MochaLoader";
declare const requirejs: any;
declare const testDependencies: string[];
declare const testPaths: string[];
/**
* Combines mocha tests into their describe() groups.
*/
export const mochaLoader: MochaLoader = new MochaLoader(mocha);
/**
* Adds a new test under the current test path.
*
* @param testName The name of the test.
* @param test A new test.
*/
export const it: typeof mochaLoader.it = mochaLoader.it.bind(mochaLoader);
/**
* Adds a new test under a custom test path.
*
* @param path Extra path after the current test path.
* @param testName The name of the test.
* @param test A new test.
*/
export const under: typeof mochaLoader.under = mochaLoader.under.bind(mochaLoader);
/**
* Informs RequireJS of the file location for a test dependency.
*
* @param testDependencies Modules depended upon for tests.
*/
function redirectTestDependencies(dependencies: string[]): void {
for (const dependency of dependencies) {
requirejs.config({
paths: {
[dependency.toLowerCase() + "/lib"]: `../node_modules/${dependency.toLowerCase()}/src`
}
});
}
}
/**
* Recursively loads test paths under mocha loader.
*
* @param loadingPaths Test paths to load.
* @param i Which index test path to load.
* @param onComplete A callback for when loading is done.
*/
function loadTestPaths(loadingPaths: string[], i: number, onComplete: () => void): void {
"use strict";
if (i >= loadingPaths.length) {
onComplete();
return;
}
mochaLoader.setTestPath(loadingPaths[i]);
requirejs(
[loadingPaths[i]],
(): void => {
loadTestPaths(loadingPaths, i + 1, onComplete);
});
}
((): void => {
redirectTestDependencies(testDependencies);
loadTestPaths(
testPaths,
0,
(): void => {
mochaLoader.describeTests();
mochaLoader.run();
});
})();
-133
View File
@@ -1,133 +0,0 @@
/* This file was auto-generated by gulp-shenanigans */
/**
* Grouping of mocha describe() tests.
*/
interface ITestHierarchy {
/**
* Hierarchical children within this describe() group.
*/
children: {
[i: string]: ITestHierarchy;
};
/**
* Tests run in this describe().
*/
tests: {
[i: string]: (done: Function) => void;
};
}
/**
* Combines mocha tests into their describe() groups.
*/
export class MochaLoader {
/**
* The underlying mocha instance.
*/
private readonly mocha: Mocha;
/**
* Root grouping of test hierarchies.
*/
private readonly testHierarchy: ITestHierarchy = {
children: {},
tests: {}
};
/**
* Mocha describe() path for the next test to be added.
*/
private currentTestPath: string[];
/**
* Initializes a new instance of the MochaLoader class.
*
* @param mocha The underlying mocha instance.
*/
public constructor(mocha: Mocha) {
this.mocha = mocha;
this.mocha.setup("bdd");
}
/**
* Sets the current test path.
*
* @param rawPath A new current test path.
*/
public setTestPath(rawPath: string): void {
this.currentTestPath = rawPath.split("/");
}
/**
* Adds a new test under the current test path.
*
* @param testName The name of the test.
* @param test A new test.
*/
public it(testName: string, test: (done: Function) => void): void {
this.under([], testName, test);
}
/**
* Adds a new test under a custom test path.
*
* @param path Extra path after the current test path.
* @param testName The name of the test.
* @param test A new test.
*/
public under(path: string[], testName: string, test: (done: Function) => void): void {
if (!this.currentTestPath) {
throw new Error(`No test path defined before adding test '${testName}'.`);
}
let testHierarchy: ITestHierarchy = this.testHierarchy;
for (const part of [...this.currentTestPath, ...path]) {
if (!testHierarchy.children[part]) {
testHierarchy = testHierarchy.children[part] = {
children: {},
tests: {}
};
} else {
testHierarchy = testHierarchy.children[part];
}
}
testHierarchy.tests[testName] = test;
}
/**
* Finalizes the tests' describe() hierarchy.
*/
public describeTests(): void {
this.describeTestHierarchy(this.testHierarchy);
}
/**
* Runs tests using mocha.
*/
public run(): void {
this.mocha.run();
}
/**
* Recursively describes a test hierarchy and its children hierarchies.
*
* @param testHierarchy A test hierarchy to describe.
*/
private describeTestHierarchy(testHierarchy: ITestHierarchy): void {
for (const testName in testHierarchy.tests) {
if (testName in testHierarchy.tests) {
it(testName, testHierarchy.tests[testName]);
}
}
for (const childName in testHierarchy.children) {
if (childName in testHierarchy.children) {
describe(childName, (): void => this.describeTestHierarchy(testHierarchy.children[childName]));
}
}
}
}
+1
View File
@@ -1,6 +1,7 @@
{
"compilerOptions": {
"declaration": true,
"lib": ["dom", "es2015.collection", "es2015.promise", "es5"],
"module": "amd",
"moduleResolution": "node",
"noImplicitAny": true,
+2
View File
@@ -27,6 +27,7 @@
"no-magic-numbers": [false],
"no-non-null-assertion": [false],
"no-object-literal-type-assertion": [false],
"no-submodule-imports": [false],
"no-require-imports": false,
"no-unbound-method": [false],
"no-unsafe-any": [false],
@@ -40,6 +41,7 @@
"prefer-function-over-method": [false],
"prefer-method-signature": [false],
"prefer-switch": [false],
"prefer-conditional-expression": [false],
"prefer-template": [false],
"restrict-plus-operands": [false],
"space-before-function-paren": [false],