source: Dev/trunk/node_modules/mocha/lib/context.js @ 484

Last change on this file since 484 was 484, checked in by hendrikvanantwerpen, 11 years ago

Commit node_modules, to make checkouts and builds more deterministic.

File size: 1.1 KB
Line 
1
2/**
3 * Expose `Context`.
4 */
5
6module.exports = Context;
7
8/**
9 * Initialize a new `Context`.
10 *
11 * @api private
12 */
13
14function Context(){}
15
16/**
17 * Set or get the context `Runnable` to `runnable`.
18 *
19 * @param {Runnable} runnable
20 * @return {Context}
21 * @api private
22 */
23
24Context.prototype.runnable = function(runnable){
25  if (0 == arguments.length) return this._runnable;
26  this.test = this._runnable = runnable;
27  return this;
28};
29
30/**
31 * Set test timeout `ms`.
32 *
33 * @param {Number} ms
34 * @return {Context} self
35 * @api private
36 */
37
38Context.prototype.timeout = function(ms){
39  this.runnable().timeout(ms);
40  return this;
41};
42
43/**
44 * Set test slowness threshold `ms`.
45 *
46 * @param {Number} ms
47 * @return {Context} self
48 * @api private
49 */
50
51Context.prototype.slow = function(ms){
52  this.runnable().slow(ms);
53  return this;
54};
55
56/**
57 * Inspect the context void of `._runnable`.
58 *
59 * @return {String}
60 * @api private
61 */
62
63Context.prototype.inspect = function(){
64  return JSON.stringify(this, function(key, val){
65    if ('_runnable' == key) return;
66    if ('test' == key) return;
67    return val;
68  }, 2);
69};
Note: See TracBrowser for help on using the repository browser.