forked from codeit-plake/plake
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.setup.ts
More file actions
84 lines (75 loc) · 2.05 KB
/
jest.setup.ts
File metadata and controls
84 lines (75 loc) · 2.05 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import "@testing-library/jest-dom";
// Shadcn Select component를 열기 위해 필요한 mock
class MockPointerEvent extends Event {
button: number;
ctrlKey: boolean;
pointerType: string;
constructor(type: string, props: PointerEventInit) {
super(type, props);
this.button = props.button || 0;
this.ctrlKey = props.ctrlKey || false;
this.pointerType = props.pointerType || "mouse";
}
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
window.PointerEvent = MockPointerEvent as any;
window.HTMLElement.prototype.scrollIntoView = jest.fn();
window.HTMLElement.prototype.releasePointerCapture = jest.fn();
window.HTMLElement.prototype.hasPointerCapture = jest.fn();
beforeEach(() => {
jest.restoreAllMocks(); // 테스트 전 원래 구현으로 스파이 복원
});
jest.mock("next/navigation", () => ({
...jest.requireActual("next/navigation"),
usePathname: jest.fn(() => "/"),
useRouter: jest.fn(() => ({
push: jest.fn(),
replace: jest.fn(),
back: jest.fn(),
prefetch: jest.fn(),
})),
useSearchParams: jest.fn(() => ({
get: jest.fn(() => null),
getAll: jest.fn(() => []),
forEach: jest.fn(),
entries: jest.fn(() => []),
keys: jest.fn(() => []),
values: jest.fn(() => []),
has: jest.fn(() => false),
})),
}));
jest.mock("next/headers", () => ({
cookies: jest.fn(() => ({
get: jest.fn(),
set: jest.fn(),
delete: jest.fn(),
getAll: jest.fn(() => []),
})),
}));
jest.mock("@/stores/useUserStore", () => ({
__esModule: true,
default: jest.fn(() => ({
user: null,
isLoggedIn: false,
isHydrated: false,
})),
useShallow: jest.fn(fn => fn),
}));
jest.mock("@/stores/useSideBarStore", () => ({
__esModule: true,
default: jest.fn(() => ({
isOpen: false,
})),
useShallow: jest.fn(fn => fn),
}));
jest.mock("swiper/react", () => ({
useSwiper: jest.fn(),
Swiper: jest.fn(),
SwiperSlide: jest.fn(),
Navigation: jest.fn(),
Pagination: jest.fn(),
Scrollbar: jest.fn(),
A11y: jest.fn(),
Autoplay: jest.fn(),
EffectFade: jest.fn(),
}));