@@ -18,6 +18,32 @@ QUnit.test('scheduleOnce', function(assert) {
18
18
} ) ;
19
19
} ) ;
20
20
21
+ QUnit . test ( 'cancelling does not affect future scheduleOnce calls' , function ( assert ) {
22
+ assert . expect ( 5 ) ;
23
+
24
+ let bb = new Backburner ( [ 'queueName' ] ) ;
25
+ const f1Calls : string [ ] = [ ] ;
26
+ const f2Calls : string [ ] = [ ] ;
27
+ const f3Calls : string [ ] = [ ] ;
28
+ const f1 = ( arg : string ) => f1Calls . push ( arg ) ;
29
+ const f2 = ( arg : string ) => f2Calls . push ( arg ) ;
30
+ const f3 = ( arg : string ) => f3Calls . push ( arg ) ;
31
+
32
+ bb . run ( ( ) => {
33
+ const toCancel = bb . scheduleOnce ( 'queueName' , null , f1 , 'f1 cancelled schedule' ) ;
34
+ bb . scheduleOnce ( 'queueName' , null , f2 , 'f2 first schedule' ) ;
35
+ bb . scheduleOnce ( 'queueName' , null , f3 , 'f3 first schedule' ) ;
36
+ bb . cancel ( toCancel ) ;
37
+ bb . scheduleOnce ( 'queueName' , null , f2 , 'f2 second schedule' ) ;
38
+ } ) ;
39
+
40
+ assert . equal ( f1Calls . length , 0 , 'f1 was not called' )
41
+ assert . equal ( f2Calls . length , 1 , 'f2 was called once' )
42
+ assert . equal ( f3Calls . length , 1 , 'f3 was called once' )
43
+ assert . deepEqual ( f2Calls , [ 'f2 second schedule' ] , 'f2 received the correct argument' )
44
+ assert . deepEqual ( f3Calls , [ 'f3 first schedule' ] , 'f3 received the correct argument' )
45
+ } ) ;
46
+
21
47
QUnit . test ( 'setTimeout' , function ( assert ) {
22
48
assert . expect ( 5 ) ;
23
49
let done = assert . async ( ) ;
0 commit comments