37 lines
929 B
JavaScript
37 lines
929 B
JavaScript
import { Promise } from 'rsvp';
|
|
import { module } from 'qunit';
|
|
import startApp from '../helpers/start-app';
|
|
import destroyApp from '../helpers/destroy-app';
|
|
|
|
export default function(name, options = {}) {
|
|
module(name, {
|
|
beforeEach() {
|
|
// Also clear local storage (a side effect of namespaces, regions, and tokens)
|
|
window.localStorage.clear();
|
|
|
|
this.application = startApp();
|
|
|
|
if (options.beforeEach) {
|
|
return options.beforeEach.apply(this, arguments);
|
|
}
|
|
},
|
|
|
|
afterEach() {
|
|
let afterEach = options.afterEach && options.afterEach.apply(this, arguments);
|
|
return Promise.resolve(afterEach).then(() => destroyApp(this.application));
|
|
},
|
|
|
|
after() {
|
|
if (options.after) {
|
|
return options.after.apply(this, arguments);
|
|
}
|
|
},
|
|
|
|
before() {
|
|
if (options.before) {
|
|
return options.before.apply(this, arguments);
|
|
}
|
|
},
|
|
});
|
|
}
|