@@ -8,23 +8,18 @@ const iconSVG = (
88 </ svg >
99) ;
1010describe ( "Action icon component tests" , ( ) => {
11- test ( "Action icon renders with correct text" , ( ) => {
12- const { getByTitle } = render ( < DxcActionIcon icon = { iconSVG } title = "favourite" /> ) ;
13- expect ( getByTitle ( "favourite" ) ) . toBeTruthy ( ) ;
14- } ) ;
15-
1611 test ( "Calls correct function on click" , ( ) => {
1712 const onClick = jest . fn ( ) ;
18- const { getByTitle } = render ( < DxcActionIcon icon = { iconSVG } title = "favourite" onClick = { onClick } /> ) ;
19- const action = getByTitle ( "favourite ") ;
13+ const { getByRole } = render ( < DxcActionIcon icon = { iconSVG } title = "favourite" onClick = { onClick } /> ) ;
14+ const action = getByRole ( "button ") ;
2015 fireEvent . click ( action ) ;
2116 expect ( onClick ) . toHaveBeenCalled ( ) ;
2217 } ) ;
2318
2419 test ( "On click is not called when disabled" , ( ) => {
2520 const onClick = jest . fn ( ) ;
26- const { getByTitle } = render ( < DxcActionIcon disabled icon = { iconSVG } title = "favourite" onClick = { onClick } /> ) ;
27- const action = getByTitle ( "favourite ") ;
21+ const { getByRole } = render ( < DxcActionIcon disabled icon = { iconSVG } title = "favourite" onClick = { onClick } /> ) ;
22+ const action = getByRole ( "button ") ;
2823 fireEvent . click ( action ) ;
2924 expect ( onClick ) . toHaveBeenCalledTimes ( 0 ) ;
3025 } ) ;
@@ -34,7 +29,6 @@ describe("Action icon component tests", () => {
3429
3530 const button = getByRole ( "button" ) ;
3631 expect ( button . getAttribute ( "aria-label" ) ) . toBe ( "favourite" ) ;
37- expect ( button . getAttribute ( "title" ) ) . toBe ( "favourite" ) ;
3832 expect ( button . getAttribute ( "tabindex" ) ) . toBe ( "1" ) ;
3933 } ) ;
4034} ) ;
0 commit comments