surrealpatch/gui/tests/helpers/module-for-acceptance.js

24 lines
617 B
JavaScript
Raw Normal View History

2016-05-14 10:20:59 +00:00
import { module } from 'qunit';
2016-07-11 13:49:23 +00:00
import Ember from 'ember';
2016-05-14 10:20:59 +00:00
import startApp from '../helpers/start-app';
import destroyApp from '../helpers/destroy-app';
2016-07-11 13:49:23 +00:00
const { RSVP: { Promise } } = Ember;
2016-05-14 10:20:59 +00:00
export default function(name, options = {}) {
module(name, {
beforeEach() {
this.application = startApp();
if (options.beforeEach) {
2016-07-11 13:49:23 +00:00
return options.beforeEach.apply(this, arguments);
2016-05-14 10:20:59 +00:00
}
},
afterEach() {
2016-07-11 13:49:23 +00:00
let afterEach = options.afterEach && options.afterEach.apply(this, arguments);
return Promise.resolve(afterEach).then(() => destroyApp(this.application));
2016-05-14 10:20:59 +00:00
}
});
}