open-nomad/ui/tests/helpers/module-for-acceptance.js
Alex Dadgar e5ec915ac3 sync
2017-09-19 10:08:23 -05:00

27 lines
720 B
JavaScript

import { module } from 'qunit';
import Ember from 'ember';
import startApp from '../helpers/start-app';
import destroyApp from '../helpers/destroy-app';
const { RSVP: { Promise } } = Ember;
export default function(name, options = {}) {
module(name, {
beforeEach() {
// Clear session storage (a side effect of token storage)
window.sessionStorage.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));
},
});
}