Files
2016-11-30 17:32:23 -08:00

60 lines
1.5 KiB
TypeScript

/* This file was auto-generated by gulp-shenanigans */
import { MochaLoader } from "./utils/MochaLoader";
declare var requirejs: any;
declare var testDependencies: string[];
declare var testPaths: string[];
export const mochaLoader: MochaLoader = new MochaLoader(mocha);
/**
* 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}/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();
});
})();