Code coverage report for ./../tap/lib/mocha.js

Statements: 25.93% (7 / 27)      Branches: 0% (0 / 10)      Functions: 0% (0 / 8)      Lines: 25.93% (7 / 27)      Ignored: none     

All files » ./../tap/lib/ » mocha.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47        2   2 2 2         2   2                           2                                  
// API surface inspired by Mocha,
// Copyright (c) TJ Holowaychuk <tj@vision-media.ca>
//
// Using these functions still outputs TAP, of course.
var stack = require('./stack.js')
 
exports.it = it
exports.describe = describe
exports.global = function () {
  for (var g in exports)
    global[g] = exports[g]
}
 
var t = require('./root.js')
 
function it (name, fn) {
  var c = t.current()
  var at = stack.at(it)
 
  if (fn && fn.length)
    c.test(name, { at: at }, function (tt) {
      fn(function () {
        tt.end()
      })
    })
  else
    c.doesNotThrow(fn, name || 'unnamed test', { at: at })
}
 
function describe (name, fn) {
  var c = t.current()
  var at = stack.at(describe)
  if (!fn)
    c.test(name, { at: at })
  else if (fn.length)
    c.test(name, { at: at }, function (tt) {
      fn(function () {
        tt.end()
      })
    })
  else
    c.test(name, { at: at }, function (tt) {
      fn()
      tt.end()
    })
}