Skip to content

Commit c9be93a

Browse files
committed
test: improve code coverage
1 parent ab24ef7 commit c9be93a

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

packages/analytics-js-common/__tests__/utilities/retryQueue/RetryQueue.test.ts

+37
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,43 @@ describe('RetryQueue', () => {
709709
);
710710
});
711711

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+
712749
it('should take over multiple tasks if a queue is abandoned', () => {
713750
// set up a fake queue
714751
const foundQueue = new Store({

0 commit comments

Comments
 (0)