-
Notifications
You must be signed in to change notification settings - Fork 3
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
UIPFU-81 - Add jest tests to Filters.js #274
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
55bbc56
temporarily revert some code
Terala-Priyanka 4a609c8
UIPFU-81 - Add jest tests to Filters.js
Terala-Priyanka 6ce37b0
UIPFU-81 - revert previous temp change
Terala-Priyanka d430407
Merge branch 'master' into UIPFU-81
Terala-Priyanka 46d1e8e
UIPFU-81 - cleanup
Terala-Priyanka 17e23df
UIPFU-81 - updated yarn lock file
Terala-Priyanka 32e621a
UIPFU-81 - update change log md file
Terala-Priyanka 3fa040a
UIPFU-81 - update CI workflow to pick jest tests
Terala-Priyanka b98ca26
UIPFU-81 - update test script
Terala-Priyanka 39fa303
UIPFU-81 - include both jest and big test in test scripts
Terala-Priyanka e1be762
UIPFU-81 - remove big test in test scripts
Terala-Priyanka 8356f60
UIPFU-81 - address review comments
Terala-Priyanka 70cc3c4
UIPFU-81 - reorder imports
Terala-Priyanka bc15aab
UIPFU-81 - upgrade actions/upload-artifact to v3 for Jest
Terala-Priyanka 8b29fb0
UIPFU-81 - upgrade actions/upload-artifact to v3 for Bigtest
Terala-Priyanka cfbeb0b
UIPFU-81 - downgrade history package from v4 to v5
Terala-Priyanka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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
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,81 @@ | ||
import { FormattedMessage } from 'react-intl'; | ||
|
||
import { screen } from '@folio/jest-config-stripes/testing-library/react'; | ||
import userEvent from '@folio/jest-config-stripes/testing-library/user-event'; | ||
|
||
import renderWithRouter from 'helpers/renderWithRouter'; | ||
import Filters from './Filters'; | ||
|
||
jest.unmock('@folio/stripes/components'); | ||
|
||
const renderFilters = (props) => renderWithRouter( | ||
<Filters {...props} /> | ||
); | ||
|
||
const props = { | ||
onChangeHandlers : { | ||
checkbox: jest.fn(), | ||
}, | ||
activeFilters: { | ||
state: {}, | ||
string: '', | ||
}, | ||
resultOffset: { | ||
replace: jest.fn(), | ||
update: jest.fn(), | ||
}, | ||
config:[ | ||
{ | ||
label: <FormattedMessage id="ui-plugin-find-user.status" />, | ||
name: 'active', | ||
cql: 'active', | ||
values: [ | ||
{ | ||
name: 'inactive', | ||
cql: 'false', | ||
displayName: <FormattedMessage id="ui-plugin-find-user.inactive" />, | ||
}, | ||
{ | ||
name: 'active', | ||
cql: 'true', | ||
displayName: <FormattedMessage id="ui-plugin-find-user.active" />, | ||
}, | ||
], | ||
}, | ||
{ | ||
label: <FormattedMessage id="ui-plugin-find-user.information.patronGroup" />, | ||
name: 'pg', | ||
cql: 'patronGroup', | ||
values: [], | ||
}, | ||
], | ||
}; | ||
|
||
describe('Filters', () => { | ||
beforeEach(() => { | ||
renderFilters(props); | ||
}); | ||
|
||
it('should render status filter groups', () => { | ||
expect(screen.queryByText('ui-plugin-find-user.status')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render patronGroup filter groups', () => { | ||
expect(screen.queryByText('ui-plugin-find-user.information.patronGroup')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render active status filter', () => { | ||
expect(screen.queryByText('ui-plugin-find-user.active')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render inactive status filter', () => { | ||
expect(screen.getByText('ui-plugin-find-user.inactive')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should call changeHandler on clicking inactive checkbox', async () => { | ||
const inActiveCheckbox = screen.getByRole('checkbox', { name: 'ui-plugin-find-user.inactive' }); | ||
await userEvent.click(inActiveCheckbox); | ||
|
||
expect(props.onChangeHandlers.checkbox).toHaveBeenCalled(); | ||
}); | ||
}); |
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 @@ | ||
jest.mock('currency-codes/data', () => ({ filter: () => [] })); |
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
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,28 @@ | ||
import React from 'react'; | ||
import { IntlProvider } from 'react-intl'; | ||
import { CalloutContext } from '@folio/stripes/core'; | ||
import { Router } from 'react-router-dom'; | ||
import { render } from '@folio/jest-config-stripes/testing-library/react'; | ||
import { createMemoryHistory } from 'history'; | ||
|
||
let rtlApi; | ||
|
||
const renderWithRouter = (children, options = {}) => { | ||
const history = createMemoryHistory(); | ||
const renderFn = options.rerender ? rtlApi.rerender : render; | ||
rtlApi = renderFn( | ||
<Router history={history}> | ||
<CalloutContext.Provider value={{ sendCallout: () => { } }}> | ||
<IntlProvider | ||
locale="en" | ||
messages={{}} | ||
> | ||
{children} | ||
</IntlProvider> | ||
</CalloutContext.Provider> | ||
</Router> | ||
); | ||
return { ...rtlApi, history }; | ||
}; | ||
|
||
export default renderWithRouter; |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Please re-order imports so that first we import third-party modules, then stripes modules, and last is imports from current module. Please also check other files in this PR
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.
Hey @BogdanDenis
Thank you for the insights. I have pushed the change. Could you please re-review it?