@@ -13,8 +13,9 @@ const props2: IBlockHeaderProps = {
1313 description : '说明文字' ,
1414 addonAfter : < div className = "test-button-after" > 新增按钮</ div > ,
1515 size : 'small' as SizeType ,
16- titleRowClassName : 'test-row-className' ,
17- titleClassName : 'test-title-className' ,
16+ className : 'test__className' ,
17+ style : { height : '100px' } ,
18+ hasBottom : true ,
1819} ;
1920const props3 : IBlockHeaderProps = {
2021 title : 'hover' ,
@@ -44,18 +45,8 @@ describe('test BlockHeader render', () => {
4445 test ( 'should render BlockHeader props default in BlockHeader' , ( ) => {
4546 const { container } = render ( < BlockHeader title = "测试" background /> ) ;
4647 const wrap = container . firstChild ;
47- expect ( wrap ! . firstChild ! . firstChild ! . firstChild ) . toHaveClass ( `${ prefixCls } -addon-before` ) ;
48- fireEvent . click ( document . getElementsByClassName ( `${ prefixCls } -title-row` ) [ 0 ] ) ;
49- } ) ;
50- test ( 'should render BlockHeader with different props' , ( ) => {
51- const { container, getByText } = render ( < BlockHeader { ...props2 } /> ) ;
52- const wrap = container . firstChild ;
53- expect ( wrap ) . toHaveClass ( `${ prefixCls } ` ) ;
54- expect ( wrap ! . firstChild ) . toHaveClass ( `test-row-className` ) ;
55- expect ( getByText ( '标题2' ) ) . toHaveClass ( 'test-title-className' ) ;
56- expect ( getByText ( '说明文字' ) ) . toHaveClass ( `${ prefixCls } -description` ) ;
57- expect ( getByText ( '新增按钮' ) ) . toHaveClass ( `test-button-after` ) ;
58- expect ( getByText ( 'Icon' ) ) . toBeTruthy ( ) ;
48+ expect ( wrap ! . firstChild ! . firstChild ! . firstChild ) . toHaveClass ( 'title__addon-before' ) ;
49+ fireEvent . click ( document . getElementsByClassName ( `${ prefixCls } __title` ) [ 0 ] ) ;
5950 } ) ;
6051 test ( 'should render BlockHeader test click event' , ( ) => {
6152 const onChange = jest . fn ( ) ;
@@ -65,7 +56,7 @@ describe('test BlockHeader render', () => {
6556 </ BlockHeader >
6657 ) ;
6758 expect ( getByText ( '收起' ) ) . toBeTruthy ( ) ;
68- fireEvent . click ( document . getElementsByClassName ( `${ prefixCls } -title-row ` ) [ 0 ] ) ;
59+ fireEvent . click ( document . getElementsByClassName ( `${ prefixCls } __title ` ) [ 0 ] ) ;
6960 expect ( getByText ( '展开' ) ) . toBeTruthy ( ) ;
7061 expect ( onChange ) . toHaveBeenCalledTimes ( 1 ) ;
7162 } ) ;
@@ -76,16 +67,16 @@ describe('test BlockHeader render', () => {
7667 </ BlockHeader >
7768 ) ;
7869 expect ( getByText ( '收起' ) ) . toBeTruthy ( ) ;
79- fireEvent . click ( document . getElementsByClassName ( `${ prefixCls } -title-row ` ) [ 0 ] ) ;
70+ fireEvent . click ( document . getElementsByClassName ( `${ prefixCls } __title ` ) [ 0 ] ) ;
8071 expect ( getByText ( '展开' ) ) . toBeTruthy ( ) ;
8172 } ) ;
8273 test ( 'should render BlockHeader with different props' , ( ) => {
8374 const { container, getByText } = render ( < BlockHeader { ...props2 } /> ) ;
8475 const wrap = container . firstChild ;
85- expect ( wrap ) . toHaveClass ( `${ prefixCls } ` ) ;
86- expect ( wrap ! . firstChild ) . toHaveClass ( `test-row-className` ) ;
87- expect ( getByText ( '标题2' ) ) . toHaveClass ( 'test-title-className ' ) ;
88- expect ( getByText ( '说明文字' ) ) . toHaveClass ( ` ${ prefixCls } -description` ) ;
76+ expect ( wrap ) . toHaveClass ( `${ prefixCls } test__className ` ) ;
77+ expect ( wrap ) . toHaveStyle ( { height : '100px' , marginBottom : '16px' } ) ;
78+ expect ( getByText ( '标题2' ) ) . toHaveClass ( 'title__text ' ) ;
79+ expect ( getByText ( '说明文字' ) ) . toHaveClass ( 'title__description' ) ;
8980 expect ( getByText ( 'Icon' ) ) . toBeTruthy ( ) ;
9081 } ) ;
9182 test ( 'should render BlockHeader background success' , ( ) => {
@@ -97,10 +88,9 @@ describe('test BlockHeader render', () => {
9788 test ( 'should render BlockHeader className when isSmall is small' , ( ) => {
9889 const { container, getByText } = render ( < BlockHeader { ...props2 } /> ) ;
9990 const wrap = container . firstChild ! ;
100- expect ( wrap ) . toHaveClass ( `${ prefixCls } ` ) ;
101- expect ( wrap . firstChild ) . toHaveClass ( `test-row-className` ) ;
102- expect ( getByText ( '标题2' ) ) . toHaveClass ( 'test-title-className' ) ;
103- expect ( getByText ( '说明文字' ) ) . toHaveClass ( `${ prefixCls } -description` ) ;
91+ expect ( wrap ) . toHaveClass ( `${ prefixCls } test__className` ) ;
92+ expect ( getByText ( '标题2' ) ) . toHaveClass ( 'title__text' ) ;
93+ expect ( getByText ( '说明文字' ) ) . toHaveClass ( 'title__description' ) ;
10494 expect ( getByText ( 'Icon' ) ) . toBeTruthy ( ) ;
10595 } ) ;
10696
0 commit comments