Skip to content

Commit

Permalink
test: add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
veinfors committed Mar 14, 2023
1 parent f15e74f commit 44880f1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions apis/nucleus/src/components/listbox/ListBoxInline.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ function ListBoxInline({ options, layout }) {
tabIndex={-1}
title={translator.get('Listbox.Search')}
size="large"
data-testid="search-toggle-btn"
>
<SearchIcon style={{ fontSize: '12px' }} />
</IconButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,9 @@ describe('<ListboxInline />', () => {
const autoSizers = renderer.root.findAllByProps({ 'data-testid': 'virtualized-auto-sizer' });
expect(autoSizers).toHaveLength(1);

const listBoxSearches = renderer.root.findAllByType(ListBoxSearch);
expect(listBoxSearches).toHaveLength(1);
expect(ListBoxSearch.mock.calls[0][0]).toMatchObject({
visible: true,
});
expect(getListboxInlineKeyboardNavigation).toHaveBeenCalledTimes(2);

// TODO: MUIv5
Expand All @@ -195,6 +196,20 @@ describe('<ListboxInline />', () => {
expect(selections.off).not.toHaveBeenCalled();
});

test('should render properly with search toggle option', async () => {
options.search = 'toggle';
await render();

const searchToggleBtns = renderer.root
.findAllByProps({ 'data-testid': 'search-toggle-btn' })
.filter((x) => typeof x.type === 'string'); // removes virtual dom elements

expect(searchToggleBtns).toHaveLength(1);
expect(ListBoxSearch.mock.calls[0][0]).toMatchObject({
visible: false,
});
});

test('should render without toolbar', async () => {
options.toolbar = false;
await render();
Expand Down

0 comments on commit 44880f1

Please sign in to comment.