github.com/hspak/nomad@v0.7.2-0.20180309000617-bc4ae22a39a5/ui/tests/helpers/module-for-acceptance.js (about)

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