Skip to content

Commit

Permalink
Merge pull request #1107 from folio-org/UIREQ-996
Browse files Browse the repository at this point in the history
UIREQ-996: Update Jest/RTL tests
  • Loading branch information
Dmitriy-Litvinenko authored Nov 17, 2023
2 parents 2c40d08 + 70974fc commit 2d67e36
Show file tree
Hide file tree
Showing 47 changed files with 56 additions and 142 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Hide all actions except "Cancel Request" in Action menu and DCB item links (Pickup library). Refs UIREQ-1035.
* Request Action - Create new option Print search slips. Refs UIREQ-1039.
* Hide Actions menu on closed request of DCB Transaction. Refs UIREQ-1040.
* Update Jest/RTL tests, remove outdated imports. Refs UIREQ-996.

## [9.0.0](https://github.com/folio-org/ui-requests/tree/v9.0.0) (2023-10-12)
[Full Changelog](https://github.com/folio-org/ui-requests/compare/v8.0.2...v9.0.0)
Expand Down
2 changes: 0 additions & 2 deletions src/CancelRequestDialog.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import {
screen,
} from '@folio/jest-config-stripes/testing-library/react';

import '../test/jest/__mock__';

import CancelRequestDialog from './CancelRequestDialog';

const labelIds = {
Expand Down
3 changes: 0 additions & 3 deletions src/ChooseRequestTypeDialog.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import React from 'react';
import {
render,
screen,
} from '@folio/jest-config-stripes/testing-library/react';

import '../test/jest/__mock__';

import { Button } from '@folio/stripes/components';

import { Loading } from './components';
Expand Down
4 changes: 1 addition & 3 deletions src/ItemDetail.test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import React from 'react';
import {
render,
screen,
within,
} from '@folio/jest-config-stripes/testing-library/react';

import '../test/jest/__mock__';

import ItemDetail from './ItemDetail';

import { INVALID_REQUEST_HARDCODED_ID } from './constants';

jest.mock('react-router-dom', () => ({
Expand Down
5 changes: 1 addition & 4 deletions src/ItemsDialog.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import React from 'react';
import {
render,
screen,
} from '@folio/jest-config-stripes/testing-library/react';

import '../test/jest/__mock__';

import {
Modal,
MultiColumnList,
Expand Down Expand Up @@ -137,7 +134,7 @@ describe('ItemsDialog', () => {
});

it('should render Modal', () => {
expect(Modal).toHaveBeenLastCalledWith(
expect(Modal).toHaveBeenCalledWith(
expect.objectContaining({
'data-test-move-request-modal': true,
label: labelIds.selectItem,
Expand Down
2 changes: 0 additions & 2 deletions src/MoveRequestManager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import {
} from '@folio/jest-config-stripes/testing-library/react';
import userEvent from '@folio/jest-config-stripes/testing-library/user-event';

import '../test/jest/__mock__';

import MoveRequestManager from './MoveRequestManager';
import ItemsDialog from './ItemsDialog';
import ChooseRequestTypeDialog from './ChooseRequestTypeDialog';
Expand Down
2 changes: 0 additions & 2 deletions src/PatronBlockModal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import {
fireEvent,
} from '@folio/jest-config-stripes/testing-library/react';

import '../test/jest/__mock__';

import { Modal } from '@folio/stripes/components';

import PatronBlockModal from './PatronBlockModal';
Expand Down
3 changes: 0 additions & 3 deletions src/PositionLink.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import {
render,
screen,
Expand All @@ -8,8 +7,6 @@ import {
requestStatuses,
} from './constants';

import '../test/jest/__mock__';

import PositionLink from './PositionLink';

jest.mock('react-router-dom', () => ({
Expand Down
7 changes: 2 additions & 5 deletions src/RequestForm.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { Router } from 'react-router-dom';
import { createMemoryHistory } from 'history';
import { Field } from 'react-final-form';

import {
render,
screen,
Expand All @@ -9,10 +10,6 @@ import {
waitFor,
} from '@folio/jest-config-stripes/testing-library/react';

import '../test/jest/__mock__';

import { Field } from 'react-final-form';

import {
Checkbox,
CommandList,
Expand Down
4 changes: 1 addition & 3 deletions src/RequestFormContainer.test.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import React from 'react';
import {
Router,
} from 'react-router-dom';
import {
createMemoryHistory,
} from 'history';

import {
render,
act,
} from '@folio/jest-config-stripes/testing-library/react';

import '../test/jest/__mock__';

import RequestFormContainer from './RequestFormContainer';
import RequestForm from './RequestForm';

Expand Down
2 changes: 0 additions & 2 deletions src/UserDetail.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import {
cleanup,
} from '@folio/jest-config-stripes/testing-library/react';

import '../test/jest/__mock__';

import { NoValue } from '@folio/stripes/components';

import UserDetail from './UserDetail';
Expand Down
1 change: 1 addition & 0 deletions src/UserForm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
render,
screen,
} from '@folio/jest-config-stripes/testing-library/react';

import { ProxyManager } from '@folio/stripes/smart-components';

import UserForm from './UserForm';
Expand Down
13 changes: 2 additions & 11 deletions src/ViewRequest.test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import React from 'react';
import moment from 'moment-timezone';

import {
render,
screen,
} from '@folio/jest-config-stripes/testing-library/react';
import moment from 'moment-timezone';

import '../test/jest/__mock__';

import {
Pane,
CommandList,
defaultKeyboardShortcuts,
} from '@folio/stripes/components';
Expand All @@ -34,12 +31,6 @@ jest.mock('./UserDetail', () => jest.fn(() => null));
jest.mock('./CancelRequestDialog', () => jest.fn(() => null));
jest.mock('./PositionLink', () => jest.fn(() => null));
jest.mock('./components/TitleInformation', () => jest.fn(() => null));
Pane.mockImplementation(({ children, actionMenu }) => (
<div>
{children}
{actionMenu({ onToggle: jest.fn() })}
</div>
));

describe('ViewRequest', () => {
const labelIds = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/ComponentToPrint/ComponentToPrint.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Parser } from 'html-to-react';

import {
render,
screen,
Expand Down
3 changes: 0 additions & 3 deletions src/components/ErrorModal/ErrorModal.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import {
render,
screen,
Expand All @@ -7,8 +6,6 @@ import {

import { runAxeTest } from '@folio/stripes-testing';

import '../../../test/jest/__mock__';

import ErrorModal from './ErrorModal';

describe('ErrorModal', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { FormattedMessage } from 'react-intl';

import {
render,
screen,
fireEvent,
cleanup,
} from '@folio/jest-config-stripes/testing-library/react';

import '../../../test/jest/__mock__';

import { FormattedMessage } from 'react-intl';

import FulfilmentPreference, {
validate,
} from './FulfilmentPreference';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { useState } from 'react';
import { Field } from 'react-final-form';

import {
render,
screen,
Expand All @@ -7,9 +9,6 @@ import {
waitFor,
} from '@folio/jest-config-stripes/testing-library/react';

import '../../../test/jest/__mock__';

import { Field } from 'react-final-form';
import {
Icon,
TextField,
Expand Down
6 changes: 2 additions & 4 deletions src/components/ItemInformation/ItemInformation.test.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { useState } from 'react';
import { Field } from 'react-final-form';

import {
render,
screen,
fireEvent,
cleanup,
waitFor,
} from '@folio/jest-config-stripes/testing-library/react';

import '../../../test/jest/__mock__';

import { Field } from 'react-final-form';
import {
Icon,
TextField,
Expand Down
2 changes: 0 additions & 2 deletions src/components/Loading/Loading.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import {
screen,
} from '@folio/jest-config-stripes/testing-library/react';

import '../../../test/jest/__mock__';

import { Layout } from '@folio/stripes/components';

import Loading from './Loading';
Expand Down
2 changes: 0 additions & 2 deletions src/components/LoadingButton/LoadingButton.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import {
screen,
} from '@folio/jest-config-stripes/testing-library/react';

import '__mock__';

import {
Button,
Icon,
Expand Down
6 changes: 2 additions & 4 deletions src/components/PrintButton/PrintButton.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import ReactToPrint from 'react-to-print';

import {
render,
screen,
} from '@folio/jest-config-stripes/testing-library/react';

import '../../../test/jest/__mock__';

import ReactToPrint from 'react-to-print';

import PrintButton from './PrintButton';

const testIds = {
Expand Down
2 changes: 0 additions & 2 deletions src/components/PrintContent/PrintContent.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import {
cleanup,
} from '@folio/jest-config-stripes/testing-library/react';

import '../../../test/jest/__mock__';

import PrintContent from './PrintContent';
import ComponentToPrint from '../ComponentToPrint';

Expand Down
2 changes: 0 additions & 2 deletions src/components/ReferredRecord/ReferredRecord.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import '../../../test/jest/__mock__';

import {
render,
screen,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import React from 'react';
import { render } from '@folio/jest-config-stripes/testing-library/react';

import '../../../test/jest/__mock__';

import {
CommandList,
defaultKeyboardShortcuts,
Expand Down
6 changes: 2 additions & 4 deletions src/components/RequestInformation/RequestInformation.test.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { useState } from 'react';
import { Field } from 'react-final-form';

import {
render,
screen,
fireEvent,
cleanup,
} from '@folio/jest-config-stripes/testing-library/react';

import '../../../test/jest/__mock__';

import { Field } from 'react-final-form';

import { Select } from '@folio/stripes/components';

import RequestInformation, {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { useState } from 'react';
import { Field } from 'react-final-form';

import {
render,
screen,
Expand All @@ -7,7 +9,6 @@ import {
waitFor,
} from '@folio/jest-config-stripes/testing-library/react';

import { Field } from 'react-final-form';
import {
Icon,
TextField,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import {
} from '@folio/jest-config-stripes/testing-library/react';
import userEvent from '@folio/jest-config-stripes/testing-library/user-event';

import '__mock__';

import {
Accordion,
FilterAccordionHeader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const RequestLevelFilter = ({
<Accordion
displayClearButton={!isEmpty(activeValues)}
id={name}
data-testid="requestLevelFilter"
header={FilterAccordionHeader}
label={formatMessage({ id: 'ui-requests.requestLevel' })}
name={name}
Expand Down
Loading

0 comments on commit 2d67e36

Please sign in to comment.