-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UIREQ-939 JEST/RTL test cases for PickupServicePointFilter #1049
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add appropriate changes to changelog file?
jest.mock('@folio/stripes/components', () => ({ | ||
Accordion: jest.fn(({ name, children, onClearFilter }) => ( | ||
<div> | ||
<div><button type="button" onClick={() => onClearFilter()} data-testid={`clear-${name}`}>Clear</button></div> | ||
<div data-testid={`accordion-${name}`}>{children}</div> | ||
</div> | ||
)), | ||
FilterAccordionHeader: jest.fn(() => <div>Filter Accordion Header</div>), | ||
})); | ||
|
||
jest.mock('@folio/stripes/smart-components', () => ({ | ||
MultiSelectionFilter: jest.fn(() => <div>Multi Selection Filter</div>) | ||
})); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add mocks to appropriate files here if they does not exist yet - test/jest/__mock__
?
jest.mock('@folio/stripes/components', () => ({ | ||
Accordion: jest.fn(({ name, children, onClearFilter }) => ( | ||
<div> | ||
<div><button type="button" onClick={() => onClearFilter()} data-testid={`clear-${name}`}>Clear</button></div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<div><button type="button" onClick={() => onClearFilter()} data-testid={`clear-${name}`}>Clear</button></div> | |
<div> | |
<button | |
type="button" | |
onClick={onClearFilter} | |
data-testid={`clear-${name}`} | |
>Clear</button> | |
</div> |
expect(pickupServicePointsButton).toBeInTheDocument(); | ||
userEvent.click(pickupServicePointsButton); | ||
expect(onClear).toHaveBeenCalled(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add two separate tests for each expect?
onChange.mockClear(); | ||
onClear.mockClear(); | ||
}); | ||
it('should render the component with default props', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name of the test does not fit test scenario.
Kudos, SonarCloud Quality Gate passed! |
CHANGELOG.md
Outdated
@@ -24,6 +24,8 @@ | |||
* 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. | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you remove empty line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you remove empty line?
<div> | ||
<button | ||
type="button" | ||
onClick={() => onClearFilter()} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onClick={() => onClearFilter()} | |
onClick={onClearFilter} |
{ id: '3', name: 'Service Point 3' }, | ||
]; | ||
|
||
describe('PickupServicePointFilter', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also check that MultiSelectionFilter
is rendered and called with correct props?
); | ||
const pickupServicePointsButton = screen.getByTestId('clear-pickupServicePoints'); | ||
userEvent.click(pickupServicePointsButton); | ||
expect(onClear).toHaveBeenCalled(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be great to check that it was called with correct argument.
</div> | ||
)), | ||
AccordionSet: jest.fn(({ children }) => ( | ||
AccordionSet: jest.fn(({ children, onToggle }) => ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not see the usage of this component inside PickupServicePointFilter
. Do we really need to mock it?
@@ -33,9 +48,23 @@ jest.mock('@folio/stripes/components', () => ({ | |||
{children} | |||
</div> | |||
)), | |||
ConfirmationModal: jest.fn(() => <div>ConfirmationModal</div>), | |||
ConfirmationModal: jest.fn(({ heading, confirmLabel, cancelLabel, onConfirm, onCancel }) => ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not see the usage of this component inside PickupServicePointFilter
. Do we really need to mock it?
Datepicker: jest.fn(() => <div>Datepicker</div>), | ||
ErrorModal: jest.fn(() => <div>ErrorModal</div>), | ||
ErrorModal: jest.fn(({ label, content, buttonLabel, onClose }) => ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not see the usage of this component inside PickupServicePointFilter
. Do we really need to mock it?
@@ -122,7 +151,24 @@ jest.mock('@folio/stripes/components', () => ({ | |||
{children} | |||
</div> | |||
)), | |||
Select: jest.fn(() => <div>Select</div>), | |||
Select: ({ name, label, onChange, required, children, value }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not see the usage of this component inside PickupServicePointFilter
. Do we really need to mock it?
NotesSmartAccordion: jest.fn(() => null), | ||
SearchAndSort: jest.fn(() => null), | ||
ViewMetaData: jest.fn(() => null), | ||
withTags: jest.fn((WrappedComponent) => (props) => <WrappedComponent {...props} />), | ||
ProxyManager: () => (<div data-testid="proxy-manager" />), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not see the usage of this component inside PickupServicePointFilter
. Do we really need to mock it?
@@ -4,8 +4,18 @@ jest.mock('@folio/stripes/smart-components', () => ({ | |||
ClipCopy: jest.fn(() => null), | |||
makeQueryFunction: jest.fn((value) => value), | |||
CheckboxFilter: jest.fn(() => null), | |||
NoteCreatePage: (props) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not see the usage of this component inside PickupServicePointFilter. Do we really need to mock it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not see the usage of this component inside PickupServicePointFilter. Do we really need to mock it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please fix feedbacks?
I have fixed the feedback issues, could you please check and let me know |
Could you please fix feedbacks? |
I have made all the possible changes. Please let me know if there is anything else remaining. |
Accordion: jest.fn(({ children, label, name, onClearFilter }) => ( | ||
<div> | ||
{label} | ||
{children} | ||
<div> | ||
<button | ||
type="button" | ||
onClick={onClearFilter} | ||
data-testid={`clear-${name}`} | ||
>Clear | ||
</button> | ||
</div> | ||
<div data-testid={`accordion-${name}`} /> | ||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accordion: jest.fn(({ children, label, name, onClearFilter }) => ( | |
<div> | |
{label} | |
{children} | |
<div> | |
<button | |
type="button" | |
onClick={onClearFilter} | |
data-testid={`clear-${name}`} | |
>Clear | |
</button> | |
</div> | |
<div data-testid={`accordion-${name}`} /> | |
</div> | |
Accordion: jest.fn(({ children, label, name, onClearFilter }) => ( | |
<div data-testid={`accordion-${name}`} > | |
{label} | |
{children} | |
<div> | |
<button | |
type="button" | |
onClick={onClearFilter} | |
data-testid={`clear-${name}`} | |
>Clear | |
</button> | |
</div> | |
</div> |
@@ -4,8 +4,18 @@ jest.mock('@folio/stripes/smart-components', () => ({ | |||
ClipCopy: jest.fn(() => null), | |||
makeQueryFunction: jest.fn((value) => value), | |||
CheckboxFilter: jest.fn(() => null), | |||
NoteCreatePage: (props) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not see the usage of this component inside PickupServicePointFilter. Do we really need to mock it?
expect(MultiSelectionFilter).toBeInTheDocument(); | ||
}); | ||
it('MultiSelectionFilter should render with activeValues', () => { | ||
const activeValue = screen.getByText('test'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const activeValue = screen.getByText('test'); | |
const activeValue = screen.getByText(activeValues[0]); |
@@ -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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you move it to the bottom of the list?
Kudos, SonarCloud Quality Gate passed! |
UIREQ-939 JEST/RTL test cases for PickupServicePointFilter
URL: https://issues.folio.org/browse/UIREQ-939