Sha256: 764d9b72ff086a3aa9e44382497856b0d381026b163b80fb0a4d0cc1b6e2b01a

Contents?: true

Size: 1.22 KB

Versions: 13

Compression:

Stored size: 1.22 KB

Contents

/**
 * Module dependencies.
 */

var Suite = require('../suite')
  , Test = require('../test');

/**
 * TDD-style interface:
 * 
 *     exports.Array = {
 *       '#indexOf()': {
 *         'should return -1 when the value is not present': function(){
 *           
 *         },
 *
 *         'should return the correct index when the value is present': function(){
 *           
 *         }
 *       }
 *     };
 * 
 */

module.exports = function(suite){
  var suites = [suite];

  suite.on('require', visit);

  function visit(obj) {
    var suite;
    for (var key in obj) {
      if ('function' == typeof obj[key]) {
        var fn = obj[key];
        switch (key) {
          case 'before':
            suites[0].beforeAll(fn);
            break;
          case 'after':
            suites[0].afterAll(fn);
            break;
          case 'beforeEach':
            suites[0].beforeEach(fn);
            break;
          case 'afterEach':
            suites[0].afterEach(fn);
            break;
          default:
            suites[0].addTest(new Test(key, fn));
        }
      } else {
        var suite = Suite.create(suites[0], key);
        suites.unshift(suite);
        visit(obj[key]);
        suites.shift();
      }
    }
  }
};

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
stylus-source-0.31.0 vendor/node_modules/mocha/lib/interfaces/exports.js
stylus-source-0.30.1 vendor/node_modules/mocha/lib/interfaces/exports.js
stylus-source-0.30.0 vendor/node_modules/mocha/lib/interfaces/exports.js
stylus-source-0.29.0 vendor/node_modules/mocha/lib/interfaces/exports.js
stylus-source-0.28.2 vendor/node_modules/mocha/lib/interfaces/exports.js
stylus-source-0.28.1 vendor/node_modules/mocha/lib/interfaces/exports.js
stylus-source-0.28.0 vendor/node_modules/mocha/lib/interfaces/exports.js
stylus-source-0.27.2 vendor/node_modules/mocha/lib/interfaces/exports.js
stylus-source-0.27.1 vendor/node_modules/mocha/lib/interfaces/exports.js
stylus-source-0.27.0 vendor/node_modules/mocha/lib/interfaces/exports.js
stylus-source-0.26.1 vendor/node_modules/mocha/lib/interfaces/exports.js
stylus-source-0.26.0 vendor/node_modules/mocha/lib/interfaces/exports.js
stylus-source-0.25.0 vendor/node_modules/mocha/lib/interfaces/exports.js