chore: migrate some tests from jest to vitest (#20568)

This commit is contained in:
ケイラ
2025-10-31 15:15:30 -06:00
committed by GitHub
parent 7ae3fdc749
commit c627a68e96
77 changed files with 629 additions and 375 deletions
@@ -1,33 +0,0 @@
import { createTestQueryClient } from "testHelpers/renderHelpers";
import { renderHook } from "@testing-library/react";
import type { FC, PropsWithChildren } from "react";
import { QueryClientProvider } from "react-query";
import { AuthProvider, useAuthContext } from "./AuthProvider";
const Wrapper: FC<PropsWithChildren> = ({ children }) => {
return (
<QueryClientProvider client={createTestQueryClient()}>
<AuthProvider>{children}</AuthProvider>
</QueryClientProvider>
);
};
describe("useAuth", () => {
it("throws an error if it is used outside of <AuthProvider />", () => {
jest.spyOn(console, "error").mockImplementation(() => {});
expect(() => {
renderHook(() => useAuthContext());
}).toThrow("useAuth should be used inside of <AuthProvider />");
jest.restoreAllMocks();
});
it("returns AuthContextValue when used inside of <AuthProvider />", () => {
expect(() => {
renderHook(() => useAuthContext(), {
wrapper: Wrapper,
});
}).not.toThrow();
});
});