From 57ef046501d7aeb68fe6030f08b559fbd436c20b Mon Sep 17 00:00:00 2001 From: Oleksandr Hladchenko1 Date: Thu, 4 Jan 2024 14:21:26 +0200 Subject: [PATCH] UIPFIMP-65: Increase test coverage for FindImportProfile.js --- .../FindImportProfile.test.js | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/FindImportProfile/FindImportProfile.test.js b/src/FindImportProfile/FindImportProfile.test.js index 9e5a318..4b6d9b0 100644 --- a/src/FindImportProfile/FindImportProfile.test.js +++ b/src/FindImportProfile/FindImportProfile.test.js @@ -16,6 +16,7 @@ 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 +59,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 +89,7 @@ jest.mock('./utils/fetchAssociations', () => ({ content: { id: 'testActionProfileId' }, contentType: 'ACTION_PROFILE', order: 0, - childSnapshotWrappers: [{ contentType: 'MAPPING_PROFILE' }], + childSnapshotWrappers: [{ contentType: 'ACTION_PROFILE' }], })), })); @@ -126,6 +131,10 @@ const renderFindImportProfile = ({ }; describe('FindImportProfile', () => { + beforeEach(() => { + listTemplate.mockClear(); + }); + it('should render with no axe errors', async () => { const { container } = renderFindImportProfile(findImportProfileProps); @@ -149,6 +158,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 () => {