Skip to content

Commit

Permalink
tests: fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alisher-epam committed Sep 25, 2023
1 parent c703098 commit 5c54186
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -28,7 +28,8 @@ const renderEditExtendedInfo = (props) => {
<EditExtendedInfo {...props} />
</>
);
renderWithRouter(

return renderWithRouter(
<Form
id="form-user"
mutators={{
Expand Down Expand Up @@ -121,7 +122,7 @@ describe('Render Extended User Information component', () => {
expect(screen.getByText('[email protected]')).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();
});
});

0 comments on commit 5c54186

Please sign in to comment.