File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
src/components/NavigationBar/tabs Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+
3
+ import { render } from '@testing-library/react' ;
4
+
5
+ import useIndexOfLastVisibleChild from './useIndexOfLastVisibleChild' ;
6
+
7
+ describe ( 'useIndexOfLastVisibleChild' , ( ) => {
8
+ let observeMock ;
9
+ let disconnectMock ;
10
+
11
+ beforeAll ( ( ) => {
12
+ observeMock = jest . fn ( ) ;
13
+ disconnectMock = jest . fn ( ) ;
14
+ global . ResizeObserver = class {
15
+ observe = observeMock ;
16
+
17
+ disconnect = disconnectMock ;
18
+ } ;
19
+ } ) ;
20
+
21
+ afterAll ( ( ) => {
22
+ delete global . ResizeObserver ;
23
+ } ) ;
24
+
25
+ it ( 'runs effect and cleanup (covers L52–53, L66)' , ( ) => {
26
+ const TestComponent = ( ) => {
27
+ const [ , containerRef ] = useIndexOfLastVisibleChild ( ) ;
28
+ return < div ref = { containerRef } /> ;
29
+ } ;
30
+
31
+ const { unmount } = render ( < TestComponent /> ) ;
32
+ unmount ( ) ;
33
+
34
+ expect ( disconnectMock ) . toHaveBeenCalled ( ) ;
35
+ } ) ;
36
+ } ) ;
You can’t perform that action at this time.
0 commit comments