Skip to content

Commit

Permalink
UIPFIMP-65: Increase test coverage for FindImportProfile.js
Browse files Browse the repository at this point in the history
  • Loading branch information
OleksandrHladchenko1 committed Jan 4, 2024
1 parent e02e42d commit 57ef046
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/FindImportProfile/FindImportProfile.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: () => {},
Expand Down Expand Up @@ -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(() => <span>listTemplate</span>),
}));
jest.mock('./FindImportProfileContainer', () => ({
JobProfilesContainer: ({
children,
Expand All @@ -84,7 +89,7 @@ jest.mock('./utils/fetchAssociations', () => ({
content: { id: 'testActionProfileId' },
contentType: 'ACTION_PROFILE',
order: 0,
childSnapshotWrappers: [{ contentType: 'MAPPING_PROFILE' }],
childSnapshotWrappers: [{ contentType: 'ACTION_PROFILE' }],
})),
}));

Expand Down Expand Up @@ -126,6 +131,10 @@ const renderFindImportProfile = ({
};

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

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

Expand All @@ -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 () => {
Expand Down

0 comments on commit 57ef046

Please sign in to comment.