2017-02-26 16:48:42 +08:00
|
|
|
import React from 'react';
|
|
|
|
import { render, mount } from 'enzyme';
|
2017-03-28 13:51:58 +08:00
|
|
|
import KeyCode from 'rc-util/lib/KeyCode';
|
2017-02-26 16:48:42 +08:00
|
|
|
import Cascader from '..';
|
2017-11-19 01:41:40 +08:00
|
|
|
import focusTest from '../../../tests/shared/focusTest';
|
2017-02-26 16:48:42 +08:00
|
|
|
|
2018-12-07 16:17:45 +08:00
|
|
|
const options = [
|
|
|
|
{
|
|
|
|
value: 'zhejiang',
|
|
|
|
label: 'Zhejiang',
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
value: 'hangzhou',
|
|
|
|
label: 'Hangzhou',
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
value: 'xihu',
|
|
|
|
label: 'West Lake',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 'jiangsu',
|
|
|
|
label: 'Jiangsu',
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
value: 'nanjing',
|
|
|
|
label: 'Nanjing',
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
value: 'zhonghuamen',
|
|
|
|
label: 'Zhong Hua Men',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
];
|
2017-02-26 16:48:42 +08:00
|
|
|
|
2018-05-25 19:31:34 +08:00
|
|
|
function filter(inputValue, path) {
|
2018-12-07 16:17:45 +08:00
|
|
|
return path.some(option => option.label.toLowerCase().indexOf(inputValue.toLowerCase()) > -1);
|
2018-05-25 19:31:34 +08:00
|
|
|
}
|
|
|
|
|
2017-02-26 16:48:42 +08:00
|
|
|
describe('Cascader', () => {
|
2017-11-19 01:41:40 +08:00
|
|
|
focusTest(Cascader);
|
|
|
|
|
2017-02-26 16:48:42 +08:00
|
|
|
it('popup correctly when panel is hidden', () => {
|
2018-12-07 16:17:45 +08:00
|
|
|
const wrapper = mount(<Cascader options={options} />);
|
|
|
|
expect(
|
|
|
|
render(
|
|
|
|
wrapper
|
|
|
|
.find('Trigger')
|
|
|
|
.instance()
|
|
|
|
.getComponent(),
|
|
|
|
),
|
|
|
|
).toMatchSnapshot();
|
2017-02-26 16:48:42 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
it('popup correctly when panel is open', () => {
|
2018-05-25 19:31:34 +08:00
|
|
|
const onPopupVisibleChange = jest.fn();
|
2017-02-26 16:48:42 +08:00
|
|
|
const wrapper = mount(
|
2018-12-07 16:17:45 +08:00
|
|
|
<Cascader options={options} onPopupVisibleChange={onPopupVisibleChange} />,
|
2017-02-26 16:48:42 +08:00
|
|
|
);
|
|
|
|
wrapper.find('input').simulate('click');
|
2018-12-07 16:17:45 +08:00
|
|
|
expect(
|
|
|
|
render(
|
|
|
|
wrapper
|
|
|
|
.find('Trigger')
|
|
|
|
.instance()
|
|
|
|
.getComponent(),
|
|
|
|
),
|
|
|
|
).toMatchSnapshot();
|
2018-05-25 19:31:34 +08:00
|
|
|
expect(onPopupVisibleChange).toHaveBeenCalledWith(true);
|
2017-02-26 16:48:42 +08:00
|
|
|
});
|
|
|
|
|
2018-03-23 19:19:29 +08:00
|
|
|
it('support controlled mode', () => {
|
2018-12-07 16:17:45 +08:00
|
|
|
const wrapper = mount(<Cascader options={options} />);
|
2018-03-23 19:19:29 +08:00
|
|
|
wrapper.setProps({
|
|
|
|
value: ['zhejiang', 'hangzhou', 'xihu'],
|
|
|
|
});
|
|
|
|
expect(wrapper.render()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
2017-02-26 16:48:42 +08:00
|
|
|
it('popup correctly with defaultValue', () => {
|
2018-12-07 16:17:45 +08:00
|
|
|
const wrapper = mount(<Cascader options={options} defaultValue={['zhejiang', 'hangzhou']} />);
|
2017-02-26 16:48:42 +08:00
|
|
|
wrapper.find('input').simulate('click');
|
2018-12-07 16:17:45 +08:00
|
|
|
expect(
|
|
|
|
render(
|
|
|
|
wrapper
|
|
|
|
.find('Trigger')
|
|
|
|
.instance()
|
|
|
|
.getComponent(),
|
|
|
|
),
|
|
|
|
).toMatchSnapshot();
|
2017-02-26 16:48:42 +08:00
|
|
|
});
|
|
|
|
|
2018-05-25 19:31:34 +08:00
|
|
|
it('should support popupVisible', () => {
|
2018-12-07 16:17:45 +08:00
|
|
|
const wrapper = mount(<Cascader options={options} defaultValue={['zhejiang', 'hangzhou']} />);
|
|
|
|
expect(
|
|
|
|
wrapper
|
|
|
|
.find('Trigger')
|
|
|
|
.instance()
|
|
|
|
.getComponent().props.visible,
|
|
|
|
).toBe(false);
|
2018-05-25 19:31:34 +08:00
|
|
|
wrapper.setProps({ popupVisible: true });
|
2018-12-07 16:17:45 +08:00
|
|
|
expect(
|
|
|
|
wrapper
|
|
|
|
.find('Trigger')
|
|
|
|
.instance()
|
|
|
|
.getComponent().props.visible,
|
|
|
|
).toBe(true);
|
2018-05-25 19:31:34 +08:00
|
|
|
});
|
|
|
|
|
2017-02-26 16:48:42 +08:00
|
|
|
it('can be selected', () => {
|
2018-05-25 19:31:34 +08:00
|
|
|
const onChange = jest.fn();
|
|
|
|
const wrapper = mount(<Cascader options={options} onChange={onChange} />);
|
2017-02-26 16:48:42 +08:00
|
|
|
wrapper.find('input').simulate('click');
|
2018-12-07 16:17:45 +08:00
|
|
|
let popupWrapper = mount(
|
|
|
|
wrapper
|
|
|
|
.find('Trigger')
|
|
|
|
.instance()
|
|
|
|
.getComponent(),
|
|
|
|
);
|
|
|
|
popupWrapper
|
|
|
|
.find('.ant-cascader-menu')
|
|
|
|
.at(0)
|
|
|
|
.find('.ant-cascader-menu-item')
|
|
|
|
.at(0)
|
2017-02-26 16:48:42 +08:00
|
|
|
.simulate('click');
|
2018-12-07 16:17:45 +08:00
|
|
|
expect(
|
|
|
|
render(
|
|
|
|
wrapper
|
|
|
|
.find('Trigger')
|
|
|
|
.instance()
|
|
|
|
.getComponent(),
|
|
|
|
),
|
|
|
|
).toMatchSnapshot();
|
|
|
|
popupWrapper = mount(
|
|
|
|
wrapper
|
|
|
|
.find('Trigger')
|
|
|
|
.instance()
|
|
|
|
.getComponent(),
|
|
|
|
);
|
|
|
|
popupWrapper
|
|
|
|
.find('.ant-cascader-menu')
|
|
|
|
.at(1)
|
|
|
|
.find('.ant-cascader-menu-item')
|
|
|
|
.at(0)
|
2017-02-26 16:48:42 +08:00
|
|
|
.simulate('click');
|
2018-12-07 16:17:45 +08:00
|
|
|
expect(
|
|
|
|
render(
|
|
|
|
wrapper
|
|
|
|
.find('Trigger')
|
|
|
|
.instance()
|
|
|
|
.getComponent(),
|
|
|
|
),
|
|
|
|
).toMatchSnapshot();
|
|
|
|
popupWrapper = mount(
|
|
|
|
wrapper
|
|
|
|
.find('Trigger')
|
|
|
|
.instance()
|
|
|
|
.getComponent(),
|
|
|
|
);
|
|
|
|
popupWrapper
|
|
|
|
.find('.ant-cascader-menu')
|
|
|
|
.at(2)
|
|
|
|
.find('.ant-cascader-menu-item')
|
|
|
|
.at(0)
|
2017-02-26 16:48:42 +08:00
|
|
|
.simulate('click');
|
2018-12-07 16:17:45 +08:00
|
|
|
expect(
|
|
|
|
render(
|
|
|
|
wrapper
|
|
|
|
.find('Trigger')
|
|
|
|
.instance()
|
|
|
|
.getComponent(),
|
|
|
|
),
|
|
|
|
).toMatchSnapshot();
|
2018-05-25 19:31:34 +08:00
|
|
|
expect(onChange).toHaveBeenCalledWith(['zhejiang', 'hangzhou', 'xihu'], expect.anything());
|
2017-02-26 16:48:42 +08:00
|
|
|
});
|
2017-03-28 13:51:58 +08:00
|
|
|
|
|
|
|
it('backspace should work with `Cascader[showSearch]`', () => {
|
|
|
|
const wrapper = mount(<Cascader options={options} showSearch />);
|
|
|
|
wrapper.find('input').simulate('change', { target: { value: '123' } });
|
|
|
|
expect(wrapper.state('inputValue')).toBe('123');
|
|
|
|
wrapper.find('input').simulate('keydown', { keyCode: KeyCode.BACKSPACE });
|
|
|
|
// Simulate onKeyDown will not trigger onChange by default, so the value is still '123'
|
|
|
|
expect(wrapper.state('inputValue')).toBe('123');
|
|
|
|
});
|
2018-05-25 19:31:34 +08:00
|
|
|
|
|
|
|
it('should highlight keyword and filter when search in Cascader', () => {
|
|
|
|
const wrapper = mount(<Cascader options={options} showSearch={{ filter }} />);
|
|
|
|
wrapper.find('input').simulate('click');
|
|
|
|
wrapper.find('input').simulate('change', { target: { value: 'z' } });
|
|
|
|
expect(wrapper.state('inputValue')).toBe('z');
|
2018-12-07 16:17:45 +08:00
|
|
|
const popupWrapper = mount(
|
|
|
|
wrapper
|
|
|
|
.find('Trigger')
|
|
|
|
.instance()
|
|
|
|
.getComponent(),
|
|
|
|
);
|
2018-05-25 19:31:34 +08:00
|
|
|
expect(popupWrapper).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render not found content', () => {
|
|
|
|
const wrapper = mount(<Cascader options={options} showSearch={{ filter }} />);
|
|
|
|
wrapper.find('input').simulate('click');
|
|
|
|
wrapper.find('input').simulate('change', { target: { value: '__notfoundkeyword__' } });
|
|
|
|
expect(wrapper.state('inputValue')).toBe('__notfoundkeyword__');
|
2018-12-07 16:17:45 +08:00
|
|
|
const popupWrapper = mount(
|
|
|
|
wrapper
|
|
|
|
.find('Trigger')
|
|
|
|
.instance()
|
|
|
|
.getComponent(),
|
|
|
|
);
|
2018-05-25 19:31:34 +08:00
|
|
|
expect(popupWrapper).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should support to clear selection', () => {
|
|
|
|
const wrapper = mount(<Cascader options={options} defaultValue={['zhejiang', 'hangzhou']} />);
|
|
|
|
expect(wrapper.find('.ant-cascader-picker-label').text()).toBe('Zhejiang / Hangzhou');
|
2018-12-07 16:17:45 +08:00
|
|
|
wrapper
|
|
|
|
.find('.ant-cascader-picker-clear')
|
|
|
|
.at(0)
|
|
|
|
.simulate('click');
|
2018-05-25 19:31:34 +08:00
|
|
|
expect(wrapper.find('.ant-cascader-picker-label').text()).toBe('');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should close popup when clear selection', () => {
|
|
|
|
const onPopupVisibleChange = jest.fn();
|
|
|
|
const wrapper = mount(
|
|
|
|
<Cascader
|
|
|
|
options={options}
|
|
|
|
popupVisible
|
|
|
|
defaultValue={['zhejiang', 'hangzhou']}
|
|
|
|
onPopupVisibleChange={onPopupVisibleChange}
|
2018-12-07 16:17:45 +08:00
|
|
|
/>,
|
2018-05-25 19:31:34 +08:00
|
|
|
);
|
2018-12-07 16:17:45 +08:00
|
|
|
wrapper
|
|
|
|
.find('.ant-cascader-picker-clear')
|
|
|
|
.at(0)
|
|
|
|
.simulate('click');
|
2018-05-25 19:31:34 +08:00
|
|
|
expect(onPopupVisibleChange).toHaveBeenCalledWith(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should clear search input when clear selection', () => {
|
|
|
|
const wrapper = mount(
|
2018-12-07 16:17:45 +08:00
|
|
|
<Cascader options={options} defaultValue={['zhejiang', 'hangzhou']} showSearch />,
|
2018-05-25 19:31:34 +08:00
|
|
|
);
|
|
|
|
wrapper.find('input').simulate('click');
|
|
|
|
wrapper.find('input').simulate('change', { target: { value: 'xxx' } });
|
|
|
|
expect(wrapper.state('inputValue')).toBe('xxx');
|
2018-12-07 16:17:45 +08:00
|
|
|
wrapper
|
|
|
|
.find('.ant-cascader-picker-clear')
|
|
|
|
.at(0)
|
|
|
|
.simulate('click');
|
2018-05-25 19:31:34 +08:00
|
|
|
expect(wrapper.state('inputValue')).toBe('');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not trigger visible change when click search input', () => {
|
|
|
|
const onPopupVisibleChange = jest.fn();
|
|
|
|
const wrapper = mount(
|
2018-12-07 16:17:45 +08:00
|
|
|
<Cascader options={options} showSearch onPopupVisibleChange={onPopupVisibleChange} />,
|
2018-05-25 19:31:34 +08:00
|
|
|
);
|
|
|
|
wrapper.find('input').simulate('focus');
|
|
|
|
expect(onPopupVisibleChange).toHaveBeenCalledTimes(0);
|
|
|
|
wrapper.find('input').simulate('click');
|
|
|
|
expect(onPopupVisibleChange).toHaveBeenCalledTimes(1);
|
|
|
|
wrapper.find('input').simulate('click');
|
|
|
|
expect(onPopupVisibleChange).toHaveBeenCalledTimes(1);
|
|
|
|
wrapper.find('input').simulate('blur');
|
|
|
|
wrapper.setState({ popupVisible: false });
|
|
|
|
wrapper.find('input').simulate('click');
|
|
|
|
expect(onPopupVisibleChange).toHaveBeenCalledTimes(2);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should change filtered item when options are changed', () => {
|
|
|
|
const wrapper = mount(<Cascader options={options} showSearch={{ filter }} />);
|
|
|
|
wrapper.find('input').simulate('click');
|
|
|
|
wrapper.find('input').simulate('change', { target: { value: 'a' } });
|
|
|
|
expect(wrapper.find('.ant-cascader-menu-item').length).toBe(2);
|
|
|
|
wrapper.setProps({ options: [options[0]] });
|
|
|
|
expect(wrapper.find('.ant-cascader-menu-item').length).toBe(1);
|
|
|
|
});
|
2018-07-28 13:29:39 +08:00
|
|
|
|
|
|
|
it('can use fieldNames', () => {
|
2018-12-07 16:17:45 +08:00
|
|
|
const customerOptions = [
|
|
|
|
{
|
|
|
|
code: 'zhejiang',
|
|
|
|
name: 'Zhejiang',
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
code: 'hangzhou',
|
|
|
|
name: 'Hangzhou',
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
code: 'xihu',
|
|
|
|
name: 'West Lake',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
code: 'jiangsu',
|
|
|
|
name: 'Jiangsu',
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
code: 'nanjing',
|
|
|
|
name: 'Nanjing',
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
code: 'zhonghuamen',
|
|
|
|
name: 'Zhong Hua Men',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
];
|
2018-11-06 12:36:03 +08:00
|
|
|
const wrapper = mount(
|
|
|
|
<Cascader
|
|
|
|
options={customerOptions}
|
|
|
|
fieldNames={{
|
|
|
|
children: 'items',
|
|
|
|
label: 'name',
|
|
|
|
value: 'code',
|
|
|
|
}}
|
2018-12-07 16:17:45 +08:00
|
|
|
/>,
|
2018-11-06 12:36:03 +08:00
|
|
|
);
|
|
|
|
wrapper.instance().handleChange(['zhejiang', 'hangzhou', 'xihu'], customerOptions);
|
2018-12-07 16:17:45 +08:00
|
|
|
expect(
|
|
|
|
wrapper
|
|
|
|
.find('.ant-cascader-picker-label')
|
|
|
|
.text()
|
|
|
|
.split('/').length,
|
|
|
|
).toBe(3);
|
2018-11-06 12:36:03 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
// https://github.com/ant-design/ant-design/issues/12970
|
|
|
|
it('can use filedNames too, for compatibility', () => {
|
|
|
|
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
2018-12-07 16:17:45 +08:00
|
|
|
const customerOptions = [
|
|
|
|
{
|
|
|
|
code: 'zhejiang',
|
|
|
|
name: 'Zhejiang',
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
code: 'hangzhou',
|
|
|
|
name: 'Hangzhou',
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
code: 'xihu',
|
|
|
|
name: 'West Lake',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
code: 'jiangsu',
|
|
|
|
name: 'Jiangsu',
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
code: 'nanjing',
|
|
|
|
name: 'Nanjing',
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
code: 'zhonghuamen',
|
|
|
|
name: 'Zhong Hua Men',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
];
|
2018-11-06 12:36:03 +08:00
|
|
|
const wrapper = mount(
|
|
|
|
<Cascader
|
|
|
|
options={customerOptions}
|
|
|
|
filedNames={{
|
|
|
|
children: 'items',
|
|
|
|
label: 'name',
|
|
|
|
value: 'code',
|
|
|
|
}}
|
2018-12-07 16:17:45 +08:00
|
|
|
/>,
|
2018-11-06 12:36:03 +08:00
|
|
|
);
|
2018-07-28 13:29:39 +08:00
|
|
|
wrapper.instance().handleChange(['zhejiang', 'hangzhou', 'xihu'], customerOptions);
|
2018-12-07 16:17:45 +08:00
|
|
|
expect(
|
|
|
|
wrapper
|
|
|
|
.find('.ant-cascader-picker-label')
|
|
|
|
.text()
|
|
|
|
.split('/').length,
|
|
|
|
).toBe(3);
|
2018-11-06 12:36:03 +08:00
|
|
|
expect(errorSpy).toHaveBeenLastCalledWith(
|
2018-12-07 16:17:45 +08:00
|
|
|
'Warning: `filedNames` of Cascader is a typo usage and deprecated, please use `fieldNames` instead.',
|
2018-11-06 12:36:03 +08:00
|
|
|
);
|
|
|
|
errorSpy.mockReset();
|
2018-07-28 13:29:39 +08:00
|
|
|
});
|
2018-11-26 11:29:16 +08:00
|
|
|
|
2019-07-09 16:29:42 +08:00
|
|
|
it('should show not found content when options.length is 0', () => {
|
|
|
|
const customerOptions = [];
|
|
|
|
const wrapper = mount(<Cascader options={customerOptions} />);
|
|
|
|
wrapper.find('input').simulate('click');
|
|
|
|
const popupWrapper = mount(
|
|
|
|
wrapper
|
|
|
|
.find('Trigger')
|
|
|
|
.instance()
|
|
|
|
.getComponent(),
|
|
|
|
);
|
|
|
|
expect(popupWrapper).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
2018-11-26 11:29:16 +08:00
|
|
|
describe('limit filtered item count', () => {
|
|
|
|
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
|
|
|
|
|
|
afterAll(() => {
|
|
|
|
errorSpy.mockRestore();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('limit with positive number', () => {
|
|
|
|
const wrapper = mount(<Cascader options={options} showSearch={{ filter, limit: 1 }} />);
|
|
|
|
wrapper.find('input').simulate('click');
|
|
|
|
wrapper.find('input').simulate('change', { target: { value: 'a' } });
|
|
|
|
expect(wrapper.find('.ant-cascader-menu-item').length).toBe(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('not limit', () => {
|
|
|
|
const wrapper = mount(<Cascader options={options} showSearch={{ filter, limit: false }} />);
|
|
|
|
wrapper.find('input').simulate('click');
|
|
|
|
wrapper.find('input').simulate('change', { target: { value: 'a' } });
|
|
|
|
expect(wrapper.find('.ant-cascader-menu-item').length).toBe(2);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('negative limit', () => {
|
|
|
|
const wrapper = mount(<Cascader options={options} showSearch={{ filter, limit: -1 }} />);
|
|
|
|
wrapper.find('input').simulate('click');
|
|
|
|
wrapper.find('input').simulate('change', { target: { value: 'a' } });
|
|
|
|
expect(wrapper.find('.ant-cascader-menu-item').length).toBe(2);
|
2019-04-03 15:54:26 +08:00
|
|
|
expect(errorSpy).toHaveBeenCalledWith(
|
2019-02-27 15:32:29 +08:00
|
|
|
"Warning: [antd: Cascader] 'limit' of showSearch should be positive number or false.",
|
2018-11-26 11:29:16 +08:00
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2019-07-08 10:57:34 +08:00
|
|
|
|
|
|
|
it('should warning if not find `value` in `options`', () => {
|
|
|
|
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
|
|
mount(<Cascader options={[{ label: 'a', value: 'a', children: [{ label: 'b' }] }]} />);
|
|
|
|
expect(errorSpy).toHaveBeenCalledWith(
|
|
|
|
'Warning: [antd: Cascader] Not found `value` in `options`.',
|
|
|
|
);
|
|
|
|
errorSpy.mockRestore();
|
|
|
|
});
|
2019-07-20 12:20:00 +08:00
|
|
|
|
|
|
|
// https://github.com/ant-design/ant-design/issues/17690
|
|
|
|
it('should not breaks when children is null', () => {
|
|
|
|
const optionsWithChildrenNull = [
|
|
|
|
{
|
|
|
|
value: 'zhejiang',
|
|
|
|
label: 'Zhejiang',
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
value: 'hangzhou',
|
|
|
|
label: 'Hangzhou',
|
|
|
|
children: null,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
];
|
|
|
|
expect(() => {
|
|
|
|
mount(<Cascader options={optionsWithChildrenNull} />);
|
|
|
|
}).not.toThrow();
|
|
|
|
});
|
2019-08-17 22:29:02 +08:00
|
|
|
|
|
|
|
// https://github.com/ant-design/ant-design/issues/18176
|
|
|
|
it('have a notFoundContent that fit trigger input width', () => {
|
|
|
|
const wrapper = mount(<Cascader popupVisible options={[]} fieldNames={{ label: 'name', value: 'code', children: 'items' }} />);
|
|
|
|
const popupWrapper = mount(
|
|
|
|
wrapper
|
|
|
|
.find('Trigger')
|
|
|
|
.instance()
|
|
|
|
.getComponent(),
|
|
|
|
);
|
|
|
|
expect(popupWrapper.render()).toMatchSnapshot();
|
|
|
|
});
|
2017-02-26 16:48:42 +08:00
|
|
|
});
|