From 51f026b9d71ba806fe50a09e2583383c2613229b Mon Sep 17 00:00:00 2001 From: Nina Kylstad Date: Tue, 6 Feb 2024 08:37:58 +0100 Subject: [PATCH] remove unneccessary code and add test --- .../components/Properties/Properties.test.tsx | 24 +++++++++++++------ .../editModal/EditTextResourceBindings.tsx | 7 ------ 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/frontend/packages/ux-editor/src/components/Properties/Properties.test.tsx b/frontend/packages/ux-editor/src/components/Properties/Properties.test.tsx index 7e6d53f4739..fba7b3abe18 100644 --- a/frontend/packages/ux-editor/src/components/Properties/Properties.test.tsx +++ b/frontend/packages/ux-editor/src/components/Properties/Properties.test.tsx @@ -45,6 +45,23 @@ jest.mock('./Calculations', () => ({ jest.mock('react-i18next', () => ({ useTranslation: () => mockUseTranslation(texts) })); describe('Properties', () => { + describe('Text', () => { + it('Toggles text when clicked', async () => { + render(); + const button = screen.queryByRole('button', { name: textText }); + await act(() => user.click(button)); + expect(button).toHaveAttribute('aria-expanded', 'true'); + await act(() => user.click(button)); + expect(button).toHaveAttribute('aria-expanded', 'false'); + }); + + it('Opens text when a component is selected', async () => { + const { rerender } = render(); + rerender(getComponent({ formId: 'test' })); + const button = screen.queryByRole('button', { name: textText }); + await waitFor(() => expect(button).toHaveAttribute('aria-expanded', 'true')); + }); + }); describe('Content', () => { it('Closes content on load', () => { render(); @@ -60,13 +77,6 @@ describe('Properties', () => { await act(() => user.click(button)); expect(button).toHaveAttribute('aria-expanded', 'false'); }); - - it('Opens text when a component is selected', async () => { - const { rerender } = render(); - rerender(getComponent({ formId: 'test' })); - const button = screen.queryByRole('button', { name: textText }); - await waitFor(() => expect(button).toHaveAttribute('aria-expanded', 'true')); - }); }); describe('Dynamics', () => { diff --git a/frontend/packages/ux-editor/src/components/config/editModal/EditTextResourceBindings.tsx b/frontend/packages/ux-editor/src/components/config/editModal/EditTextResourceBindings.tsx index 7a6784d1950..7eb7314df82 100644 --- a/frontend/packages/ux-editor/src/components/config/editModal/EditTextResourceBindings.tsx +++ b/frontend/packages/ux-editor/src/components/config/editModal/EditTextResourceBindings.tsx @@ -20,12 +20,6 @@ export const EditTextResourceBindings = ({ handleComponentChange, textResourceBindingKeys, }: EditTextResourceBindingsProps) => { - const handleRemoveKey = (key: string) => { - const updatedComponent = { ...component }; - delete updatedComponent.textResourceBindings[key]; - handleComponentChange(updatedComponent); - }; - return (
{textResourceBindingKeys.map((key: string) => ( @@ -33,7 +27,6 @@ export const EditTextResourceBindings = ({ key={key} component={component} handleComponentChange={handleComponentChange} - removeTextResourceBinding={() => handleRemoveKey(key)} textKey={key} labelKey={`ux_editor.modal_properties_textResourceBindings_${key}` as any} placeholderKey={`ux_editor.modal_properties_textResourceBindings_${key}_add` as any}