Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("sends multiple events", async () => {
setup();
const e1 = { component: "Page1" };
const e2 = { component: "Page2" };
sendScheduler.enqueue(e1);
sendScheduler.enqueue(e2);
await delayAndAdvance(1000);
expect(global.window.tealiumTrack).toHaveBeenCalledTimes(2);
});
setup();
const timer = delay(2 * 60 * 1000);
const e1 = { component: "Page1" };
const e2 = { component: "Page2" };
global.window.tealiumTrack = () => {
advance(1 * 60 * 1000);
};
jest.spyOn(global.window, "tealiumTrack");
sendScheduler.enqueue(e1);
sendScheduler.enqueue(e2);
await delayAndAdvance(0);
await timer;
expect(global.window.tealiumTrack).toHaveBeenCalledTimes(2);
});
});