1
- import React from 'react' ;
1
+ import React from 'react' ;
2
2
import SlidePane from '../index' ;
3
3
import { render } from '@testing-library/react' ;
4
4
import '@testing-library/jest-dom/extend-expect' ;
5
5
6
-
7
6
describe ( 'test SlidePane ' , ( ) => {
8
7
const expectValues = {
9
- children :( < div >
8
+ children : ( < div >
10
9
< h1 > success</ h1 >
11
10
</ div > ) ,
12
- visible :true ,
13
- style :{ color :'red' , background :'#FF7C12' } ,
11
+ visible : true ,
12
+ style : { color : 'red' , background : '#FF7C12' }
14
13
}
15
14
test ( 'should render correct' , ( ) => {
16
- const { container, getByTestId} = render ( < SlidePane
17
- children = { expectValues . children }
18
- visible = { expectValues . visible }
15
+ const { container, getByTestId } = render ( < SlidePane
16
+ children = { expectValues . children }
17
+ visible = { expectValues . visible }
19
18
style = { expectValues . style }
20
- /> )
19
+ /> )
21
20
expect ( container . firstChild ) . toHaveStyle ( expectValues . style ) ;
22
21
const oDiv = getByTestId ( 'slidepane_container' ) ;
23
22
expect ( oDiv ) . not . toBeNull ( ) ;
24
- expect ( oDiv ) . toHaveStyle ( 'display:block' ) ;
25
- expect ( oDiv . innerHTML ) . toEqual ( " <div><h1>success</h1></div>" ) ;
23
+ expect ( oDiv ) . toBeVisible ( ) ;
24
+ expect ( oDiv . innerHTML ) . toEqual ( ' <div><h1>success</h1></div>' ) ;
26
25
expect ( container ) . toMatchSnapshot ( ) ;
27
26
} )
28
27
test ( 'should be invisible' , ( ) => {
29
- const { getByTestId} = render ( < SlidePane
30
- children = { expectValues . children }
31
- visible = { false }
32
- /> )
33
- const oDiv = getByTestId ( 'slidepane_container' ) ;
34
- expect ( oDiv ) . toHaveStyle ( 'display:none' ) ;
35
- } ) }
36
- )
28
+ const { getByTestId } = render ( < SlidePane
29
+ children = { expectValues . children }
30
+ visible = { false }
31
+ /> )
32
+ const oDiv = getByTestId ( 'slidepane_container' ) ;
33
+ expect ( oDiv ) . not . toBeVisible ( ) ;
34
+ } )
35
+ }
36
+ )
0 commit comments