@@ -4,13 +4,6 @@ var Promise = global.Promise = require('bluebird');
4
4
var delay = require ( 'delay' ) ;
5
5
var _ava = require ( '../lib/test' ) ;
6
6
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
-
14
7
function ava ( ) {
15
8
var t = _ava . apply ( null , arguments ) ;
16
9
t . metadata = { callback : false } ;
@@ -365,7 +358,7 @@ test('throws and doesNotThrow work with promises', function (t) {
365
358
var asyncCalled = false ;
366
359
ava ( function ( a ) {
367
360
a . plan ( 2 ) ;
368
- a . throws ( delayReject ( 10 , 'foo' ) , 'foo' ) ;
361
+ a . throws ( delay . reject ( 10 , new Error ( 'foo' ) ) , 'foo' ) ;
369
362
a . doesNotThrow ( delay ( 20 ) . then ( function ( ) {
370
363
asyncCalled = true ;
371
364
} ) ) ;
@@ -394,7 +387,7 @@ test('waits for t.throws to resolve after t.end is called', function (t) {
394
387
test ( 'waits for t.throws to reject after t.end is called' , function ( t ) {
395
388
ava . cb ( function ( a ) {
396
389
a . plan ( 1 ) ;
397
- a . throws ( delayReject ( 10 , 'foo' ) , 'foo' ) ;
390
+ a . throws ( delay . reject ( 10 , new Error ( 'foo' ) ) , 'foo' ) ;
398
391
a . end ( ) ;
399
392
} ) . run ( ) . then ( function ( a ) {
400
393
t . ifError ( a . assertError ) ;
@@ -420,7 +413,7 @@ test('waits for t.throws to resolve after the promise returned from the test res
420
413
test ( 'waits for t.throws to reject after the promise returned from the test resolves' , function ( t ) {
421
414
ava ( function ( a ) {
422
415
a . plan ( 1 ) ;
423
- a . throws ( delayReject ( 10 , 'foo' ) , 'foo' ) ;
416
+ a . throws ( delay . reject ( 10 , new Error ( 'foo' ) ) , 'foo' ) ;
424
417
return Promise . resolve ( ) ;
425
418
} ) . run ( ) . then ( function ( a ) {
426
419
t . ifError ( a . assertError ) ;
@@ -434,7 +427,7 @@ test('multiple resolving and rejecting promises passed to t.throws/t.doesNotThro
434
427
ava ( function ( a ) {
435
428
a . plan ( 6 ) ;
436
429
for ( var i = 0 ; i < 3 ; ++ i ) {
437
- a . throws ( delayReject ( 10 , 'foo' ) , 'foo' ) ;
430
+ a . throws ( delay . reject ( 10 , new Error ( 'foo' ) ) , 'foo' ) ;
438
431
a . doesNotThrow ( delay ( 10 ) , 'foo' ) ;
439
432
}
440
433
} ) . run ( ) . then ( function ( a ) {
@@ -448,7 +441,7 @@ test('multiple resolving and rejecting promises passed to t.throws/t.doesNotThro
448
441
test ( 'number of assertions matches t.plan when the test exits, but before all promises resolve another is added' , function ( t ) {
449
442
ava ( function ( a ) {
450
443
a . plan ( 2 ) ;
451
- a . throws ( delayReject ( 10 , 'foo' ) , 'foo' ) ;
444
+ a . throws ( delay . reject ( 10 , new Error ( 'foo' ) ) , 'foo' ) ;
452
445
a . doesNotThrow ( delay ( 10 ) , 'foo' ) ;
453
446
setTimeout ( function ( ) {
454
447
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
464
457
test ( 'number of assertions doesn\'t match plan when the test exits, but before all promises resolve another is added' , function ( t ) {
465
458
ava ( function ( a ) {
466
459
a . plan ( 3 ) ;
467
- a . throws ( delayReject ( 10 , 'foo' ) , 'foo' ) ;
460
+ a . throws ( delay . reject ( 10 , new Error ( 'foo' ) ) , 'foo' ) ;
468
461
a . doesNotThrow ( delay ( 10 ) , 'foo' ) ;
469
462
setTimeout ( function ( ) {
470
463
a . throws ( Promise . reject ( new Error ( 'foo' ) ) , 'foo' ) ;
0 commit comments