common/corpus-common-addon/tests/helpers/module-for-acceptance.js
author ymh <ymh.work@gmail.com>
Fri, 17 Nov 2017 00:06:39 +0100
changeset 556 a31f1343b913
parent 543 aaaf9b0b09f6
permissions -rw-r--r--
Correct header and footer for backend pages

import { module } from 'qunit';
import Ember from 'ember';
import startApp from '../helpers/start-app';
import destroyApp from '../helpers/destroy-app';

const { RSVP: { resolve } } = Ember;

export default function(name, options = {}) {
  module(name, {
    beforeEach() {
      this.application = startApp();

      if (options.beforeEach) {
        return options.beforeEach.apply(this, arguments);
      }
    },

    afterEach() {
      let afterEach = options.afterEach && options.afterEach.apply(this, arguments);
      return resolve(afterEach).then(() => destroyApp(this.application));
    }
  });
}