File tree 1 file changed +31
-0
lines changed
1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -428,3 +428,34 @@ test('test returns a promise that resolves before a promise passed to t.throws r
428
428
t . end ( ) ;
429
429
} ) ;
430
430
} ) ;
431
+
432
+ test ( 'multiple resolving and rejecting promises passed to t.throws/t.doesNotThrow' , function ( t ) {
433
+ ava ( function ( a ) {
434
+ a . plan ( 6 ) ;
435
+ for ( var i = 0 ; i < 3 ; ++ i ) {
436
+ a . throws ( delay ( Promise . reject ( new Error ( 'foo' ) ) , 10 ) , 'foo' ) ;
437
+ a . doesNotThrow ( delay ( Promise . resolve ( ) , 10 ) , 'foo' ) ;
438
+ }
439
+ } ) . run ( ) . then ( function ( a ) {
440
+ t . ifError ( a . assertError ) ;
441
+ t . is ( a . planCount , 6 ) ;
442
+ t . is ( a . assertCount , 6 ) ;
443
+ t . end ( ) ;
444
+ } ) ;
445
+ } ) ;
446
+
447
+ test ( 'number of assertions matches t.plan when the test exits, but before all promises resolve another is added' , function ( t ) {
448
+ ava ( function ( a ) {
449
+ a . plan ( 2 ) ;
450
+ a . throws ( delay ( Promise . reject ( new Error ( 'foo' ) ) , 10 ) , 'foo' ) ;
451
+ a . doesNotThrow ( delay ( Promise . resolve ( ) , 10 ) , 'foo' ) ;
452
+ setTimeout ( function ( ) {
453
+ a . throws ( Promise . reject ( new Error ( 'foo' ) ) , 'foo' ) ;
454
+ } , 5 ) ;
455
+ } ) . run ( ) . catch ( function ( err ) {
456
+ t . is ( err . operator , 'plan' ) ;
457
+ t . is ( err . actual , 3 ) ;
458
+ t . is ( err . expected , 2 ) ;
459
+ t . end ( ) ;
460
+ } )
461
+ } ) ;
You can’t perform that action at this time.
0 commit comments