-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathuseValidatePasswordMutation.test.tsx
More file actions
37 lines (31 loc) · 1.07 KB
/
useValidatePasswordMutation.test.tsx
File metadata and controls
37 lines (31 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import React from "react";
import { describe, expect, test, beforeEach, afterEach } from "vitest";
import { renderHook, act, waitFor } from "@testing-library/react";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { useValidatePasswordMutation } from "./useValidatePasswordMutation";
import { auth, wipeAuth } from "~/testing-utils";
const queryClient = new QueryClient({
defaultOptions: {
queries: { retry: false },
mutations: { retry: false },
},
});
const wrapper = ({ children }: { children: React.ReactNode }) => (
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
);
describe("useValidatePasswordMutation", () => {
const validPassword = "ValidPassword123!";
const invalidPassword = "short";
beforeEach(async () => {
queryClient.clear();
await wipeAuth();
});
test("validates a password successfully", async () => {
const { result } = renderHook(() => useValidatePasswordMutation(auth), {
wrapper,
});
act(() => {
result.current.mutate(validPassword);
});
});
});