We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 8f57232 + 03b86a2 commit 19534fdCopy full SHA for 19534fd
packages/core/src/hooks/useWindowScroll/useWindowScroll.test.ts
@@ -0,0 +1,23 @@
1
+import { renderHook } from '@testing-library/react';
2
+
3
+import { useWindowScroll } from './useWindowScroll';
4
5
+const mockScrollTo = vi.fn();
6
7
+beforeAll(() => {
8
+ vi.stubGlobal('scrollTo', mockScrollTo);
9
+});
10
11
+afterAll(() => {
12
+ vi.unstubAllGlobals();
13
14
15
+it('Should use window scroll', () => {
16
+ const { result } = renderHook(() => useWindowScroll());
17
18
+ expect(result.current.value).toEqual({ x: 0, y: 0 });
19
20
+ result.current.scrollTo({ x: 100, y: 100 });
21
22
+ expect(globalThis.scrollTo).toBeCalledWith({ left: 100, top: 100, behavior: 'smooth' });
23
0 commit comments