fava
Version:
A wannabe tiny largely-drop-in replacement for ava that works in the browser too.
31 lines (30 loc) • 911 B
JavaScript
/* IMPORT */
import { ROOT_SUITER_ID } from './constants.js';
import Suiter from './suiter.js';
/* MAIN */
// The Executor singleton keeps track of the current suite, or creates one if needed
// Only one suite can be active at any given time, they can't be nested
class Executor {
constructor() {
/* VARIABLES */
/* API */
this.get = () => {
if (this.current && !this.current.executed)
return this.current;
return this.init();
};
this.init = () => {
const suiter = new Suiter(ROOT_SUITER_ID);
suiter.schedule();
return this.current = suiter;
};
this.set = (suiter) => {
if (this.current && !this.current.scheduled)
this.current.schedule();
return this.current = suiter;
};
}
}
;
/* EXPORT */
export default new Executor();