@@ -13,8 +13,9 @@ const props2: IBlockHeaderProps = {
13
13
description : '说明文字' ,
14
14
addonAfter : < div className = "test-button-after" > 新增按钮</ div > ,
15
15
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 ,
18
19
} ;
19
20
const props3 : IBlockHeaderProps = {
20
21
title : 'hover' ,
@@ -44,18 +45,8 @@ describe('test BlockHeader render', () => {
44
45
test ( 'should render BlockHeader props default in BlockHeader' , ( ) => {
45
46
const { container } = render ( < BlockHeader title = "测试" background /> ) ;
46
47
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 ] ) ;
59
50
} ) ;
60
51
test ( 'should render BlockHeader test click event' , ( ) => {
61
52
const onChange = jest . fn ( ) ;
@@ -65,7 +56,7 @@ describe('test BlockHeader render', () => {
65
56
</ BlockHeader >
66
57
) ;
67
58
expect ( getByText ( '收起' ) ) . toBeTruthy ( ) ;
68
- fireEvent . click ( document . getElementsByClassName ( `${ prefixCls } -title-row ` ) [ 0 ] ) ;
59
+ fireEvent . click ( document . getElementsByClassName ( `${ prefixCls } __title ` ) [ 0 ] ) ;
69
60
expect ( getByText ( '展开' ) ) . toBeTruthy ( ) ;
70
61
expect ( onChange ) . toHaveBeenCalledTimes ( 1 ) ;
71
62
} ) ;
@@ -76,16 +67,16 @@ describe('test BlockHeader render', () => {
76
67
</ BlockHeader >
77
68
) ;
78
69
expect ( getByText ( '收起' ) ) . toBeTruthy ( ) ;
79
- fireEvent . click ( document . getElementsByClassName ( `${ prefixCls } -title-row ` ) [ 0 ] ) ;
70
+ fireEvent . click ( document . getElementsByClassName ( `${ prefixCls } __title ` ) [ 0 ] ) ;
80
71
expect ( getByText ( '展开' ) ) . toBeTruthy ( ) ;
81
72
} ) ;
82
73
test ( 'should render BlockHeader with different props' , ( ) => {
83
74
const { container, getByText } = render ( < BlockHeader { ...props2 } /> ) ;
84
75
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' ) ;
89
80
expect ( getByText ( 'Icon' ) ) . toBeTruthy ( ) ;
90
81
} ) ;
91
82
test ( 'should render BlockHeader background success' , ( ) => {
@@ -97,10 +88,9 @@ describe('test BlockHeader render', () => {
97
88
test ( 'should render BlockHeader className when isSmall is small' , ( ) => {
98
89
const { container, getByText } = render ( < BlockHeader { ...props2 } /> ) ;
99
90
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' ) ;
104
94
expect ( getByText ( 'Icon' ) ) . toBeTruthy ( ) ;
105
95
} ) ;
106
96
0 commit comments