Skip to content

Commit

Permalink
UISACQCOMP-166: fix organizations' list (#734)
Browse files Browse the repository at this point in the history
  • Loading branch information
alisher-epam authored Nov 28, 2023
1 parent ceb761a commit 895016c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Donors/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const getDonorUrl = (orgId) => {
};

export const getDonorsListFormatter = ({ canViewOrganizations }) => ({
name: donor => <TextLink to={getDonorUrl(canViewOrganizations && donor.id)}>{donor.name}</TextLink>,
name: donor => (canViewOrganizations ? <TextLink to={getDonorUrl(donor.id)}>{donor.name}</TextLink> : donor.name),
code: donor => donor.code,
});

Expand Down
16 changes: 16 additions & 0 deletions lib/Donors/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});

0 comments on commit 895016c

Please sign in to comment.