Skip to content

Commit

Permalink
Use delay.reject
Browse files Browse the repository at this point in the history
  • Loading branch information
ariporad committed Dec 25, 2015
1 parent 716b37d commit 0063076
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@
},
"devDependencies": {
"coveralls": "^2.11.4",
"delay": "^1.3.0",
"signal-exit": "^2.1.2",
"sinon": "^1.17.2",
"source-map-fixtures": "^0.4.0",
"tap": "^2.2.1",
"delay": "^1.2.0",
"xo": "*",
"zen-observable": "^0.1.6"
},
Expand Down
19 changes: 6 additions & 13 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@ var Promise = global.Promise = require('bluebird');
var delay = require('delay');
var _ava = require('../lib/test');

// This is a helper some boilerplate for testing `t.throws`
function delayReject(ms, message) {
return delay(ms).then(function () {
throw new Error(message);
});
}

function ava() {
var t = _ava.apply(null, arguments);
t.metadata = {callback: false};
Expand Down Expand Up @@ -365,7 +358,7 @@ test('throws and doesNotThrow work with promises', function (t) {
var asyncCalled = false;
ava(function (a) {
a.plan(2);
a.throws(delayReject(10, 'foo'), 'foo');
a.throws(delay.reject(10, new Error('foo')), 'foo');
a.doesNotThrow(delay(20).then(function () {
asyncCalled = true;
}));
Expand Down Expand Up @@ -394,7 +387,7 @@ test('waits for t.throws to resolve after t.end is called', function (t) {
test('waits for t.throws to reject after t.end is called', function (t) {
ava.cb(function (a) {
a.plan(1);
a.throws(delayReject(10, 'foo'), 'foo');
a.throws(delay.reject(10, new Error('foo')), 'foo');
a.end();
}).run().then(function (a) {
t.ifError(a.assertError);
Expand All @@ -420,7 +413,7 @@ test('waits for t.throws to resolve after the promise returned from the test res
test('waits for t.throws to reject after the promise returned from the test resolves', function (t) {
ava(function (a) {
a.plan(1);
a.throws(delayReject(10, 'foo'), 'foo');
a.throws(delay.reject(10, new Error('foo')), 'foo');
return Promise.resolve();
}).run().then(function (a) {
t.ifError(a.assertError);
Expand All @@ -434,7 +427,7 @@ test('multiple resolving and rejecting promises passed to t.throws/t.doesNotThro
ava(function (a) {
a.plan(6);
for (var i = 0; i < 3; ++i) {
a.throws(delayReject(10, 'foo'), 'foo');
a.throws(delay.reject(10, new Error('foo')), 'foo');
a.doesNotThrow(delay(10), 'foo');
}
}).run().then(function (a) {
Expand All @@ -448,7 +441,7 @@ test('multiple resolving and rejecting promises passed to t.throws/t.doesNotThro
test('number of assertions matches t.plan when the test exits, but before all promises resolve another is added', function (t) {
ava(function (a) {
a.plan(2);
a.throws(delayReject(10, 'foo'), 'foo');
a.throws(delay.reject(10, new Error('foo')), 'foo');
a.doesNotThrow(delay(10), 'foo');
setTimeout(function () {
a.throws(Promise.reject(new Error('foo')), 'foo');
Expand All @@ -464,7 +457,7 @@ test('number of assertions matches t.plan when the test exits, but before all pr
test('number of assertions doesn\'t match plan when the test exits, but before all promises resolve another is added', function (t) {
ava(function (a) {
a.plan(3);
a.throws(delayReject(10, 'foo'), 'foo');
a.throws(delay.reject(10, new Error('foo')), 'foo');
a.doesNotThrow(delay(10), 'foo');
setTimeout(function () {
a.throws(Promise.reject(new Error('foo')), 'foo');
Expand Down

0 comments on commit 0063076

Please sign in to comment.