@@ -16,6 +16,7 @@ describe('<DatepickerControl />', () => {
1616 ) ;
1717
1818 const props = {
19+ intl : { } ,
1920 type : DATEPICKER_TYPES . date ,
2021 label : 'fooLabel' ,
2122 value : '' ,
@@ -30,6 +31,7 @@ describe('<DatepickerControl />', () => {
3031 beforeEach ( ( ) => {
3132 onChangeMock . mockClear ( ) ;
3233 } ) ;
34+
3335 it ( 'renders without crashing' , ( ) => {
3436 const { getByText, queryAllByText, getByPlaceholderText } = render (
3537 < RootWrapper { ...props } /> ,
@@ -52,36 +54,38 @@ describe('<DatepickerControl />', () => {
5254 } ) ;
5355
5456 it ( 'renders time picker with accessibility hint' , ( ) => {
55- const { getByText, getByLabelText } = render (
57+ const { getByText, getByPlaceholderText } = render (
5658 < RootWrapper
5759 { ...props }
5860 type = { DATEPICKER_TYPES . time }
5961 value = "2025-01-01T10:00:00Z"
6062 helpText = ""
6163 /> ,
6264 ) ;
65+ const input = getByPlaceholderText ( 'HH:MM' ) ;
66+
6367 expect (
6468 getByText ( 'Enter time in HH:MM or twelve-hour format, for example 6:00 PM.' ) ,
6569 ) . toBeInTheDocument ( ) ;
66- expect ( getByLabelText ( messages . timepickerAriaLabel . defaultMessage ) )
67- . toBeInTheDocument ( ) ;
70+ expect ( input . getAttribute ( 'aria-describedby' ) ) . toContain ( 'fooControlName-timehint' ) ;
6871 } ) ;
6972
7073 it ( 'increments time value with arrow down and decrements with arrow up' , ( ) => {
7174 const incremented = convertToStringFromDate ( '2025-01-01T10:30:00Z' ) ;
7275 const decremented = convertToStringFromDate ( '2025-01-01T09:30:00Z' ) ;
73- const { getByLabelText } = render (
76+ const { getByPlaceholderText } = render (
7477 < RootWrapper
7578 { ...props }
7679 type = { DATEPICKER_TYPES . time }
7780 value = "2025-01-01T10:00:00Z"
7881 helpText = ""
7982 /> ,
8083 ) ;
81- const input = getByLabelText ( messages . timepickerAriaLabel . defaultMessage ) ;
82- expect ( input ) . toHaveValue ( '10:00' ) ;
84+ const input = getByPlaceholderText ( 'HH:MM' ) ;
85+
8386 fireEvent . keyDown ( input , { key : 'ArrowDown' , target : { value : '10:00' } } ) ;
8487 expect ( onChangeMock ) . toHaveBeenCalledWith ( incremented ) ;
88+
8589 fireEvent . keyDown ( input , { key : 'ArrowUp' , target : { value : '10:30' } } ) ;
8690 expect ( onChangeMock ) . toHaveBeenCalledWith ( decremented ) ;
8791 } ) ;
0 commit comments