@@ -6,35 +6,35 @@ import { TrashIcon } from '../../../icons';
66describe ( 'Experimental: IconButton' , ( ) => {
77 it ( 'renders an icon button with the provided icon' , ( ) => {
88 const onPress = jest . fn ( ) ;
9- render ( < IconButton onPress = { onPress } Icon = { TrashIcon } /> ) ;
10- expect ( screen . getByTestId ( 'standard-icon-container' ) ) . toBeInTheDocument ( ) ;
9+ render ( < IconButton onPress = { onPress } Icon = { TrashIcon } label = "Icon label" /> ) ;
10+ expect ( screen . getByRole ( "button" , { name : "Icon label" } ) ) . toBeInTheDocument ( ) ;
1111 } ) ;
1212
1313 it ( 'calls onPress when clicked' , ( ) => {
1414 const onPress = jest . fn ( ) ;
15- render ( < IconButton Icon = { TrashIcon } onPress = { onPress } /> ) ;
16- screen . getByTestId ( 'standard-icon-container' ) . click ( ) ;
15+ render ( < IconButton Icon = { TrashIcon } onPress = { onPress } label = "Icon label" /> ) ;
16+ screen . getByRole ( "button" , { name : "Icon label" } ) . click ( ) ;
1717 expect ( onPress ) . toHaveBeenCalledTimes ( 1 ) ;
1818 } ) ;
1919
2020 it ( 'does not call onPress when disabled' , ( ) => {
2121 const onPress = jest . fn ( ) ;
22- render ( < IconButton Icon = { TrashIcon } onPress = { onPress } isDisabled /> ) ;
23- screen . getByTestId ( 'standard-icon-container' ) . click ( ) ;
22+ render ( < IconButton Icon = { TrashIcon } onPress = { onPress } isDisabled label = "Icon label" /> ) ;
23+ screen . getByRole ( "button" , { name : "Icon label" } ) . click ( ) ;
2424 expect ( onPress ) . toHaveBeenCalledTimes ( 0 ) ;
2525 } ) ;
2626
2727 it ( 'does not call onPress when is loading' , ( ) => {
2828 const onPress = jest . fn ( ) ;
29- render ( < IconButton Icon = { TrashIcon } onPress = { onPress } isLoading /> ) ;
30- screen . getByTestId ( 'standard-icon-container' ) . click ( ) ;
29+ render ( < IconButton Icon = { TrashIcon } onPress = { onPress } isLoading label = "Icon label" /> ) ;
30+ screen . getByRole ( "button" , { name : "Icon label" } ) . click ( ) ;
3131 expect ( onPress ) . toHaveBeenCalledTimes ( 0 ) ;
3232 } ) ;
3333
3434 it ( 'sets the right sizes for standard variant' , ( ) => {
3535 const onPress = jest . fn ( ) ;
36- render ( < IconButton Icon = { TrashIcon } onPress = { onPress } /> ) ;
37- const iconContainerInstance = screen . getByTestId ( 'standard-icon-container' ) ;
36+ render ( < IconButton Icon = { TrashIcon } onPress = { onPress } label = "Icon label" /> ) ;
37+ const iconContainerInstance = screen . getByRole ( "button" , { name : "Icon label" } ) ;
3838 const containerStyle = window . getComputedStyle ( iconContainerInstance ) ;
3939 expect ( containerStyle . width ) . toBe ( '2.5rem' ) ;
4040 expect ( containerStyle . height ) . toBe ( '2.5rem' ) ;
@@ -43,8 +43,8 @@ describe('Experimental: IconButton', () => {
4343
4444 it ( 'sets the right sizes for tonal variant' , ( ) => {
4545 const onPress = jest . fn ( ) ;
46- render ( < IconButton Icon = { TrashIcon } onPress = { onPress } variant = "tonal" /> ) ;
47- const iconContainerInstance = screen . getByTestId ( 'tonal-icon-container' ) ;
46+ render ( < IconButton Icon = { TrashIcon } onPress = { onPress } variant = "tonal" label = "Icon label" /> ) ;
47+ const iconContainerInstance = screen . getByRole ( "button" , { name : "Icon label" } ) ;
4848 const containerStyle = window . getComputedStyle ( iconContainerInstance ) ;
4949 expect ( containerStyle . width ) . toBe ( '3.5rem' ) ;
5050 expect ( containerStyle . height ) . toBe ( '3.5rem' ) ;
@@ -53,7 +53,7 @@ describe('Experimental: IconButton', () => {
5353
5454 it ( 'spinner is rendered when loading' , ( ) => {
5555 const onPress = jest . fn ( ) ;
56- render ( < IconButton Icon = { TrashIcon } onPress = { onPress } isLoading /> ) ;
56+ render ( < IconButton Icon = { TrashIcon } onPress = { onPress } isLoading label = "Icon label" /> ) ;
5757 expect ( screen . getByTestId ( 'iconbutton-spinner' ) ) . toBeInTheDocument ( ) ;
5858 } ) ;
5959} ) ;
0 commit comments