Skip to content

Commit

Permalink
tests: add test coverages
Browse files Browse the repository at this point in the history
  • Loading branch information
alisher-epam committed Nov 15, 2023
1 parent eecb03d commit 26b9fdb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/Donors/Donors.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jest.mock('./hooks', () => ({
const defaultProps = {
name: 'donors',
donorOrganizationIds: [],
onChange: jest.fn(),
};

const renderForm = (props = {}) => (
Expand Down
9 changes: 8 additions & 1 deletion lib/Donors/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ import {
getDonorsFormatter,
} from './utils';

const mockOnRemove = jest.fn();
const defaultProps = {
canViewOrganizations: true,
fields: {
remove: jest.fn(),
value: ['1'],
},
intl: {
formatMessage: jest.fn((id) => id),
},
onRemove: jest.fn(),
onRemove: mockOnRemove,
};

describe('getDonorsListFormatter', () => {
Expand All @@ -32,5 +34,10 @@ describe('getDonorsFormatter', () => {
expect(result).toEqual(expect.objectContaining({
unassignDonor: expect.any(Function),
}));

result.unassignDonor({ _index: 0 }).props.onClick({ preventDefault: jest.fn() });

expect(defaultProps.fields.remove).toHaveBeenCalled();
expect(mockOnRemove).toHaveBeenCalled();
});
});

0 comments on commit 26b9fdb

Please sign in to comment.