From b76c05cd594b1fae31766b52eb637574b36f3d21 Mon Sep 17 00:00:00 2001 From: htranho <34069728+htranho@users.noreply.github.com> Date: Thu, 2 Jan 2025 15:41:21 -0500 Subject: [PATCH] MMT-3960: Add input test --- .../__tests__/CustomDateTimeWidget.test.jsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/static/src/js/components/CustomDateTimeWidget/__tests__/CustomDateTimeWidget.test.jsx b/static/src/js/components/CustomDateTimeWidget/__tests__/CustomDateTimeWidget.test.jsx index eb58f737a..c48a1af54 100644 --- a/static/src/js/components/CustomDateTimeWidget/__tests__/CustomDateTimeWidget.test.jsx +++ b/static/src/js/components/CustomDateTimeWidget/__tests__/CustomDateTimeWidget.test.jsx @@ -174,12 +174,24 @@ describe('CustomDateTimeWidget', () => { describe('When a date has a specific time in the form', () => { test('shows the date and time', async () => { setup({ - value: '2023-12-05T16:05:59.000Z' + value: '2023-12-05T16:05:59.090Z' }) const field = await screen.findByPlaceholderText('YYYY-MM-DDTHH:MM:SS.SSSZ') - expect(field).toHaveValue('2023-12-05T16:05:59.000Z') + expect(field).toHaveValue('2023-12-05T16:05:59.090Z') + }) + }) + + describe('when the field is typed in', () => { + test('calls onChange', async () => { + const { props, user } = setup() + + const field = await screen.findByPlaceholderText('YYYY-MM-DDTHH:MM:SS.SSSZ') + + await user.type(field, '2025-01-02T03:20:15.999Z') + + expect(props.onChange).toHaveBeenCalledWith('2025-01-02T03:20:15.999Z') }) }) })