From 2f35e90cc9381c881b7e3f8be39d20e620b19bfc Mon Sep 17 00:00:00 2001 From: Alisher Musurmonov Date: Mon, 25 Sep 2023 18:38:37 +0500 Subject: [PATCH] refactor: disable add button with disabled: true --- .../DepartmentsNameEdit/DepartmentsNameEdit.js | 3 ++- .../DepartmentsNameEdit/DepartmentsNameEdit.test.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/EditSections/EditExtendedInfo/DepartmentsNameEdit/DepartmentsNameEdit.js b/src/components/EditSections/EditExtendedInfo/DepartmentsNameEdit/DepartmentsNameEdit.js index 7d8acef0b..e4564ff7a 100644 --- a/src/components/EditSections/EditExtendedInfo/DepartmentsNameEdit/DepartmentsNameEdit.js +++ b/src/components/EditSections/EditExtendedInfo/DepartmentsNameEdit/DepartmentsNameEdit.js @@ -30,13 +30,14 @@ const DepartmentsNameEdit = ({ departments, disabled }) => { return (
} + addLabel={} legend={} id="department-name" component={RepeatableField} name="departments" onAdd={fields => fields.push()} canRemove={!disabled} + canAdd={!disabled} renderField={field => ( { describe('Given DepartmentsNameEdit with disabled: true', () => { it('should not render add button', async () => { renderDepartmentsNameEdit({ ...props, disabled: true }); - expect(screen.queryByText('ui-users.extended.department.add')).not.toBeInTheDocument(); + expect(screen.getByRole('button')).toBeDisabled(); }); });