@@ -4403,20 +4403,50 @@ describe("DatePicker", () => {
44034403 expect ( input . getAttribute ( "aria-required" ) ) . toBe ( "true" ) ;
44044404 } ) ;
44054405
4406+ it ( "should pass aria-label to the input using standard HTML attribute name" , ( ) => {
4407+ const { container } = render (
4408+ < DatePicker selected = { newDate ( ) } aria-label = "Select a date" /> ,
4409+ ) ;
4410+ const input = safeQuerySelector ( container , "input" ) ;
4411+ expect ( input . getAttribute ( "aria-label" ) ) . toBe ( "Select a date" ) ;
4412+ } ) ;
4413+
4414+ it ( "should pass aria-label to the input using camelCase prop name" , ( ) => {
4415+ const { container } = render (
4416+ < DatePicker selected = { newDate ( ) } ariaLabel = "Select a date" /> ,
4417+ ) ;
4418+ const input = safeQuerySelector ( container , "input" ) ;
4419+ expect ( input . getAttribute ( "aria-label" ) ) . toBe ( "Select a date" ) ;
4420+ } ) ;
4421+
4422+ it ( "should prefer standard HTML attribute name over camelCase for aria-label" , ( ) => {
4423+ const { container } = render (
4424+ < DatePicker
4425+ selected = { newDate ( ) }
4426+ aria-label = "standard-label"
4427+ ariaLabel = "camelcase-label"
4428+ /> ,
4429+ ) ;
4430+ const input = safeQuerySelector ( container , "input" ) ;
4431+ expect ( input . getAttribute ( "aria-label" ) ) . toBe ( "standard-label" ) ;
4432+ } ) ;
4433+
44064434 it ( "should pass aria attributes to custom input using standard HTML attribute names" , ( ) => {
44074435 const { container } = render (
44084436 < DatePicker
44094437 selected = { newDate ( ) }
44104438 customInput = { < CustomInput /> }
44114439 aria-describedby = "desc-id"
44124440 aria-invalid = "true"
4441+ aria-label = "date-label"
44134442 aria-labelledby = "label-id"
44144443 aria-required = "true"
44154444 /> ,
44164445 ) ;
44174446 const input = safeQuerySelector ( container , "input" ) ;
44184447 expect ( input . getAttribute ( "aria-describedby" ) ) . toBe ( "desc-id" ) ;
44194448 expect ( input . getAttribute ( "aria-invalid" ) ) . toBe ( "true" ) ;
4449+ expect ( input . getAttribute ( "aria-label" ) ) . toBe ( "date-label" ) ;
44204450 expect ( input . getAttribute ( "aria-labelledby" ) ) . toBe ( "label-id" ) ;
44214451 expect ( input . getAttribute ( "aria-required" ) ) . toBe ( "true" ) ;
44224452 } ) ;
0 commit comments