Skip to content

Commit 3bf6c26

Browse files
committed
normalize getters and setters (fixes mochajs#3058)
1 parent 9f204ba commit 3bf6c26

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed

lib/context.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Context.prototype.runnable = function (runnable) {
2929
};
3030

3131
/**
32-
* Set test timeout `ms`.
32+
* Set or get test timeout `ms`.
3333
*
3434
* @api private
3535
* @param {number} ms
@@ -44,25 +44,31 @@ Context.prototype.timeout = function (ms) {
4444
};
4545

4646
/**
47-
* Set test timeout `enabled`.
47+
* Set or get test timeout `enabled`.
4848
*
4949
* @api private
5050
* @param {boolean} enabled
5151
* @return {Context} self
5252
*/
5353
Context.prototype.enableTimeouts = function (enabled) {
54+
if (!arguments.length) {
55+
return this.runnable().enableTimeouts();
56+
}
5457
this.runnable().enableTimeouts(enabled);
5558
return this;
5659
};
5760

5861
/**
59-
* Set test slowness threshold `ms`.
62+
* Set or get test slowness threshold `ms`.
6063
*
6164
* @api private
6265
* @param {number} ms
6366
* @return {Context} self
6467
*/
6568
Context.prototype.slow = function (ms) {
69+
if (!arguments.length) {
70+
return this.runnable().slow();
71+
}
6672
this.runnable().slow(ms);
6773
return this;
6874
};
@@ -78,7 +84,7 @@ Context.prototype.skip = function () {
7884
};
7985

8086
/**
81-
* Allow a number of retries on failed tests
87+
* Set or get a number of allowed retries on failed tests
8288
*
8389
* @api private
8490
* @param {number} n

lib/runnable.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,14 @@ Runnable.prototype.timeout = function (ms) {
9191
};
9292

9393
/**
94-
* Set & get slow `ms`.
94+
* Set or get slow `ms`.
9595
*
9696
* @api private
9797
* @param {number|string} ms
9898
* @return {Runnable|number} ms or Runnable instance.
9999
*/
100100
Runnable.prototype.slow = function (ms) {
101-
if (typeof ms === 'undefined') {
101+
if (!arguments.length || typeof ms === 'undefined') {
102102
return this._slow;
103103
}
104104
if (typeof ms === 'string') {
@@ -144,7 +144,7 @@ Runnable.prototype.isPending = function () {
144144
};
145145

146146
/**
147-
* Set number of retries.
147+
* Set or get number of retries.
148148
*
149149
* @api private
150150
*/
@@ -156,7 +156,7 @@ Runnable.prototype.retries = function (n) {
156156
};
157157

158158
/**
159-
* Get current retry
159+
* Set or get current retry
160160
*
161161
* @api private
162162
*/
@@ -242,7 +242,7 @@ Runnable.prototype.resetTimeout = function () {
242242
};
243243

244244
/**
245-
* Whitelist a list of globals for this test run.
245+
* Set or get a list of whitelisted globals for this test run.
246246
*
247247
* @api private
248248
* @param {string[]} globals

lib/suite.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Suite.prototype.clone = function () {
9292
};
9393

9494
/**
95-
* Set timeout `ms` or short-hand such as "2s".
95+
* Set or get timeout `ms` or short-hand such as "2s".
9696
*
9797
* @api private
9898
* @param {number|string} ms
@@ -114,7 +114,7 @@ Suite.prototype.timeout = function (ms) {
114114
};
115115

116116
/**
117-
* Set number of times to retry a failed test.
117+
* Set or get number of times to retry a failed test.
118118
*
119119
* @api private
120120
* @param {number|string} n
@@ -130,7 +130,7 @@ Suite.prototype.retries = function (n) {
130130
};
131131

132132
/**
133-
* Set timeout to `enabled`.
133+
* Set or get timeout to `enabled`.
134134
*
135135
* @api private
136136
* @param {boolean} enabled
@@ -146,7 +146,7 @@ Suite.prototype.enableTimeouts = function (enabled) {
146146
};
147147

148148
/**
149-
* Set slow `ms` or short-hand such as "2s".
149+
* Set or get slow `ms` or short-hand such as "2s".
150150
*
151151
* @api private
152152
* @param {number|string} ms
@@ -165,7 +165,7 @@ Suite.prototype.slow = function (ms) {
165165
};
166166

167167
/**
168-
* Sets whether to bail after first error.
168+
* Sets or gets whether to bail after first error.
169169
*
170170
* @api private
171171
* @param {boolean} bail

0 commit comments

Comments
 (0)