From 5c54186c78210317a6a0f8a793d20d14a5290cb1 Mon Sep 17 00:00:00 2001 From: Alisher Musurmonov Date: Mon, 25 Sep 2023 18:14:56 +0500 Subject: [PATCH] tests: fix failing tests --- .../EditContactInfo/EditContactInfo.test.js | 1 - .../DepartmentsNameEdit/DepartmentsNameEdit.test.js | 8 ++++++-- .../EditExtendedInfo/EditExtendedInfo.test.js | 11 ++++++----- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/components/EditSections/EditContactInfo/EditContactInfo.test.js b/src/components/EditSections/EditContactInfo/EditContactInfo.test.js index b35bc110d..a0423a0ef 100644 --- a/src/components/EditSections/EditContactInfo/EditContactInfo.test.js +++ b/src/components/EditSections/EditContactInfo/EditContactInfo.test.js @@ -81,6 +81,5 @@ describe('Render Edit contact Information component', () => { expect(document.querySelector('[id="adduser_email"]')).toBeDisabled(); expect(document.querySelector('[id="adduser_phone"]')).toBeDisabled(); expect(document.querySelector('[id="adduser_mobilePhone"]')).toBeDisabled(); - expect(document.querySelector('[id="adduser_preferredcontact"]')).toBeDisabled(); }); }); diff --git a/src/components/EditSections/EditExtendedInfo/DepartmentsNameEdit/DepartmentsNameEdit.test.js b/src/components/EditSections/EditExtendedInfo/DepartmentsNameEdit/DepartmentsNameEdit.test.js index e3a9591c6..2d841a263 100644 --- a/src/components/EditSections/EditExtendedInfo/DepartmentsNameEdit/DepartmentsNameEdit.test.js +++ b/src/components/EditSections/EditExtendedInfo/DepartmentsNameEdit/DepartmentsNameEdit.test.js @@ -8,9 +8,10 @@ import { import userEvent from '@folio/jest-config-stripes/testing-library/user-event'; import renderWithRouter from 'helpers/renderWithRouter'; import DepartmentsNameEdit from './DepartmentsNameEdit'; -import '__mock__/stripesSmartComponent.mock'; +// import '__mock__/stripesSmartComponent.mock'; jest.unmock('@folio/stripes/components'); +jest.unmock('@folio/stripes/smart-components'); const onSubmit = jest.fn(); @@ -62,8 +63,11 @@ describe('Given DepartmentsNameEdit', () => { await userEvent.click(screen.getByText('ui-users.extended.department.add')); expect(screen.queryByPlaceholderText(/ui-users.extended.department.default/i)); }); +}); - it('should not render add button with disabled prop is true', async () => { +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(); }); }); diff --git a/src/components/EditSections/EditExtendedInfo/EditExtendedInfo.test.js b/src/components/EditSections/EditExtendedInfo/EditExtendedInfo.test.js index 416c0f32e..37cb243c6 100644 --- a/src/components/EditSections/EditExtendedInfo/EditExtendedInfo.test.js +++ b/src/components/EditSections/EditExtendedInfo/EditExtendedInfo.test.js @@ -2,11 +2,11 @@ import { screen } from '@folio/jest-config-stripes/testing-library/react'; import { Form } from 'react-final-form'; import PropTypes from 'prop-types'; -import '__mock__/stripesComponents.mock'; - import renderWithRouter from 'helpers/renderWithRouter'; import EditExtendedInfo from './EditExtendedInfo'; +jest.unmock('@folio/stripes/components'); + const onSubmit = jest.fn(); const arrayMutators = { @@ -28,7 +28,8 @@ const renderEditExtendedInfo = (props) => { ); - renderWithRouter( + + return renderWithRouter(
{ expect(screen.getByText('test@test.ccom')).toBeInTheDocument(); }); it('should fields to be disabled', () => { - renderEditExtendedInfo(props); - expect(screen.getByText(props.username)).toBeDisabled(); + renderEditExtendedInfo({ ...props, disabled: true }); + expect(screen.getAllByRole('textbox')[0]).toBeDisabled(); }); });