Skip to content

Commit

Permalink
Merge pull request #395 from jamestalmage/assertions-return-promises
Browse files Browse the repository at this point in the history
Regression: Assertions should return promises.
  • Loading branch information
sindresorhus committed Dec 31, 2015
2 parents c7ce760 + 821436a commit b04d004
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ Test.prototype._publicApi = function () {
return Promise.reject(err);
});
self._assert(promise);
return promise;
}

var enhanced = enhanceAssert({
Expand Down
16 changes: 16 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
var test = require('tap').test;
var Promise = global.Promise = require('bluebird');
var delay = require('delay');
var isPromise = require('is-promise');
var _ava = require('../lib/test');

function ava() {
Expand Down Expand Up @@ -469,3 +470,18 @@ test('number of assertions doesn\'t match plan when the test exits, but before a
t.end();
});
});

test('assertions return promises', function (t) {
t.plan(4);
ava(function (a) {
a.plan(4);
t.ok(isPromise(a.throws(Promise.reject(new Error('foo')))));
t.ok(isPromise(a.throws(function () {
throw new Error('bar');
})));
t.ok(isPromise(a.doesNotThrow(Promise.resolve(true))));
t.ok(isPromise(a.true(true)));
}).run().then(function () {
t.end();
});
});

0 comments on commit b04d004

Please sign in to comment.