test: refactor code (#22436)

This commit is contained in:
偏右 2020-03-20 15:48:44 +08:00 committed by GitHub
parent 296072a720
commit f6722eb28b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -503,6 +503,7 @@ describe('Cascader', () => {
});
expect(wrapper.find('input').prop('placeholder')).toBe(customPlaceholder);
});
it('popup correctly with defaultValue RTL', () => {
const wrapper = mount(
<ConfigProvider direction="rtl">
@ -523,6 +524,7 @@ describe('Cascader', () => {
),
).toMatchSnapshot();
});
it('can be selected in RTL direction', () => {
const options2 = [
{

View File

@ -522,10 +522,8 @@ class Cascader extends React.Component<CascaderProps, CascaderState> {
const names: FilledFieldNamesType = getFilledFieldNames(this.props);
if (options && options.length > 0) {
if (state.inputValue) {
options = this.generateFilteredOptions(prefixCls, renderEmpty);
if (isEqual(options, this.cachedOptions)) {
options = this.cachedOptions;
}
const filteredOptions = this.generateFilteredOptions(prefixCls, renderEmpty);
options = isEqual(filteredOptions, this.cachedOptions) ? this.cachedOptions : filteredOptions;
}
} else {
options = [