From 3bf6c26a0a491f8721fbb796c5932ba5920fd5d5 Mon Sep 17 00:00:00 2001 From: Christian Date: Mon, 9 Oct 2017 20:12:57 +0200 Subject: [PATCH] normalize getters and setters (fixes #3058) --- lib/context.js | 14 ++++++++++---- lib/runnable.js | 10 +++++----- lib/suite.js | 10 +++++----- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/lib/context.js b/lib/context.js index 073643b8b6..633a2ac472 100644 --- a/lib/context.js +++ b/lib/context.js @@ -29,7 +29,7 @@ Context.prototype.runnable = function (runnable) { }; /** - * Set test timeout `ms`. + * Set or get test timeout `ms`. * * @api private * @param {number} ms @@ -44,25 +44,31 @@ Context.prototype.timeout = function (ms) { }; /** - * Set test timeout `enabled`. + * Set or get test timeout `enabled`. * * @api private * @param {boolean} enabled * @return {Context} self */ Context.prototype.enableTimeouts = function (enabled) { + if (!arguments.length) { + return this.runnable().enableTimeouts(); + } this.runnable().enableTimeouts(enabled); return this; }; /** - * Set test slowness threshold `ms`. + * Set or get test slowness threshold `ms`. * * @api private * @param {number} ms * @return {Context} self */ Context.prototype.slow = function (ms) { + if (!arguments.length) { + return this.runnable().slow(); + } this.runnable().slow(ms); return this; }; @@ -78,7 +84,7 @@ Context.prototype.skip = function () { }; /** - * Allow a number of retries on failed tests + * Set or get a number of allowed retries on failed tests * * @api private * @param {number} n diff --git a/lib/runnable.js b/lib/runnable.js index 946f278341..694d4f59c2 100644 --- a/lib/runnable.js +++ b/lib/runnable.js @@ -91,14 +91,14 @@ Runnable.prototype.timeout = function (ms) { }; /** - * Set & get slow `ms`. + * Set or get slow `ms`. * * @api private * @param {number|string} ms * @return {Runnable|number} ms or Runnable instance. */ Runnable.prototype.slow = function (ms) { - if (typeof ms === 'undefined') { + if (!arguments.length || typeof ms === 'undefined') { return this._slow; } if (typeof ms === 'string') { @@ -144,7 +144,7 @@ Runnable.prototype.isPending = function () { }; /** - * Set number of retries. + * Set or get number of retries. * * @api private */ @@ -156,7 +156,7 @@ Runnable.prototype.retries = function (n) { }; /** - * Get current retry + * Set or get current retry * * @api private */ @@ -242,7 +242,7 @@ Runnable.prototype.resetTimeout = function () { }; /** - * Whitelist a list of globals for this test run. + * Set or get a list of whitelisted globals for this test run. * * @api private * @param {string[]} globals diff --git a/lib/suite.js b/lib/suite.js index f5dca4cfa5..9b9a082762 100644 --- a/lib/suite.js +++ b/lib/suite.js @@ -92,7 +92,7 @@ Suite.prototype.clone = function () { }; /** - * Set timeout `ms` or short-hand such as "2s". + * Set or get timeout `ms` or short-hand such as "2s". * * @api private * @param {number|string} ms @@ -114,7 +114,7 @@ Suite.prototype.timeout = function (ms) { }; /** - * Set number of times to retry a failed test. + * Set or get number of times to retry a failed test. * * @api private * @param {number|string} n @@ -130,7 +130,7 @@ Suite.prototype.retries = function (n) { }; /** - * Set timeout to `enabled`. + * Set or get timeout to `enabled`. * * @api private * @param {boolean} enabled @@ -146,7 +146,7 @@ Suite.prototype.enableTimeouts = function (enabled) { }; /** - * Set slow `ms` or short-hand such as "2s". + * Set or get slow `ms` or short-hand such as "2s". * * @api private * @param {number|string} ms @@ -165,7 +165,7 @@ Suite.prototype.slow = function (ms) { }; /** - * Sets whether to bail after first error. + * Sets or gets whether to bail after first error. * * @api private * @param {boolean} bail