Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Select width became 0px when search after select something for a…
…ntd 5 (#936) * fix: Select width 0px when searching (#934) * fix: Select width became 0px when search after select something (#935) * chore: publish on branch 14.1.x * 14.1.17-0 * fix: Select width 0px when search again * fix np branch
- Loading branch information
Showing
5 changed files
with
67 additions
and
64 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
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,45 @@ | ||
import { mount } from 'enzyme'; | ||
import React from 'react'; | ||
import Select from '../src'; | ||
import { toggleOpen } from './utils/common'; | ||
|
||
describe('Select placeholder', () => { | ||
it('when searchValue is controlled', () => { | ||
const wrapper = mount(<Select searchValue="light" placeholder="bamboo" />); | ||
expect( | ||
wrapper.find('.rc-select-selection-placeholder').getDOMNode().hasAttribute('style'), | ||
).toBe(false); | ||
toggleOpen(wrapper); | ||
expect( | ||
(wrapper.find('.rc-select-selection-placeholder').getDOMNode() as HTMLSpanElement).style | ||
.visibility, | ||
).toBe('hidden'); | ||
}); | ||
|
||
it('when value is null', () => { | ||
const wrapper = mount(<Select value={null} placeholder="bamboo" />); | ||
expect(wrapper.find('.rc-select-selection-placeholder').length).toBe(1); | ||
expect(wrapper.find('.rc-select-selection-placeholder').text()).toBe('bamboo'); | ||
}); | ||
|
||
it('not when value is null but it is an Option', () => { | ||
const wrapper = mount( | ||
<Select value={null} placeholder="bamboo" options={[{ value: null, label: 'light' }]} />, | ||
); | ||
expect(wrapper.find('.rc-select-selection-placeholder').length).toBe(0); | ||
expect(wrapper.find('.rc-select-selection-item').text()).toBe('light'); | ||
toggleOpen(wrapper); | ||
expect(wrapper.find('.rc-select-selection-item').text()).toBe('light'); | ||
}); | ||
|
||
it('should hide placeholder if force closed and showSearch with searchValue', () => { | ||
const wrapper = mount( | ||
<Select showSearch searchValue="search" open={false} placeholder="placeholder" />, | ||
); | ||
expect( | ||
(wrapper.find('.rc-select-selection-placeholder').getDOMNode() as HTMLSpanElement).style | ||
.visibility, | ||
).toBe('hidden'); | ||
expect(wrapper.find('.rc-select-selection-placeholder').text()).toBe('placeholder'); | ||
}); | ||
}); |