github.com/elliott5/community@v0.14.1-0.20160709191136-823126fb026a/app/tests/helpers/module-for-acceptance.js (about)

     1  import { module } from 'qunit';
     2  import startApp from '../helpers/start-app';
     3  import destroyApp from '../helpers/destroy-app';
     4  
     5  export default function(name, options = {}) {
     6    module(name, {
     7      beforeEach() {
     8        this.application = startApp();
     9        stubAudit(this);
    10        stubUserNotification(this);
    11  
    12        if (options.beforeEach) {
    13          options.beforeEach.apply(this, arguments);
    14        }
    15  
    16        this.register = (fullName, Factory) => {
    17          let instance = this.application.__deprecatedInstance__;
    18          let registry = instance.register ? instance : instance.registry;
    19  
    20          return registry.register(fullName, Factory);
    21        };
    22      },
    23  
    24      afterEach() {
    25        destroyApp(this.application);
    26  
    27        if (options.afterEach) {
    28          options.afterEach.apply(this, arguments);
    29        }
    30      }
    31    });
    32  }