☕️ Classic, reliable, trusted test framework for Node.js and the browser
add ms() to .slow() and .timeout()
TJ Holowaychuk3e1c439a2c37
diff --git a/lib/suite.js b/lib/suite.jsindex 79f38c9c..c726ccb6 100644--- a/lib/suite.js+++ b/lib/suite.js@@ -5,6 +5,7 @@var EventEmitter = require('events').EventEmitter, debug = require('debug')('mocha:suite')+ , milliseconds = require('ms'), utils = require('./utils'), Hook = require('./hook');@@ -94,7 +95,7 @@ Suite.prototype.clone = function(){Suite.prototype.timeout = function(ms){if (0 == arguments.length) return this._timeout;- if (String(ms).match(/s$/)) ms = parseFloat(ms) * 1000;+ if ('string' == typeof ms) ms = milliseconds(ms);debug('timeout %d', ms);this._timeout = parseInt(ms, 10);return this;@@ -110,9 +111,9 @@ Suite.prototype.timeout = function(ms){Suite.prototype.slow = function(ms){if (0 === arguments.length) return this._slow;- if (String(ms).match(/s$/)) ms = parseFloat(ms) * 1000;+ if ('string' == typeof ms) ms = milliseconds(ms);debug('slow %d', ms);- this._slow = parseInt(ms, 10);+ this._slow = ms;return this;};diff --git a/test/suite.js b/test/suite.jsindex 1795b6b0..e04bf5d7 100644--- a/test/suite.js+++ b/test/suite.js@@ -84,6 +84,13 @@ describe('Suite', function(){this.suite = new Suite('A Suite');});+ describe('when given a string', function(){+ it('should parse it', function(){+ this.suite.slow('5 seconds');+ this.suite.slow().should.equal(5000);+ })+ })+describe('when no argument is passed', function(){it('should return the slow value', function(){this.suite.slow().should.equal(75);