mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-24 20:03:41 +03:00
0ce9c8ffcd
* test(useApiKeyConfig): add unit tests * test(BackendConfig): add unit tests
32 lines
711 B
TypeScript
32 lines
711 B
TypeScript
import { renderHook } from "@testing-library/react";
|
|
import { describe, expect, it, vi } from "vitest";
|
|
|
|
import { useAuthApi } from "../useAuthApi";
|
|
|
|
const axiosPostMock = vi.fn(() => ({
|
|
data: {
|
|
api_key: "",
|
|
},
|
|
}));
|
|
|
|
vi.mock("@/lib/hooks", () => ({
|
|
useAxios: () => ({
|
|
axiosInstance: {
|
|
post: axiosPostMock,
|
|
},
|
|
}),
|
|
}));
|
|
|
|
describe("useAuthApi", () => {
|
|
it("should call createApiKey with the correct parameters", async () => {
|
|
const {
|
|
result: {
|
|
current: { createApiKey },
|
|
},
|
|
} = renderHook(() => useAuthApi());
|
|
await createApiKey();
|
|
expect(axiosPostMock).toHaveBeenCalledTimes(1);
|
|
expect(axiosPostMock).toHaveBeenCalledWith("/api-key");
|
|
});
|
|
});
|