Skip to content

Commit

Permalink
test: fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alisher-epam committed Nov 15, 2023
1 parent 1bffa0b commit 6567e23
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
19 changes: 18 additions & 1 deletion src/components/POLine/POLineForm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import POLineForm from './POLineForm';
jest.mock('@folio/stripes-acq-components/lib/AcqUnits/AcqUnitsField', () => {
return () => <span>AcqUnitsField</span>;
});
jest.mock('@folio/stripes-acq-components', () => ({
...jest.requireActual('@folio/stripes-acq-components'),
Donors: jest.fn(() => 'Donors'),
}));
jest.mock('@folio/stripes/components', () => ({
...jest.requireActual('@folio/stripes/components'),
collapseAllSections: jest.fn(),
Expand All @@ -29,6 +33,14 @@ jest.mock('react-router', () => ({
useHistory: jest.fn(),
}));
jest.mock('./Location/LocationForm', () => jest.fn().mockReturnValue('LocationForm'));
jest.mock('./hooks', () => ({
...jest.requireActual('./hooks'),
useGetDonorsByFundId: jest.fn().mockReturnValue({
donorOrganizationIds: [],
setDonorIds: jest.fn(),
onDonorRemove: jest.fn(),
}),
}));

const defaultProps = {
onCancel: jest.fn(),
Expand All @@ -37,7 +49,10 @@ const defaultProps = {
batch: jest.fn(),
getRegisteredFields: jest.fn(),
},
initialValues: {},
initialValues: {
donorOrganizationIds: [],
fundDistribution: [],
},
onSubmit: jest.fn(),
handleSubmit: jest.fn(),
pristine: false,
Expand Down Expand Up @@ -96,6 +111,8 @@ const defaultProps = {
linesLimit: 3,
values: {
orderFormat: 'P/E Mix',
donorOrganizationIds: [],
fundDistribution: [],
},
stripes: {},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ export const useGetDonorsByFundId = ({
};

useEffect(() => {
setDonorIds(prevDonorIds => [...prevDonorIds, ...donorOrganizationIds]);
if (donorOrganizationIds.length) {
setDonorIds(prevDonorIds => [...prevDonorIds, ...donorOrganizationIds]);
}
}, [donorOrganizationIds]);

return {
Expand Down

0 comments on commit 6567e23

Please sign in to comment.