github.com/blixtra/nomad@v0.7.2-0.20171221000451-da9a1d7bb050/ui/tests/helpers/module-for-acceptance.js (about)

     1  import { module } from 'qunit';
     2  import Ember from 'ember';
     3  import startApp from '../helpers/start-app';
     4  import destroyApp from '../helpers/destroy-app';
     5  
     6  const { RSVP: { Promise } } = Ember;
     7  
     8  export default function(name, options = {}) {
     9    module(name, {
    10      beforeEach() {
    11        // Clear session storage (a side effect of token storage)
    12        window.sessionStorage.clear();
    13  
    14        // Also clear local storage (a side effect of namespaces)
    15        window.localStorage.clear();
    16  
    17        this.application = startApp();
    18  
    19        if (options.beforeEach) {
    20          return options.beforeEach.apply(this, arguments);
    21        }
    22      },
    23  
    24      afterEach() {
    25        let afterEach = options.afterEach && options.afterEach.apply(this, arguments);
    26        return Promise.resolve(afterEach).then(() => destroyApp(this.application));
    27      },
    28    });
    29  }