From 26b9fdb217fa8953514bcccb0101fcea4866911b Mon Sep 17 00:00:00 2001 From: Alisher Musurmonov Date: Wed, 15 Nov 2023 18:25:11 +0500 Subject: [PATCH] tests: add test coverages --- lib/Donors/Donors.test.js | 1 + lib/Donors/utils.test.js | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/Donors/Donors.test.js b/lib/Donors/Donors.test.js index 8980c0a1..eb0a3fb5 100644 --- a/lib/Donors/Donors.test.js +++ b/lib/Donors/Donors.test.js @@ -21,6 +21,7 @@ jest.mock('./hooks', () => ({ const defaultProps = { name: 'donors', donorOrganizationIds: [], + onChange: jest.fn(), }; const renderForm = (props = {}) => ( diff --git a/lib/Donors/utils.test.js b/lib/Donors/utils.test.js index 6e717855..a56f1acb 100644 --- a/lib/Donors/utils.test.js +++ b/lib/Donors/utils.test.js @@ -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', () => { @@ -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(); }); });