@@ -24,7 +24,7 @@ test('can override the ids', () => {
24
24
expect ( container . firstChild ) . toMatchSnapshot ( )
25
25
} )
26
26
27
- test ( 'if aria-label is provided to the menu then aria-labelledby is not applied to the label ' , ( ) => {
27
+ test ( 'if aria-label is provided to the menu then aria-labelledby is not applied to the menu ' , ( ) => {
28
28
const customLabel = 'custom menu label'
29
29
const { menu} = renderDownshift ( {
30
30
menuProps : { 'aria-label' : customLabel } ,
@@ -33,7 +33,16 @@ test('if aria-label is provided to the menu then aria-labelledby is not applied
33
33
expect ( menu ) . toHaveAttribute ( 'aria-label' , customLabel )
34
34
} )
35
35
36
- function renderDownshift ( { renderFn, props, menuProps} = { } ) {
36
+ test ( 'if aria-label is provided to the input then aria-labelledby is not applied to the input' , ( ) => {
37
+ const customLabel = 'custom menu label'
38
+ const { input} = renderDownshift ( {
39
+ inputProps : { 'aria-label' : customLabel } ,
40
+ } )
41
+ expect ( input ) . not . toHaveAttribute ( 'aria-labelledby' )
42
+ expect ( input ) . toHaveAttribute ( 'aria-label' , customLabel )
43
+ } )
44
+
45
+ function renderDownshift ( { renderFn, props, menuProps, inputProps} = { } ) {
37
46
function defaultRenderFn ( {
38
47
getInputProps,
39
48
getToggleButtonProps,
@@ -46,7 +55,7 @@ function renderDownshift({renderFn, props, menuProps} = {}) {
46
55
< label data-testid = "label" { ...getLabelProps ( ) } >
47
56
label
48
57
</ label >
49
- < input data-testid = "input" { ...getInputProps ( ) } />
58
+ < input data-testid = "input" { ...getInputProps ( inputProps ) } />
50
59
< button data-testid = "button" { ...getToggleButtonProps ( ) } />
51
60
< ul data-testid = "menu" { ...getMenuProps ( menuProps ) } >
52
61
< li data-testid = "item-0" { ...getItemProps ( { item : 'item' , index : 0 } ) } >
0 commit comments