2019-03-02 22:19:08 +07:00
|
|
|
import WithEnvironment from "./WithEnvironment";
|
|
|
|
import fs from 'fs';
|
2019-01-30 22:47:03 +07:00
|
|
|
|
|
|
|
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-03-02 22:19:08 +07:00
|
|
|
function AutheliaSuiteBase(description: string, suite: string,
|
2019-01-31 04:44:03 +07:00
|
|
|
cb: (this: Mocha.ISuiteCallbackContext) => void,
|
|
|
|
context: (description: string, ctx: (this: Mocha.ISuiteCallbackContext) => void) => Mocha.ISuite) {
|
2019-01-30 22:47:03 +07:00
|
|
|
return context('Suite: ' + description, function(this: Mocha.ISuiteCallbackContext) {
|
2019-03-02 22:19:08 +07:00
|
|
|
if (!fs.existsSync('.suite')) {
|
|
|
|
WithEnvironment(suite);
|
2019-02-24 05:02:03 +07:00
|
|
|
}
|
|
|
|
|
2019-01-30 22:47:03 +07:00
|
|
|
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;
|