How to use the @times-components/utils/faketime.delay function in @times-components/utils

To help you get started, we’ve selected a few @times-components/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github newsuk / times-components / packages / tealium / __tests__ / shared.js View on Github external
it("sends more events if they cannot be sent in time", async () => {
        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);