From b947002ace96750a08a5b2b0247b3950447ad623 Mon Sep 17 00:00:00 2001 From: lassopicasso Date: Fri, 13 Dec 2024 14:10:44 +0100 Subject: [PATCH] small adjustments in test --- .../EditSubformTableColumns.test.tsx | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/frontend/packages/ux-editor/src/components/Properties/EditSubformTableColumns/EditSubformTableColumns.test.tsx b/frontend/packages/ux-editor/src/components/Properties/EditSubformTableColumns/EditSubformTableColumns.test.tsx index c911a56674b..5358c68740b 100644 --- a/frontend/packages/ux-editor/src/components/Properties/EditSubformTableColumns/EditSubformTableColumns.test.tsx +++ b/frontend/packages/ux-editor/src/components/Properties/EditSubformTableColumns/EditSubformTableColumns.test.tsx @@ -46,10 +46,9 @@ describe('EditSubformTableColumns', () => { }, }); - const addColumnButton = getAddColumnButton(); - await user.click(addColumnButton); - + await user.click(getAddColumnButton()); expect(handleComponentChangeMock).toHaveBeenCalledTimes(1); + const numberOfColumnsAfterAdded = getUpdatedTableColumns(handleComponentChangeMock).length; expect(numberOfColumnsAfterAdded).toBe(1); }); @@ -62,8 +61,7 @@ describe('EditSubformTableColumns', () => { props: { handleComponentChange: handleComponentChangeMock }, }); - const addColumnButton = getAddColumnButton(); - await user.click(addColumnButton); + await user.click(getAddColumnButton()); expect(handleComponentChangeMock).toHaveBeenCalledTimes(1); const numberOfColumnsAfterAdded = getUpdatedTableColumns(handleComponentChangeMock).length; @@ -83,8 +81,7 @@ describe('EditSubformTableColumns', () => { }); await user.click(editButton); - const componentSelector = getComponentSelector(); - await user.click(componentSelector); + await user.click(getComponentSelector()); await user.click( screen.getByRole('option', { name: new RegExp(`${subformLayoutMock.component1Id}`) }), ); @@ -146,9 +143,7 @@ describe('EditSubformTableColumns', () => { props: { handleComponentChange: handleComponentChangeMock }, }); - const addColumnButton = getAddColumnButton(); - await user.click(addColumnButton); - + await user.click(getAddColumnButton()); const updatedProps = { handleComponentChange: handleComponentChangeMock, component: { @@ -157,9 +152,7 @@ describe('EditSubformTableColumns', () => { }, }; rerender(); - - const componentSelector = getComponentSelector(); - expect(componentSelector).toBeInTheDocument(); + expect(getComponentSelector()).toBeInTheDocument(); }); });