File tree 1 file changed +37
-0
lines changed
packages/analytics-js-common/__tests__/utilities/retryQueue
1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -709,6 +709,43 @@ describe('RetryQueue', () => {
709
709
) ;
710
710
} ) ;
711
711
712
+ it ( 'should take over an in-progress task (which is an object) if a queue is abandoned' , ( ) => {
713
+ // set up a fake queue
714
+ const foundQueue = new Store ( {
715
+ name : 'test' ,
716
+ id : 'fake-id' ,
717
+ validKeys : QueueStatuses ,
718
+ } ) ;
719
+ foundQueue . set ( 'ack' , - 15000 ) ;
720
+
721
+ // Older in progress queues are stored as an object
722
+ foundQueue . set ( 'inProgress' , {
723
+ id1 : {
724
+ item : 'a' ,
725
+ time : 0 ,
726
+ attemptNumber : 0 ,
727
+ } ,
728
+ } ) ;
729
+
730
+ // wait for the queue to expire
731
+ jest . advanceTimersByTime ( DEFAULT_RECLAIM_TIMEOUT_MS ) ;
732
+
733
+ queue . start ( ) ;
734
+
735
+ // wait long enough for the other queue to expire and be reclaimed
736
+ jest . advanceTimersByTime ( DEFAULT_RECLAIM_TIMER_MS + DEFAULT_RECLAIM_WAIT_MS * 2 ) ;
737
+
738
+ expect ( queue . processQueueCb ) . toHaveBeenCalledTimes ( 1 ) ;
739
+ expect ( queue . processQueueCb ) . toHaveBeenCalledWith (
740
+ 'a' ,
741
+ expect . any ( Function ) ,
742
+ 1 ,
743
+ 2 ,
744
+ true ,
745
+ true ,
746
+ ) ;
747
+ } ) ;
748
+
712
749
it ( 'should take over multiple tasks if a queue is abandoned' , ( ) => {
713
750
// set up a fake queue
714
751
const foundQueue = new Store ( {
You can’t perform that action at this time.
0 commit comments