Вход Регистрация
Файл: error-kitty/node_modules/mocha/lib/interfaces/bdd.js
Строк: 136
<?php
/**
 * Module dependencies.
 */

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

/**
 * BDD-style interface:
 *
 *      describe('Array', function(){
 *        describe('#indexOf()', function(){
 *          it('should return -1 when not present', function(){
 *
 *          });
 *
 *          it('should return the index when present', function(){
 *
 *          });
 *        });
 *      });
 *
 */

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

  
suite.on('pre-require', function(contextfilemocha){

    
/**
     * Execute before running tests.
     */

    
context.before = function(namefn){
      
suites[0].beforeAll(namefn);
    };

    
/**
     * Execute after running tests.
     */

    
context.after = function(namefn){
      
suites[0].afterAll(namefn);
    };

    
/**
     * Execute before each test case.
     */

    
context.beforeEach = function(namefn){
      
suites[0].beforeEach(namefn);
    };

    
/**
     * Execute after each test case.
     */

    
context.afterEach = function(namefn){
      
suites[0].afterEach(namefn);
    };

    
/**
     * Describe a "suite" with the given `title`
     * and callback `fn` containing nested suites
     * and/or tests.
     */

    
context.describe context.context = function(titlefn){
      var 
suite Suite.create(suites[0], title);
      
suite.file file;
      
suites.unshift(suite);
      
fn.call(suite);
      
suites.shift();
      return 
suite;
    };

    
/**
     * Pending describe.
     */

    
context.xdescribe =
    
context.xcontext =
    
context.describe.skip = function(titlefn){
      var 
suite Suite.create(suites[0], title);
      
suite.pending true;
      
suites.unshift(suite);
      
fn.call(suite);
      
suites.shift();
    };

    
/**
     * Exclusive suite.
     */

    
context.describe.only = function(titlefn){
      var 
suite context.describe(titlefn);
      
mocha.grep(suite.fullTitle());
      return 
suite;
    };

    
/**
     * Describe a specification or test-case
     * with the given `title` and callback `fn`
     * acting as a thunk.
     */

    
context.it context.specify = function(titlefn){
      var 
suite suites[0];
      if (
suite.pending) var fn null;
      var 
test = new Test(titlefn);
      
test.file file;
      
suite.addTest(test);
      return 
test;
    };

    
/**
     * Exclusive test-case.
     */

    
context.it.only = function(titlefn){
      var 
test context.it(titlefn);
      var 
reString '^' utils.escapeRegexp(test.fullTitle()) + '$';
      
mocha.grep(new RegExp(reString));
      return 
test;
    };

    
/**
     * Pending test case.
     */

    
context.xit =
    
context.xspecify =
    
context.it.skip = function(title){
      
context.it(title);
    };
  });
};
?>
Онлайн: 1
Реклама