Skip to content

Commit 0063076

Browse files
committed
Use delay.reject
1 parent 716b37d commit 0063076

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,11 @@
120120
},
121121
"devDependencies": {
122122
"coveralls": "^2.11.4",
123+
"delay": "^1.3.0",
123124
"signal-exit": "^2.1.2",
124125
"sinon": "^1.17.2",
125126
"source-map-fixtures": "^0.4.0",
126127
"tap": "^2.2.1",
127-
"delay": "^1.2.0",
128128
"xo": "*",
129129
"zen-observable": "^0.1.6"
130130
},

test/test.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@ var Promise = global.Promise = require('bluebird');
44
var delay = require('delay');
55
var _ava = require('../lib/test');
66

7-
// This is a helper some boilerplate for testing `t.throws`
8-
function delayReject(ms, message) {
9-
return delay(ms).then(function () {
10-
throw new Error(message);
11-
});
12-
}
13-
147
function ava() {
158
var t = _ava.apply(null, arguments);
169
t.metadata = {callback: false};
@@ -365,7 +358,7 @@ test('throws and doesNotThrow work with promises', function (t) {
365358
var asyncCalled = false;
366359
ava(function (a) {
367360
a.plan(2);
368-
a.throws(delayReject(10, 'foo'), 'foo');
361+
a.throws(delay.reject(10, new Error('foo')), 'foo');
369362
a.doesNotThrow(delay(20).then(function () {
370363
asyncCalled = true;
371364
}));
@@ -394,7 +387,7 @@ test('waits for t.throws to resolve after t.end is called', function (t) {
394387
test('waits for t.throws to reject after t.end is called', function (t) {
395388
ava.cb(function (a) {
396389
a.plan(1);
397-
a.throws(delayReject(10, 'foo'), 'foo');
390+
a.throws(delay.reject(10, new Error('foo')), 'foo');
398391
a.end();
399392
}).run().then(function (a) {
400393
t.ifError(a.assertError);
@@ -420,7 +413,7 @@ test('waits for t.throws to resolve after the promise returned from the test res
420413
test('waits for t.throws to reject after the promise returned from the test resolves', function (t) {
421414
ava(function (a) {
422415
a.plan(1);
423-
a.throws(delayReject(10, 'foo'), 'foo');
416+
a.throws(delay.reject(10, new Error('foo')), 'foo');
424417
return Promise.resolve();
425418
}).run().then(function (a) {
426419
t.ifError(a.assertError);
@@ -434,7 +427,7 @@ test('multiple resolving and rejecting promises passed to t.throws/t.doesNotThro
434427
ava(function (a) {
435428
a.plan(6);
436429
for (var i = 0; i < 3; ++i) {
437-
a.throws(delayReject(10, 'foo'), 'foo');
430+
a.throws(delay.reject(10, new Error('foo')), 'foo');
438431
a.doesNotThrow(delay(10), 'foo');
439432
}
440433
}).run().then(function (a) {
@@ -448,7 +441,7 @@ test('multiple resolving and rejecting promises passed to t.throws/t.doesNotThro
448441
test('number of assertions matches t.plan when the test exits, but before all promises resolve another is added', function (t) {
449442
ava(function (a) {
450443
a.plan(2);
451-
a.throws(delayReject(10, 'foo'), 'foo');
444+
a.throws(delay.reject(10, new Error('foo')), 'foo');
452445
a.doesNotThrow(delay(10), 'foo');
453446
setTimeout(function () {
454447
a.throws(Promise.reject(new Error('foo')), 'foo');
@@ -464,7 +457,7 @@ test('number of assertions matches t.plan when the test exits, but before all pr
464457
test('number of assertions doesn\'t match plan when the test exits, but before all promises resolve another is added', function (t) {
465458
ava(function (a) {
466459
a.plan(3);
467-
a.throws(delayReject(10, 'foo'), 'foo');
460+
a.throws(delay.reject(10, new Error('foo')), 'foo');
468461
a.doesNotThrow(delay(10), 'foo');
469462
setTimeout(function () {
470463
a.throws(Promise.reject(new Error('foo')), 'foo');

0 commit comments

Comments
 (0)