@@ -4350,20 +4350,50 @@ describe("DatePicker", () => {
43504350 expect ( input . getAttribute ( "aria-required" ) ) . toBe ( "true" ) ;
43514351 } ) ;
43524352
4353+ it ( "should pass aria-label to the input using standard HTML attribute name" , ( ) => {
4354+ const { container } = render (
4355+ < DatePicker selected = { newDate ( ) } aria-label = "Select a date" /> ,
4356+ ) ;
4357+ const input = safeQuerySelector ( container , "input" ) ;
4358+ expect ( input . getAttribute ( "aria-label" ) ) . toBe ( "Select a date" ) ;
4359+ } ) ;
4360+
4361+ it ( "should pass aria-label to the input using camelCase prop name" , ( ) => {
4362+ const { container } = render (
4363+ < DatePicker selected = { newDate ( ) } ariaLabel = "Select a date" /> ,
4364+ ) ;
4365+ const input = safeQuerySelector ( container , "input" ) ;
4366+ expect ( input . getAttribute ( "aria-label" ) ) . toBe ( "Select a date" ) ;
4367+ } ) ;
4368+
4369+ it ( "should prefer standard HTML attribute name over camelCase for aria-label" , ( ) => {
4370+ const { container } = render (
4371+ < DatePicker
4372+ selected = { newDate ( ) }
4373+ aria-label = "standard-label"
4374+ ariaLabel = "camelcase-label"
4375+ /> ,
4376+ ) ;
4377+ const input = safeQuerySelector ( container , "input" ) ;
4378+ expect ( input . getAttribute ( "aria-label" ) ) . toBe ( "standard-label" ) ;
4379+ } ) ;
4380+
43534381 it ( "should pass aria attributes to custom input using standard HTML attribute names" , ( ) => {
43544382 const { container } = render (
43554383 < DatePicker
43564384 selected = { newDate ( ) }
43574385 customInput = { < CustomInput /> }
43584386 aria-describedby = "desc-id"
43594387 aria-invalid = "true"
4388+ aria-label = "date-label"
43604389 aria-labelledby = "label-id"
43614390 aria-required = "true"
43624391 /> ,
43634392 ) ;
43644393 const input = safeQuerySelector ( container , "input" ) ;
43654394 expect ( input . getAttribute ( "aria-describedby" ) ) . toBe ( "desc-id" ) ;
43664395 expect ( input . getAttribute ( "aria-invalid" ) ) . toBe ( "true" ) ;
4396+ expect ( input . getAttribute ( "aria-label" ) ) . toBe ( "date-label" ) ;
43674397 expect ( input . getAttribute ( "aria-labelledby" ) ) . toBe ( "label-id" ) ;
43684398 expect ( input . getAttribute ( "aria-required" ) ) . toBe ( "true" ) ;
43694399 } ) ;
0 commit comments