github.com/zoomfoo/nomad@v0.8.5-0.20180907175415-f28fd3a1a056/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 // Also clear local storage (a side effect of namespaces, regions, and tokens) 10 window.localStorage.clear(); 11 12 this.application = startApp(); 13 14 if (options.beforeEach) { 15 return options.beforeEach.apply(this, arguments); 16 } 17 }, 18 19 afterEach() { 20 let afterEach = options.afterEach && options.afterEach.apply(this, arguments); 21 return Promise.resolve(afterEach).then(() => destroyApp(this.application)); 22 }, 23 }); 24 }