-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
270 additions
and
55 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
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
57 changes: 57 additions & 0 deletions
57
src/components/Select/__tests__/Select.renderPopup.test.tsx
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,57 @@ | ||
import React from 'react'; | ||
|
||
import userEvent from '@testing-library/user-event'; | ||
|
||
import {SelectQa} from '../constants'; | ||
|
||
import {DEFAULT_OPTIONS, TEST_QA, setup} from './utils'; | ||
|
||
const QA = 'SELECT_RENDER_POPUP_TEST_QA'; | ||
|
||
describe('Select renderPopup', () => { | ||
test('default case', async () => { | ||
const {getByTestId} = setup({ | ||
options: DEFAULT_OPTIONS, | ||
filterable: true, | ||
renderPopup: ({renderFilter, renderList}) => { | ||
return ( | ||
<React.Fragment> | ||
{renderFilter()} | ||
<div data-qa={QA} /> | ||
{renderList()} | ||
</React.Fragment> | ||
); | ||
}, | ||
}); | ||
|
||
const user = userEvent.setup(); | ||
const selectControl = getByTestId(TEST_QA); | ||
// open select popup | ||
await user.click(selectControl); | ||
|
||
const filterInput = getByTestId(SelectQa.FILTER_INPUT); | ||
expect(filterInput).toBeVisible(); | ||
|
||
const list = getByTestId(SelectQa.LIST); | ||
expect(list).toBeVisible(); | ||
|
||
const customPopupDiv = getByTestId(QA); | ||
expect(customPopupDiv).toBeVisible(); | ||
}); | ||
|
||
test('empty options', async () => { | ||
const {getByTestId} = setup({ | ||
options: [], | ||
renderEmptyOptions: () => <div data-qa={QA} />, | ||
renderPopup: ({renderList}) => renderList(), | ||
}); | ||
|
||
const user = userEvent.setup(); | ||
const selectControl = getByTestId(TEST_QA); | ||
// open select popup | ||
await user.click(selectControl); | ||
|
||
const emptyContent = getByTestId(QA); | ||
expect(emptyContent).toBeVisible(); | ||
}); | ||
}); |
Oops, something went wrong.