New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: fix selectPicker when search is controlled and exit Dropdown wit… #2411
Changes from 4 commits
ee681c6
b686373
755930e
61cd20f
99a2b58
b3793f9
d7653ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { render, fireEvent, waitForElementToBeRemoved } from '@testing-library/react'; | ||
import ReactTestUtils from 'react-dom/test-utils'; | ||
import { getDOMNode, getInstance } from '@test/testUtils'; | ||
import SelectPicker from '../SelectPicker'; | ||
|
@@ -400,4 +400,24 @@ describe('SelectPicker', () => { | |
expect(getByTestId('content')).to.have.text('Not selected'); | ||
}); | ||
}); | ||
it('SearchWord should be reset when controlled and triggered off', async () => { | ||
const handleSearch = sinon.spy(); | ||
const Wrapper = () => { | ||
return ( | ||
<> | ||
<button id="exit">exit</button> | ||
<SelectPicker container={container} defaultOpen onSearch={handleSearch} data={data} /> | ||
</> | ||
); | ||
}; | ||
Wrapper.displayName = 'WrapperSelectPicker'; | ||
let { container } = render(<Wrapper />); | ||
const exit = container.querySelector('#exit'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The container doesn't have the getElementById method There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
// close select | ||
fireEvent.mouseDown(exit, { bubbles: true }); | ||
await waitForElementToBeRemoved(document.querySelector('.rs-picker-search-bar-input')); | ||
|
||
assert.isTrue(handleSearch.calledOnce); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid mentioning implementation detail in test cases. Simply use Arguments of onSearch call should also be asserted. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah |
||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary wrapping. Simply
render
the fragment.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah