We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents c9ed9fd + d2d77b6 commit 30c733aCopy full SHA for 30c733a
src/hooks/useInfiniteScroll.spec.tsx
@@ -0,0 +1,23 @@
1
+import { fireEvent, renderHook } from "@testing-library/react";
2
+import useInfiniteScroll from "./useInfiniteScroll";
3
+
4
+describe("useInfiniteScroll", () => {
5
+ it("스크롤을 끝까지 내렸을 때 fetchNextPage 호출 확인", () => {
6
+ const fetchNextPage = jest.fn();
7
+ renderHook(() => useInfiniteScroll(fetchNextPage));
8
9
+ Object.defineProperty(window, "scrollY", {
10
+ value: 0,
11
+ });
12
+ Object.defineProperty(document.documentElement, "offsetHeight", {
13
+ value: 3000,
14
15
+ // 스크롤을 끝까지 내리지 않음
16
+ fireEvent.scroll(window);
17
+ // 스크롤을 끝까지 내림
18
+ window.scrollY = 3000;
19
20
21
+ expect(fetchNextPage).toHaveBeenCalledTimes(1);
22
23
+});
0 commit comments