test(provider-activity): restore real timers

This commit is contained in:
Peter Steinberger
2026-01-08 23:52:07 +01:00
parent 69f8af530d
commit 769b76cd40

View File

@@ -1,4 +1,4 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import {
getProviderActivity,
@@ -13,6 +13,10 @@ describe("provider activity", () => {
vi.setSystemTime(new Date("2026-01-08T00:00:00Z"));
});
afterEach(() => {
vi.useRealTimers();
});
it("records inbound/outbound separately", () => {
recordProviderActivity({ provider: "telegram", direction: "inbound" });
vi.advanceTimersByTime(1000);
@@ -35,13 +39,17 @@ describe("provider activity", () => {
direction: "inbound",
at: 2,
});
expect(getProviderActivity({ provider: "whatsapp", accountId: "a" })).toEqual({
inboundAt: 1,
outboundAt: null,
});
expect(getProviderActivity({ provider: "whatsapp", accountId: "b" })).toEqual({
inboundAt: 2,
outboundAt: null,
});
expect(getProviderActivity({ provider: "whatsapp", accountId: "a" })).toEqual(
{
inboundAt: 1,
outboundAt: null,
},
);
expect(getProviderActivity({ provider: "whatsapp", accountId: "b" })).toEqual(
{
inboundAt: 2,
outboundAt: null,
},
);
});
});