Skip to content

Commit f2c3b5a

Browse files
[FSSDK-11003] new test addition for event processor
1 parent bad40b4 commit f2c3b5a

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

lib/event_processor/batch_event_processor.spec.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ describe('QueueingEventProcessor', async () => {
9494
await expect(processor.onRunning()).resolves.not.toThrow();
9595
});
9696

97-
it('should start dispatchRepeater and failedEventRepeater', () => {
97+
it('should start failedEventRepeater', () => {
9898
const eventDispatcher = getMockDispatcher();
9999
const dispatchRepeater = getMockRepeater();
100100
const failedEventRepeater = getMockRepeater();
@@ -107,7 +107,6 @@ describe('QueueingEventProcessor', async () => {
107107
});
108108

109109
processor.start();
110-
expect(dispatchRepeater.start).toHaveBeenCalledOnce();
111110
expect(failedEventRepeater.start).toHaveBeenCalledOnce();
112111
});
113112

@@ -175,6 +174,25 @@ describe('QueueingEventProcessor', async () => {
175174
expect(eventDispatcher.dispatchEvent).toHaveBeenCalledTimes(0);
176175
});
177176

177+
it('should start the dispatchRepeater if it is not running', async () => {
178+
const eventDispatcher = getMockDispatcher();
179+
const dispatchRepeater = getMockRepeater();
180+
181+
const processor = new BatchEventProcessor({
182+
eventDispatcher,
183+
dispatchRepeater,
184+
batchSize: 100,
185+
});
186+
187+
processor.start();
188+
await processor.onRunning();
189+
190+
const event = createImpressionEvent('id-1');
191+
await processor.process(event);
192+
193+
expect(dispatchRepeater.start).toHaveBeenCalledOnce();
194+
});
195+
178196
it('should dispatch events if queue is full and clear queue', async () => {
179197
const eventDispatcher = getMockDispatcher();
180198
const mockDispatch: MockInstance<typeof eventDispatcher.dispatchEvent> = eventDispatcher.dispatchEvent;

0 commit comments

Comments
 (0)