diff --git a/CHANGELOG.md b/CHANGELOG.md index 03f12eb..2836ff8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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: diff --git a/src/FindImportProfile/FindImportProfile.test.js b/src/FindImportProfile/FindImportProfile.test.js index 301faf8..3232cfd 100644 --- a/src/FindImportProfile/FindImportProfile.test.js +++ b/src/FindImportProfile/FindImportProfile.test.js @@ -8,14 +8,17 @@ import { runAxeTest } from '@folio/stripes-testing'; import { renderWithIntl } from '@folio/stripes-data-transfer-components/test/jest/helpers'; import '../../test/jest/__mock__'; -import { buildStripes } from '../../test/jest/helpers'; -import { translationsProperties } from '../../test/jest/helpers'; +import { + buildStripes, + translationsProperties, +} from '../../test/jest/helpers'; 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: () => {}, @@ -58,6 +61,10 @@ jest.mock('@folio/stripes-acq-components', () => ({ ), PluginFindRecordModal: jest.fn(() => 'PluginFindRecordModal'), })); +jest.mock('@folio/stripes-data-transfer-components', () => ({ + ...jest.requireActual('@folio/stripes-data-transfer-components'), + listTemplate: jest.fn(() => listTemplate), +})); jest.mock('./FindImportProfileContainer', () => ({ JobProfilesContainer: ({ children, @@ -84,7 +91,7 @@ jest.mock('./utils/fetchAssociations', () => ({ content: { id: 'testActionProfileId' }, contentType: 'ACTION_PROFILE', order: 0, - childSnapshotWrappers: [{ contentType: 'MAPPING_PROFILE' }], + childSnapshotWrappers: [{ contentType: 'ACTION_PROFILE' }], })), })); @@ -126,6 +133,10 @@ const renderFindImportProfile = ({ }; describe('FindImportProfile', () => { + beforeEach(() => { + listTemplate.mockClear(); + }); + it('should render with no axe errors', async () => { const { container } = renderFindImportProfile(findImportProfileProps); @@ -149,6 +160,17 @@ describe('FindImportProfile', () => { }); }); + 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 () => {