Skip to content

Commit 8b4fc5a

Browse files
committed
Add some tests regarding async assertions and tests that return promises
1 parent f51424a commit 8b4fc5a

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test/test.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,3 +402,29 @@ test('t.end is called when a promise passed to t.throws hasn\'t rejected yet', f
402402
t.end();
403403
});
404404
});
405+
406+
test('test returns a promise that resolves before a promise passed to t.throws resolves', function (t) {
407+
ava(function (a) {
408+
a.plan(1);
409+
a.doesNotThrow(delay(Promise.resolve(), 10), 'foo');
410+
return Promise.resolve();
411+
}).run().then(function (a) {
412+
t.ifError(a.assertError);
413+
t.is(a.planCount, 1);
414+
t.is(a.assertCount, 1);
415+
t.end();
416+
});
417+
});
418+
419+
test('test returns a promise that resolves before a promise passed to t.throws rejects', function (t) {
420+
ava(function (a) {
421+
a.plan(1);
422+
a.throws(delay(Promise.reject(new Error('foo')), 10), 'foo');
423+
return Promise.resolve();
424+
}).run().then(function (a) {
425+
t.ifError(a.assertError);
426+
t.is(a.planCount, 1);
427+
t.is(a.assertCount, 1);
428+
t.end();
429+
});
430+
});

0 commit comments

Comments
 (0)