-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3274 from donatascn/hotfix/disappearing-nested-fi…
…lter-loc-change fix filter condition to work with nested object paths
- Loading branch information
Showing
4 changed files
with
66 additions
and
5 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
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,53 @@ | ||
import React from 'react'; | ||
import expect from 'expect'; | ||
import { render, cleanup, fireEvent } from 'react-testing-library'; | ||
|
||
import { FilterButton } from './FilterButton'; | ||
import TextInput from '../input/TextInput'; | ||
|
||
describe('<FilterButton />', () => { | ||
const defaultProps = { | ||
resource: 'post', | ||
filters: [ | ||
<TextInput source="title" label="Title" />, | ||
<TextInput source="customer.name" label="Name" />, | ||
], | ||
displayedFilters: { | ||
title: true, | ||
"customer.name": true, | ||
}, | ||
showFilter: () => {}, | ||
translate: () => {}, | ||
filterValues: {}, | ||
}; | ||
|
||
afterEach(cleanup); | ||
|
||
describe('filter button', () => { | ||
it('should not be rendered, if all filters are already being displayed', () => { | ||
const { queryByText } = render( | ||
<FilterButton | ||
{...defaultProps} | ||
/> | ||
); | ||
expect(queryByText('ra.action.add_filter')).toBeNull(); | ||
}); | ||
|
||
}); | ||
|
||
describe('filter selection menu', () => { | ||
it('should display only hidden filters', () => { | ||
const hiddenFilter = <TextInput source="Returned" label="Returned" />; | ||
const { queryByText } = render( | ||
<FilterButton | ||
{...defaultProps} | ||
filters={defaultProps.filters.concat(hiddenFilter)} | ||
/> | ||
); | ||
fireEvent.click(queryByText('ra.action.add_filter')); | ||
|
||
expect(queryByText('Returned')).not.toBeNull(); | ||
expect(queryByText('Name')).toBeNull(); | ||
}); | ||
}); | ||
}); |
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