Last change
on this file was
484,
checked in by hendrikvanantwerpen, 11 years ago
|
Commit node_modules, to make checkouts and builds more deterministic.
|
File size:
1.1 KB
|
Rev | Line | |
---|
[484] | 1 | |
---|
| 2 | /** |
---|
| 3 | * Expose `Context`. |
---|
| 4 | */ |
---|
| 5 | |
---|
| 6 | module.exports = Context; |
---|
| 7 | |
---|
| 8 | /** |
---|
| 9 | * Initialize a new `Context`. |
---|
| 10 | * |
---|
| 11 | * @api private |
---|
| 12 | */ |
---|
| 13 | |
---|
| 14 | function 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 | |
---|
| 24 | Context.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 | |
---|
| 38 | Context.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 | |
---|
| 51 | Context.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 | |
---|
| 63 | Context.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.