Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

test for timeout

Tj Holowaychuk4bf3f5033289
diff --git a/lib/runnable.js b/lib/runnable.js
index f350888a..217d9ab5 100644
--- a/lib/runnable.js
+++ b/lib/runnable.js
@@ -22,14 +22,15 @@ function Runnable(title, fn) {
}
/**
- * Set timeout `ms`.
+ * Set & get timeout `ms`.
*
* @param {Number} ms
- * @return {Runnable} for chaining
+ * @return {Runnable|Number} ms or self
* @api private
*/
Runnable.prototype.timeout = function(ms){
+ if (0 == arguments.length) return this._timeout;
this._timeout = ms;
return this;
};
diff --git a/test/runnable.js b/test/runnable.js
new file mode 100644
index 00000000..22013557
--- /dev/null
+++ b/test/runnable.js
@@ -0,0 +1,13 @@
+
+var mocha = require('../')
+ , Runnable = mocha.Runnable;
+
+describe('Runnable', function(){
+ describe('#timeout(ms)', function(){
+ it('should set the timeout', function(){
+ var run = new Runnable;
+ run.timeout(1000)
+ run.timeout().should.equal(1000);
+ })
+ })
+})
\ No newline at end of file