-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.setup.ts
44 lines (40 loc) · 1.01 KB
/
jest.setup.ts
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
38
39
40
41
42
43
44
import "@testing-library/jest-dom";
import "@testing-library/jest-dom/jest-globals";
import messages from "./src/messages/en.json";
jest.mock("react-hook-form", () => ({
useForm: jest.fn().mockReturnValue({
control: {
register: jest.fn(),
unregister: jest.fn(),
setValue: jest.fn(),
getValues: jest.fn().mockReturnValue({}),
formState: {
errors: {}
}
}
}),
useController: jest.fn()
}));
jest.mock("next-intl", () => ({
useTranslations: () => (id: string) => id
// useTranslations: (key: keyof typeof messages) => {
// const t = (phrase: keyof (typeof messages)[key]) => messages[key][phrase];
// t.rich = (key: string, vars: Record<string, unknown>) => {
// return vars ? `${key} ${JSON.stringify(vars)}` : key;
// };
// return t;
// }
}));
jest.mock("next/navigation", () => ({
useRouter() {
return {
push: jest.fn()
};
},
usePathname() {
return "/";
},
useParams() {
return { locale: "en" };
}
}));