2019-03-02 15:19:08 +00:00
|
|
|
import WithEnvironment from "./WithEnvironment";
|
|
|
|
import fs from 'fs';
|
2019-01-30 15:47:03 +00:00
|
|
|
|
|
|
|
interface AutheliaSuiteType {
|
2019-01-30 21:44:03 +00:00
|
|
|
(description: string, configPath: string, cb: (this: Mocha.ISuiteCallbackContext) => void): Mocha.ISuite;
|
|
|
|
only: (description: string, configPath: string, cb: (this: Mocha.ISuiteCallbackContext) => void) => Mocha.ISuite;
|
2019-01-30 15:47:03 +00:00
|
|
|
}
|
|
|
|
|
2019-03-02 15:19:08 +00:00
|
|
|
function AutheliaSuiteBase(description: string, suite: string,
|
2019-01-30 21:44:03 +00:00
|
|
|
cb: (this: Mocha.ISuiteCallbackContext) => void,
|
|
|
|
context: (description: string, ctx: (this: Mocha.ISuiteCallbackContext) => void) => Mocha.ISuite) {
|
2019-01-30 15:47:03 +00:00
|
|
|
return context('Suite: ' + description, function(this: Mocha.ISuiteCallbackContext) {
|
2019-03-02 15:19:08 +00:00
|
|
|
if (!fs.existsSync('.suite')) {
|
|
|
|
WithEnvironment(suite);
|
2019-02-23 22:02:03 +00:00
|
|
|
}
|
|
|
|
|
2019-01-30 15:47:03 +00:00
|
|
|
cb.call(this);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-01-30 21:44:03 +00:00
|
|
|
const AutheliaSuite = <AutheliaSuiteType>function(
|
|
|
|
description: string, configPath: string,
|
|
|
|
cb: (this: Mocha.ISuiteCallbackContext) => void) {
|
|
|
|
return AutheliaSuiteBase(description, configPath, cb, describe);
|
2019-01-30 15:47:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-01-30 21:44:03 +00:00
|
|
|
AutheliaSuite.only = function(description: string, configPath: string,
|
|
|
|
cb: (this: Mocha.ISuiteCallbackContext) => void) {
|
|
|
|
return AutheliaSuiteBase(description, configPath, cb, describe.only);
|
2019-01-30 15:47:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default AutheliaSuite as AutheliaSuiteType;
|