lib/jasmine-flight.js
function describeComponentFactory (componentPath, specDefinitions, isMixin) {
    return function () {
      beforeEach(function (done) {
        // reset member variables
        this.Component = this.component = this.$node = null;

        // bind setupComponent to the current context
        this.setupComponent = setupComponent.bind(this);

        var requireCallback = function (registry, defineComponent, Component) {
          // reset the registry
          registry.reset();

          if (isMixin) {
            // mix the mixin in to an anonymous, component
            this.Component = defineComponent(function () {}, Component);
          } else {
            this.Component = Component;
          }
          // let Jasmine know we're good to continue with the tests
          done();
        }.bind(this);

        require(['flight/lib/registry', 'flight/lib/component', componentPath], requireCallback);
      });

      afterEach(function (done) {
        // remove the component root node
        if (this.$node) {
          this.$node.remove();
          this.$node = null;
        }

        var requireCallback = function (defineComponent) {
          // reset local member variables
          this.component = null;
          this.Component = null;
          // teardown all flight components
          defineComponent.teardownAll();
          done();
        }.bind(this);

        require(['flight/lib/component'], requireCallback);
      });

      specDefinitions.apply(this);
    };
  }
function describeComponentFactory (componentPath, specDefinitions, isMixin) {
    return function () {
      beforeEach(function (done) {
        // reset member variables
        this.Component = this.component = this.$node = null;

        // bind setupComponent to the current context
        this.setupComponent = setupComponent.bind(this);

        var requireCallback = function (registry, defineComponent, Component) {
          // reset the registry
          registry.reset();

          if (isMixin) {
            // mix the mixin in to an anonymous, component
            this.Component = defineComponent(function () {}, Component);
          } else {
            this.Component = Component;
          }
          // let Jasmine know we're good to continue with the tests
          done();
        }.bind(this);

        require(['flight/lib/registry', 'flight/lib/component', componentPath], requireCallback);
      });

      afterEach(function (done) {
        // remove the component root node
        if (this.$node) {
          this.$node.remove();
          this.$node = null;
        }

        var requireCallback = function (defineComponent) {
          // reset local member variables
          this.component = null;
          this.Component = null;
          // teardown all flight components
          defineComponent.teardownAll();
          done();
        }.bind(this);

        require(['flight/lib/component'], requireCallback);
      });

      specDefinitions.apply(this);
    };
  }
function describeComponentFactory ( componentPath , specDefinitions , isMixin ) { return function ( ) { beforeEach ( function ( done ) { // reset member variables this . Component = this . component = this . $node = null ; // bind setupComponent to the current context this . setupComponent = setupComponent . bind ( this ) ; var requireCallback = function ( registry , defineComponent , Component ) { // reset the registry registry . reset ( ) ; if ( isMixin ) { // mix the mixin in to an anonymous, component this . Component = defineComponent ( function ( ) { } , Component ) ; } else { this . Component = Component ; } // let Jasmine know we're good to continue with the tests done ( ) ; } . bind ( this ) ; require ( [ 'flight/lib/registry' , 'flight/lib/component' , componentPath ] , requireCallback ) ; } ) ; afterEach ( function ( done ) { // remove the component root node if ( this . $node ) { this . $node . remove ( ) ; this . $node = null ; } var requireCallback = function ( defineComponent ) { // reset local member variables this . component = null ; this . Component = null ; // teardown all flight components defineComponent . teardownAll ( ) ; done ( ) ; } . bind ( this ) ; require ( [ 'flight/lib/component' ] , requireCallback ) ; } ) ; specDefinitions . apply ( this ) ; } ; }
describeComponentFactory
loads the specified amd component/mixin before executing specDefinitions
provides this.setupComponent
Component instances created with this.setupComponent are torn down after each spec

@param componentPath
@param specDefinitions
describeComponentFactory loads the specified amd component / mixin before executing specDefinitions provides this . setupComponent Component instances created with this . setupComponent are torn down after each spec