Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UIPFIMP-65: Increase test coverage for FindImportProfile component #150

Merged
merged 4 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change history for ui-plugin-find-import-profile

## **7.1.0** (in progress)

### Features added:
* Jest/RTL: Increase test coverage for FindImportProfile component (UIPFIMP-65)

## [7.0.0](https://github.com/folio-org/ui-plugin-find-import-profile/tree/v7.0.0) (2023-10-13)

### Features added:
Expand Down
22 changes: 21 additions & 1 deletion src/FindImportProfile/FindImportProfile.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
import { renderWithIntl } from '@folio/stripes-data-transfer-components/test/jest/helpers';

import '../../test/jest/__mock__';
import { buildStripes } from '../../test/jest/helpers';

Check failure on line 11 in src/FindImportProfile/FindImportProfile.test.js

View workflow job for this annotation

GitHub Actions / github-actions-ci

'/home/runner/work/ui-plugin-find-import-profile/ui-plugin-find-import-profile/test/jest/helpers/index.js' imported multiple times

Check failure on line 11 in src/FindImportProfile/FindImportProfile.test.js

View workflow job for this annotation

GitHub Actions / github-actions-ci

'/home/runner/work/ui-plugin-find-import-profile/ui-plugin-find-import-profile/test/jest/helpers/index.js' imported multiple times
import { translationsProperties } from '../../test/jest/helpers';

Check failure on line 12 in src/FindImportProfile/FindImportProfile.test.js

View workflow job for this annotation

GitHub Actions / github-actions-ci

'/home/runner/work/ui-plugin-find-import-profile/ui-plugin-find-import-profile/test/jest/helpers/index.js' imported multiple times

Check failure on line 12 in src/FindImportProfile/FindImportProfile.test.js

View workflow job for this annotation

GitHub Actions / github-actions-ci

'/home/runner/work/ui-plugin-find-import-profile/ui-plugin-find-import-profile/test/jest/helpers/index.js' imported multiple times

import FindImportProfile from './FindImportProfile';

import { fetchAssociations } from './utils/fetchAssociations';
import { PluginFindRecordModal } from '@folio/stripes-acq-components';
import { ConfirmationModal } from '@folio/stripes/components';
import { listTemplate } from '@folio/stripes-data-transfer-components';

const mockModalProps = {
closeModal: () => {},
Expand Down Expand Up @@ -58,6 +59,10 @@
),
PluginFindRecordModal: jest.fn(() => 'PluginFindRecordModal'),
}));
jest.mock('@folio/stripes-data-transfer-components', () => ({
...jest.requireActual('@folio/stripes-data-transfer-components'),
listTemplate: jest.fn(() => <span>listTemplate</span>),
}));
jest.mock('./FindImportProfileContainer', () => ({
JobProfilesContainer: ({
children,
Expand All @@ -84,7 +89,7 @@
content: { id: 'testActionProfileId' },
contentType: 'ACTION_PROFILE',
order: 0,
childSnapshotWrappers: [{ contentType: 'MAPPING_PROFILE' }],
childSnapshotWrappers: [{ contentType: 'ACTION_PROFILE' }],
})),
}));

Expand Down Expand Up @@ -126,6 +131,10 @@
};

describe('FindImportProfile', () => {
beforeEach(() => {
listTemplate.mockClear();
});

it('should render with no axe errors', async () => {
const { container } = renderFindImportProfile(findImportProfileProps);

Expand All @@ -149,6 +158,17 @@
});
});

describe('when search by a term', () => {
it('should call a proper handler to render new records', async () => {
await act(async () => {
renderFindImportProfile(findImportProfileProps);
PluginFindRecordModal.mock.calls[0][0].onSearchChange('test term');
});

expect(listTemplate).toHaveBeenCalled();
});
});

describe('when saving multiple', () => {
it('should call a proper handler', async () => {
await act(async () => {
Expand Down
Loading