mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: migrate some tests from jest to vitest (#20568)
This commit is contained in:
@@ -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();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user