Skip to content

Commit 2303c66

Browse files
makepanicboneskull
authored andcommitted
normalize getters and setters (fixes #3058)
1 parent da901da commit 2303c66

File tree

4 files changed

+31
-13
lines changed

4 files changed

+31
-13
lines changed

lib/context.js

Lines changed: 9 additions & 3 deletions
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
@@ -51,18 +51,24 @@ Context.prototype.timeout = function (ms) {
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

Lines changed: 5 additions & 5 deletions
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

Lines changed: 5 additions & 5 deletions
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+
* Set or get whether to bail after first error.
169169
*
170170
* @api private
171171
* @param {boolean} bail

test/unit/context.spec.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,18 @@ describe('methods', function () {
7373
});
7474
});
7575

76+
describe('slow()', function () {
77+
it('should return the slow', function () {
78+
expect(this.slow()).to.equal(75);
79+
});
80+
});
81+
82+
describe('enableTimeouts()', function () {
83+
it('should return the enableTimeouts', function () {
84+
expect(this.enableTimeouts()).to.equal(true);
85+
});
86+
});
87+
7688
describe('retries', function () {
7789
it('should return the number of retries', function () {
7890
expect(this.retries()).to.equal(-1);

0 commit comments

Comments
 (0)