feature: display only 5 results in filter search (#96)
* feature: display only 5 results in filter search * feature: Display laoding in a dropdown item * test: use testid insread of text
This commit is contained in:
@ -65,7 +65,11 @@ export function FilterDropdownButton<FilterProperties>({
|
||||
selectedFilter: FilterType<FilterProperties>,
|
||||
) => {
|
||||
if (filterSearchResults.loading) {
|
||||
return 'LOADING';
|
||||
return (
|
||||
<DropdownButton.StyledDropdownItem data-testid="loading-search-results">
|
||||
Loading
|
||||
</DropdownButton.StyledDropdownItem>
|
||||
);
|
||||
}
|
||||
return filterSearchResults.results.map((value, index) => (
|
||||
<DropdownButton.StyledDropdownItem
|
||||
|
||||
@ -48,6 +48,7 @@ const mocks = [
|
||||
{ lastname: { _ilike: '%%' } },
|
||||
],
|
||||
},
|
||||
limit: 5,
|
||||
},
|
||||
},
|
||||
result: {
|
||||
@ -66,6 +67,7 @@ const mocks = [
|
||||
{ lastname: { _ilike: '%Jane%' } },
|
||||
],
|
||||
},
|
||||
limit: 5,
|
||||
},
|
||||
},
|
||||
result: {
|
||||
|
||||
@ -84,7 +84,7 @@ it('Checks the selection of top option for Doesnot include', async () => {
|
||||
|
||||
it('Calls the filters when typing a new name', async () => {
|
||||
const setFilters = jest.fn();
|
||||
const { getByText, getByPlaceholderText, queryByText } = render(
|
||||
const { getByText, getByPlaceholderText, queryByText, getByTestId } = render(
|
||||
<RegularFilterDropdownButton setFilter={setFilters} />,
|
||||
);
|
||||
|
||||
@ -100,7 +100,7 @@ it('Calls the filters when typing a new name', async () => {
|
||||
fireEvent.change(filterSearch, { target: { value: 'Jane' } });
|
||||
|
||||
await waitFor(() => {
|
||||
const loadingDiv = getByText('LOADING');
|
||||
const loadingDiv = getByTestId('loading-search-results');
|
||||
expect(loadingDiv).toBeDefined();
|
||||
});
|
||||
|
||||
|
||||
@ -72,6 +72,7 @@ export const useSearch = (): [
|
||||
{
|
||||
variables: {
|
||||
where,
|
||||
limit: 5,
|
||||
},
|
||||
skip: !filter,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user