From af8ad3565c5970ec0abd487670674bead2b960e0 Mon Sep 17 00:00:00 2001 From: Steve Matney Date: Thu, 6 Feb 2025 10:17:36 -0700 Subject: [PATCH] Fix: ensuring monthNames are consistent in defaultProps --- .../patterns/dateInput/DateInput.specs.tsx | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/packages/es-components/src/components/patterns/dateInput/DateInput.specs.tsx b/packages/es-components/src/components/patterns/dateInput/DateInput.specs.tsx index c1580c49a..7e0304551 100644 --- a/packages/es-components/src/components/patterns/dateInput/DateInput.specs.tsx +++ b/packages/es-components/src/components/patterns/dateInput/DateInput.specs.tsx @@ -465,3 +465,51 @@ it('correctly unsets the date when month is deselected', async () => { value: undefined }); }); + +it('correctly unsets the date when month is deselected', async () => { + const onChange = jest.fn(); + const props = { + onChange + }; + + renderWithTheme( + + + + + + ); + + await userEvent.selectOptions( + screen.getByRole('combobox', { name: /month/ }), + 'January' + ); + await typeFresh(await screen.findByRole('spinbutton', { name: /day/ }), '15'); + await typeFresh( + await screen.findByRole('spinbutton', { name: /year/ }), + '2025' + ); + expect(onChange).toHaveBeenLastCalledWith({ + isInRange: true, + rawValues: { + day: '15', + month: '1', + year: '2025' + }, + value: new Date('2025/1/15') + }); + + await userEvent.selectOptions( + screen.getByRole('combobox', { name: /month/ }), + 'Select a Month' + ); + expect(onChange).toHaveBeenLastCalledWith({ + isInRange: false, + rawValues: { + day: '15', + month: '', + year: '2025' + }, + value: undefined + }); +});