2019-01-30 22:47:03 +07:00
|
|
|
import WithAutheliaRunning from "./WithAutheliaRunning";
|
|
|
|
import WithDriver from "./WithDriver";
|
|
|
|
|
|
|
|
let running = false;
|
|
|
|
|
|
|
|
interface AutheliaSuiteType {
|
2019-01-31 04:44:03 +07: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 22:47:03 +07:00
|
|
|
}
|
|
|
|
|
2019-01-31 04:44:03 +07:00
|
|
|
function AutheliaSuiteBase(description: string, configPath: string,
|
|
|
|
cb: (this: Mocha.ISuiteCallbackContext) => void,
|
|
|
|
context: (description: string, ctx: (this: Mocha.ISuiteCallbackContext) => void) => Mocha.ISuite) {
|
2019-01-30 22:47:03 +07:00
|
|
|
if (!running && process.env['WITH_SERVER'] == 'y') {
|
2019-01-31 04:44:03 +07:00
|
|
|
WithAutheliaRunning(configPath);
|
2019-01-30 22:47:03 +07:00
|
|
|
running = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return context('Suite: ' + description, function(this: Mocha.ISuiteCallbackContext) {
|
|
|
|
WithDriver.call(this);
|
|
|
|
cb.call(this);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-01-31 04:44:03 +07:00
|
|
|
const AutheliaSuite = <AutheliaSuiteType>function(
|
|
|
|
description: string, configPath: string,
|
|
|
|
cb: (this: Mocha.ISuiteCallbackContext) => void) {
|
|
|
|
return AutheliaSuiteBase(description, configPath, cb, describe);
|
2019-01-30 22:47:03 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-01-31 04:44:03 +07:00
|
|
|
AutheliaSuite.only = function(description: string, configPath: string,
|
|
|
|
cb: (this: Mocha.ISuiteCallbackContext) => void) {
|
|
|
|
return AutheliaSuiteBase(description, configPath, cb, describe.only);
|
2019-01-30 22:47:03 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
export default AutheliaSuite as AutheliaSuiteType;
|