File tree 2 files changed +43
-0
lines changed
2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change 3
3
// expect(element).toHaveTextContent(/react/i)
4
4
// learn more: https://github.com/testing-library/jest-dom
5
5
import '@testing-library/jest-dom' ;
6
+ global . ResizeObserver = jest . fn ( ) . mockImplementation ( ( ) => ( {
7
+ observe : jest . fn ( ) ,
8
+ unobserve : jest . fn ( ) ,
9
+ disconnect : jest . fn ( ) ,
10
+ } ) ) ;
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import { customRender , fireEvent , screen , waitFor } from './testUtils' ;
3
+ import { Sidebar } from '../src/components/Sidebar' ;
4
+ import { Menu } from '../src/components/Menu' ;
5
+ import { SubMenu } from '../src/components/SubMenu' ;
6
+ import { menuClasses , sidebarClasses } from '../src/utils/utilityClasses' ;
7
+
8
+ describe ( 'Menu' , ( ) => {
9
+ it ( 'should display popper on submenu click when collapsed' , async ( ) => {
10
+ customRender (
11
+ < Sidebar defaultCollapsed >
12
+ < Menu >
13
+ < SubMenu label = "Charts" > </ SubMenu >
14
+ </ Menu >
15
+ </ Sidebar > ,
16
+ ) ;
17
+
18
+ const submenuButton = screen . getByTestId ( `${ menuClasses . button } -test-id` ) ;
19
+ const submenuContent = screen . queryByTestId ( `${ menuClasses . subMenuContent } -test-id` ) ;
20
+
21
+ expect ( submenuButton ) . toBeInTheDocument ( ) ;
22
+ expect ( submenuContent ) . toBeInTheDocument ( ) ;
23
+
24
+ fireEvent . click ( submenuButton ) ;
25
+
26
+ const sidebarElem = screen . getByTestId ( `${ sidebarClasses . root } -test-id` ) ;
27
+ expect ( sidebarElem ) . toHaveClass ( sidebarClasses . root ) ;
28
+ expect ( sidebarElem ) . toHaveStyle ( {
29
+ width : '80px' ,
30
+ 'min-width' : '80px' ,
31
+ } ) ;
32
+ await waitFor ( ( ) =>
33
+ expect ( submenuContent ) . toHaveStyle ( {
34
+ visibility : 'visible' ,
35
+ } ) ,
36
+ ) ;
37
+ } ) ;
38
+ } ) ;
You can’t perform that action at this time.
0 commit comments