From 0714f27cc323818c6dec2836b36e491e6680005f Mon Sep 17 00:00:00 2001 From: Lars Olav Torvik Date: Tue, 14 May 2024 15:35:30 +0200 Subject: [PATCH] Fix test --- packages/fyllut/src/index.tsx | 2 ++ .../components/core/datepicker/DatePicker.test.tsx | 3 ++- .../formio/components/core/datepicker/DatePicker.tsx | 11 ++++++----- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/fyllut/src/index.tsx b/packages/fyllut/src/index.tsx index 7af390f1f..b8d1f3d31 100644 --- a/packages/fyllut/src/index.tsx +++ b/packages/fyllut/src/index.tsx @@ -29,6 +29,7 @@ httpFyllut const renderReact = (dokumentInnsendingBaseURL, config) => { const root = createRoot(document.getElementById('root')!); root.render( + { + , ); }; diff --git a/packages/shared-components/src/formio/components/core/datepicker/DatePicker.test.tsx b/packages/shared-components/src/formio/components/core/datepicker/DatePicker.test.tsx index 984943f52..8b2aa5914 100644 --- a/packages/shared-components/src/formio/components/core/datepicker/DatePicker.test.tsx +++ b/packages/shared-components/src/formio/components/core/datepicker/DatePicker.test.tsx @@ -100,11 +100,12 @@ describe('NavDatePicker', () => { expect(datepickerInput.value).toBe('01.01.2020'); await userEvent.clear(datepickerInput); + datepickerInput.blur(); expect(datepickerInput.value).toBe(''); const nextButton = screen.getByRole('button', { name: 'Neste steg' }); expect(nextButton).toBeInTheDocument(); - nextButton.click(); + await act(async () => nextButton.click()); const errorMessage = await screen.findByText('Du må fylle ut: Dato (dd.mm.åååå)'); expect(errorMessage).toBeInTheDocument(); diff --git a/packages/shared-components/src/formio/components/core/datepicker/DatePicker.tsx b/packages/shared-components/src/formio/components/core/datepicker/DatePicker.tsx index 3054c52f1..9f43cccbd 100644 --- a/packages/shared-components/src/formio/components/core/datepicker/DatePicker.tsx +++ b/packages/shared-components/src/formio/components/core/datepicker/DatePicker.tsx @@ -62,7 +62,11 @@ export default class DatePicker extends BaseComponent { this.t.bind(this), ); - return this.setComponentValidity(errorMessage ? [this.createError(errorMessage, undefined)] : [], dirty, undefined); + return this.setComponentValidity( + errorMessage ? [this.createError(errorMessage, undefined)] : [], + dirty, + undefined, + ); } return true; @@ -99,10 +103,7 @@ export default class DatePicker extends BaseComponent { this.updateValue(value, { modified: true }); if (this.component?.beforeDateInputKey) { - const referenceComponent = navFormUtils.findByKey( - this.component?.beforeDateInputKey, - this.root.getComponents(), - ); + const referenceComponent = navFormUtils.findByKey(this.component?.beforeDateInputKey, this.root.getComponents()); referenceComponent?.rerender?.(); } else { this.getComponentsWithDateInputKey().map((component) => component.rerender?.());