-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UIREQ-939 JEST/RTL test cases for PickupServicePointFilter (#1049)
- Loading branch information
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/components/RequestsFilters/PickupServicePointFilter/PickupServicePointFilter.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import '__mock__/'; | ||
import { render, screen } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { requestFilterTypes } from '../../../constants'; | ||
import PickupServicePointFilter from './PickupServicePointFilter'; | ||
|
||
const servicePoints = [ | ||
{ | ||
id: requestFilterTypes.PICKUP_SERVICE_POINT, | ||
name: requestFilterTypes.PICKUP_SERVICE_POINT | ||
} | ||
]; | ||
const activeValues = ['test']; | ||
const onChange = jest.fn(); | ||
const onClear = jest.fn(); | ||
describe('PickupServicePointFilter', () => { | ||
const setupPickupServicePointFilter = () => render( | ||
<PickupServicePointFilter | ||
activeValues={activeValues} | ||
servicePoints={servicePoints} | ||
onChange={onChange} | ||
onClear={onClear} | ||
/> | ||
); | ||
beforeEach(() => { | ||
onChange.mockClear(); | ||
onClear.mockClear(); | ||
setupPickupServicePointFilter(); | ||
}); | ||
it('should render MultiSelectionFilter', () => { | ||
const MultiSelectionFilter = screen.getByText('MultiSelectionFilter'); | ||
expect(MultiSelectionFilter).toBeInTheDocument(); | ||
}); | ||
it('MultiSelectionFilter should render with activeValues', () => { | ||
const activeValue = screen.getByText(activeValues[0]); | ||
expect(activeValue).toBeInTheDocument(); | ||
}); | ||
it('should perform onClear event', () => { | ||
const pickupServicePointsButton = screen.getByTestId('clear-pickupServicePoints'); | ||
userEvent.click(pickupServicePointsButton); | ||
expect(onClear).toHaveBeenCalledWith(requestFilterTypes.PICKUP_SERVICE_POINT); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters