quivr/frontend/lib/api/notification/__tests__/useNotificationApi.test.ts
Mamadou DICKO 7cc90ef258
feat: add polling for pending notifications (#1152)
* feat: add notification controller

* feat: add polling logic on pending notifications

* feat: refecth notifications on Feed
2023-09-12 18:00:46 +02:00

29 lines
786 B
TypeScript

import { renderHook } from "@testing-library/react";
import { describe, expect, it, vi } from "vitest";
import { useNotificationApi } from "../useNotificationApi";
const axiosGetMock = vi.fn(() => ({}));
vi.mock("@/lib/hooks", () => ({
useAxios: () => ({
axiosInstance: {
get: axiosGetMock,
},
}),
}));
describe("useNotificationApi", () => {
it("should call getChatNotifications with the correct parameters", async () => {
const chatId = "test-chat-id";
const {
result: {
current: { getChatNotifications },
},
} = renderHook(() => useNotificationApi());
await getChatNotifications(chatId);
expect(axiosGetMock).toHaveBeenCalledTimes(1);
expect(axiosGetMock).toHaveBeenCalledWith(`/notifications/${chatId}`);
});
});