diff --git a/lib/Donors/utils.js b/lib/Donors/utils.js index 946fa2ce..973e9504 100644 --- a/lib/Donors/utils.js +++ b/lib/Donors/utils.js @@ -13,7 +13,7 @@ const getDonorUrl = (orgId) => { }; export const getDonorsListFormatter = ({ canViewOrganizations }) => ({ - name: donor => {donor.name}, + name: donor => (canViewOrganizations ? {donor.name} : donor.name), code: donor => donor.code, }); diff --git a/lib/Donors/utils.test.js b/lib/Donors/utils.test.js index a56f1acb..6e5ae59a 100644 --- a/lib/Donors/utils.test.js +++ b/lib/Donors/utils.test.js @@ -39,5 +39,21 @@ describe('getDonorsFormatter', () => { expect(defaultProps.fields.remove).toHaveBeenCalled(); expect(mockOnRemove).toHaveBeenCalled(); + + expect(result.name({ id: '1', name: 'name' })).toEqual(expect.objectContaining({ + props: expect.objectContaining({ + to: '/organizations/view/1', + children: 'name', + }), + })); + }); + + it('should not return link to organization if canViewOrganizations is false', () => { + const result = getDonorsFormatter({ + ...defaultProps, + canViewOrganizations: false, + }); + + expect(result.name({ id: '1', name: 'name' })).toEqual('name'); }); });