mirror of
https://github.com/Unleash/unleash.git
synced 2025-03-27 00:19:39 +01:00
test: filter selection avoid duplicates (#5636)
This commit is contained in:
parent
d00d27a9ac
commit
adb9ba5c09
@ -81,3 +81,41 @@ test('should keep filters order when adding a new filter', async () => {
|
||||
|
||||
expect(filterTexts).toEqual(['Tags', 'State']);
|
||||
});
|
||||
|
||||
test('should remove selected item from the add filter list', async () => {
|
||||
const availableFilters: IFilterItem[] = [
|
||||
{
|
||||
label: 'State',
|
||||
options: [],
|
||||
filterKey: 'irrelevantKey',
|
||||
singularOperators: ['IRRELEVANT'],
|
||||
pluralOperators: ['IRRELEVANT'],
|
||||
},
|
||||
{
|
||||
label: 'Tags',
|
||||
options: [],
|
||||
filterKey: 'irrelevantKey',
|
||||
singularOperators: ['IRRELEVANT'],
|
||||
pluralOperators: ['IRRELEVANT'],
|
||||
},
|
||||
];
|
||||
|
||||
render(
|
||||
<Filters
|
||||
availableFilters={availableFilters}
|
||||
onChange={() => {}}
|
||||
state={{}}
|
||||
/>,
|
||||
);
|
||||
|
||||
// initial selection list
|
||||
const addFilterButton = screen.getByText('Add Filter');
|
||||
addFilterButton.click();
|
||||
expect(screen.getByRole('menu').textContent).toBe('StateTags');
|
||||
|
||||
screen.getByText('State').click();
|
||||
|
||||
// reduced selection list
|
||||
addFilterButton.click();
|
||||
expect(screen.getByRole('menu').textContent).toBe('Tags');
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user