@@ -6,35 +6,35 @@ import { TrashIcon } from '../../../icons';
6
6
describe ( 'Experimental: IconButton' , ( ) => {
7
7
it ( 'renders an icon button with the provided icon' , ( ) => {
8
8
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 ( ) ;
11
11
} ) ;
12
12
13
13
it ( 'calls onPress when clicked' , ( ) => {
14
14
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 ( ) ;
17
17
expect ( onPress ) . toHaveBeenCalledTimes ( 1 ) ;
18
18
} ) ;
19
19
20
20
it ( 'does not call onPress when disabled' , ( ) => {
21
21
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 ( ) ;
24
24
expect ( onPress ) . toHaveBeenCalledTimes ( 0 ) ;
25
25
} ) ;
26
26
27
27
it ( 'does not call onPress when is loading' , ( ) => {
28
28
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 ( ) ;
31
31
expect ( onPress ) . toHaveBeenCalledTimes ( 0 ) ;
32
32
} ) ;
33
33
34
34
it ( 'sets the right sizes for standard variant' , ( ) => {
35
35
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" } ) ;
38
38
const containerStyle = window . getComputedStyle ( iconContainerInstance ) ;
39
39
expect ( containerStyle . width ) . toBe ( '2.5rem' ) ;
40
40
expect ( containerStyle . height ) . toBe ( '2.5rem' ) ;
@@ -43,8 +43,8 @@ describe('Experimental: IconButton', () => {
43
43
44
44
it ( 'sets the right sizes for tonal variant' , ( ) => {
45
45
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" } ) ;
48
48
const containerStyle = window . getComputedStyle ( iconContainerInstance ) ;
49
49
expect ( containerStyle . width ) . toBe ( '3.5rem' ) ;
50
50
expect ( containerStyle . height ) . toBe ( '3.5rem' ) ;
@@ -53,7 +53,7 @@ describe('Experimental: IconButton', () => {
53
53
54
54
it ( 'spinner is rendered when loading' , ( ) => {
55
55
const onPress = jest . fn ( ) ;
56
- render ( < IconButton Icon = { TrashIcon } onPress = { onPress } isLoading /> ) ;
56
+ render ( < IconButton Icon = { TrashIcon } onPress = { onPress } isLoading label = "Icon label" /> ) ;
57
57
expect ( screen . getByTestId ( 'iconbutton-spinner' ) ) . toBeInTheDocument ( ) ;
58
58
} ) ;
59
59
} ) ;
0 commit comments