import { beforeEach, describe, expect, it, vi } from "vitest"; const apiGet = vi.fn(); const apiPost = vi.fn(); vi.mock("./axios", () => ({ apiGet, apiPost })); describe("general notification API", () => { beforeEach(() => vi.clearAllMocks()); it("loads an uncached recipient feed and updates read state", async () => { const { listGeneralNotifications, markAllGeneralNotificationsRead, markGeneralNotificationRead, } = await import("./notifications"); listGeneralNotifications("study-1", 8); markGeneralNotificationRead("study-1", "notification-1"); markAllGeneralNotificationsRead("study-1"); expect(apiGet).toHaveBeenCalledWith( "/api/v1/studies/study-1/notifications/feed", { params: { limit: 8 }, cache: false, disableRequestDedupe: true }, ); expect(apiPost).toHaveBeenCalledWith( "/api/v1/studies/study-1/notifications/notification-1/read", ); expect(apiPost).toHaveBeenCalledWith( "/api/v1/studies/study-1/notifications/read-all", ); }); });