Skip to content

Commit

Permalink
tests: add test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
alisher-epam committed Nov 23, 2023
1 parent d79e2c0 commit 2fa695d
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions lib/DonorFilter/PluggableDonorFilter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jest.mock('../Donors', () => ({
...jest.requireActual('../Donors'),
useFetchDonors: jest.fn(() => ({
isLoading: false,
donors: [],
donors: [{ id: '1', name: 'Amazon' }],
})),
DonorsLookup: jest.fn(({ children, ...rest }) => {
return (
Expand Down Expand Up @@ -43,7 +43,7 @@ const renderFilter = (props) => (render(
id="donor"
activeFilters={[]}
labelId={labelId}
name="donor"
name={mockVendorData.name}
onChange={() => {}}
{...props}
/>,
Expand All @@ -67,6 +67,26 @@ describe('PluggableDonorFilter', () => {

expect(addDonorsButton).toBeDefined();
user.click(addDonorsButton);
expect(mockOnAddDonors).toHaveBeenCalledWith({ name: 'donor', values: [mockVendorData.id] });
expect(mockOnAddDonors).toHaveBeenCalledWith({
name: mockVendorData.name,
values: [mockVendorData.id],
});
});

it('should clear all donors', () => {
const mockOnAddDonors = jest.fn();
const { getAllByRole } = renderFilter({
onChange: mockOnAddDonors,
activeFilters: [mockVendorData.id],
});

const clearAllButton = getAllByRole('button')[1];

expect(clearAllButton).toBeDefined();
user.click(clearAllButton);
expect(mockOnAddDonors).toHaveBeenCalledWith({
name: mockVendorData.name,
values: [],
});
});
});

0 comments on commit 2fa695d

Please sign in to comment.