Skip to content

Commit

Permalink
UIREQ-939 JEST/RTL test cases for PickupServicePointFilter (#1049)
Browse files Browse the repository at this point in the history
  • Loading branch information
KetineniM authored Jul 12, 2023
1 parent 4293b90 commit c57ab7e
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* Added requestDate token. Refs UIREQ-962.
* Update `request-storage` okapi interface to `6.0` version. Refs UIREQ-963.
* UI tests replacement with RTL/Jest for src/PatronBlockModal.js. Refs UIREQ-878.
* Create Jest/RTL test for PickupServicePointFilter.js Refs UIREQ-939.
* Create Jest/RTL test for RequestsFiltersConfig.js. Refs UIREQ-938.
* Create Jest/RTL test for SortableList.js. Refs UIREQ-941.
* Create Jest/RTL test for draggableRowFormatter.js. Refs UIREQ-942.
Expand Down
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);
});
});
8 changes: 8 additions & 0 deletions test/jest/__mock__/stripesSmartComponents.mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,12 @@ jest.mock('@folio/stripes/smart-components', () => ({
SearchAndSort: jest.fn(() => null),
ViewMetaData: jest.fn(() => null),
withTags: jest.fn((WrappedComponent) => (props) => <WrappedComponent {...props} />),
MultiSelectionFilter: (props) => {
return (
<div>
<div>MultiSelectionFilter</div>
{props.selectedValues}
</div>
);
},
}));

0 comments on commit c57ab7e

Please sign in to comment.