mirror of
https://github.com/ansible/awx.git
synced 2026-01-13 02:50:02 -03:30
add onShowAdvancedSearch callback test
This commit is contained in:
parent
a352de3da7
commit
1323626d5e
@ -93,6 +93,52 @@ describe('<Search />', () => {
|
||||
expect(onSearch).toBeCalledWith('description__icontains', 'test-321');
|
||||
});
|
||||
|
||||
test('changing key select to and from advanced causes onShowAdvancedSearch callback to be invoked', () => {
|
||||
const searchButton = 'button[aria-label="Search submit button"]';
|
||||
const searchTextInput = 'input[aria-label="Search text input"]';
|
||||
const columns = [
|
||||
{ name: 'Name', key: 'name__icontains', isDefault: true },
|
||||
{ name: 'Description', key: 'description__icontains' },
|
||||
{ name: 'Advanced', key: 'advanced' },
|
||||
];
|
||||
const onSearch = jest.fn();
|
||||
const onShowAdvancedSearch = jest.fn();
|
||||
const wrapper = mountWithContexts(
|
||||
<Toolbar
|
||||
id={`${QS_CONFIG.namespace}-list-toolbar`}
|
||||
clearAllFilters={() => {}}
|
||||
collapseListedFiltersBreakpoint="lg"
|
||||
>
|
||||
<ToolbarContent>
|
||||
<Search
|
||||
qsConfig={QS_CONFIG}
|
||||
columns={columns}
|
||||
onSearch={onSearch}
|
||||
onShowAdvancedSearch={onShowAdvancedSearch}
|
||||
/>
|
||||
</ToolbarContent>
|
||||
</Toolbar>
|
||||
);
|
||||
|
||||
act(() => {
|
||||
wrapper
|
||||
.find('Select[aria-label="Simple key select"]')
|
||||
.invoke('onSelect')({ target: { innerText: 'Advanced' } });
|
||||
});
|
||||
wrapper.update();
|
||||
expect(onShowAdvancedSearch).toHaveBeenCalledTimes(1);
|
||||
expect(onShowAdvancedSearch).toBeCalledWith(true);
|
||||
jest.clearAllMocks();
|
||||
act(() => {
|
||||
wrapper
|
||||
.find('Select[aria-label="Simple key select"]')
|
||||
.invoke('onSelect')({ target: { innerText: 'Description' } });
|
||||
});
|
||||
wrapper.update();
|
||||
expect(onShowAdvancedSearch).toHaveBeenCalledTimes(1);
|
||||
expect(onShowAdvancedSearch).toBeCalledWith(false);
|
||||
});
|
||||
|
||||
test('attempt to search with empty string', () => {
|
||||
const searchButton = 'button[aria-label="Search submit button"]';
|
||||
const searchTextInput = 'input[aria-label="Search text input"]';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user