mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-11-30 19:18:07 +08:00
feat: update input
This commit is contained in:
parent
6d2c5950f9
commit
71300d0c00
@ -71,6 +71,9 @@ export default {
|
||||
blur () {
|
||||
this.$refs.input.blur()
|
||||
},
|
||||
select () {
|
||||
this.$refs.input.select()
|
||||
},
|
||||
|
||||
getInputClassName () {
|
||||
const { prefixCls, size, disabled } = this.$props
|
||||
|
@ -29,4 +29,91 @@ describe('Input.Search', () => {
|
||||
expect(wrapper.html()).toMatchSnapshot()
|
||||
})
|
||||
})
|
||||
|
||||
it('should disable enter button when disabled prop is true', () => {
|
||||
const wrapper = mount({
|
||||
render () {
|
||||
return <Search placeholder='input search text' enterButton disabled />
|
||||
},
|
||||
})
|
||||
expect(wrapper.findAll('.ant-btn-primary[disabled]')).toHaveLength(1)
|
||||
})
|
||||
|
||||
// it('should trigger onSearch when click search icon', () => {
|
||||
// const onSearch = jest.fn();
|
||||
// const wrapper = mount(
|
||||
// <Search defaultValue="search text" onSearch={onSearch} />
|
||||
// );
|
||||
// wrapper.find('.anticon-search').simulate('click');
|
||||
// expect(onSearch).toHaveBeenCalledTimes(1);
|
||||
// expect(onSearch).toBeCalledWith('search text', expect.objectContaining({
|
||||
// type: 'click',
|
||||
// preventDefault: expect.any(Function),
|
||||
// }));
|
||||
// });
|
||||
|
||||
// it('should trigger onSearch when click search button', () => {
|
||||
// const onSearch = jest.fn();
|
||||
// const wrapper = mount(
|
||||
// <Search defaultValue="search text" enterButton onSearch={onSearch} />
|
||||
// );
|
||||
// wrapper.find('Button').simulate('click');
|
||||
// expect(onSearch).toHaveBeenCalledTimes(1);
|
||||
// expect(onSearch).toBeCalledWith('search text', expect.objectContaining({
|
||||
// type: 'click',
|
||||
// preventDefault: expect.any(Function),
|
||||
// }));
|
||||
// });
|
||||
|
||||
// it('should trigger onSearch when click search button with text', () => {
|
||||
// const onSearch = jest.fn();
|
||||
// const wrapper = mount(
|
||||
// <Search defaultValue="search text" enterButton="button text" onSearch={onSearch} />
|
||||
// );
|
||||
// wrapper.find('Button').simulate('click');
|
||||
// expect(onSearch).toHaveBeenCalledTimes(1);
|
||||
// expect(onSearch).toBeCalledWith('search text', expect.objectContaining({
|
||||
// type: 'click',
|
||||
// preventDefault: expect.any(Function),
|
||||
// }));
|
||||
// });
|
||||
|
||||
// it('should trigger onSearch when click search button with customize button', () => {
|
||||
// const onSearch = jest.fn();
|
||||
// const wrapper = mount(
|
||||
// <Search defaultValue="search text" enterButton={<Button>antd button</Button>} onSearch={onSearch} />
|
||||
// );
|
||||
// wrapper.find('Button').simulate('click');
|
||||
// expect(onSearch).toHaveBeenCalledTimes(1);
|
||||
// expect(onSearch).toBeCalledWith('search text', expect.objectContaining({
|
||||
// type: 'click',
|
||||
// preventDefault: expect.any(Function),
|
||||
// }));
|
||||
// });
|
||||
|
||||
// it('should trigger onSearch when click search button of native', () => {
|
||||
// const onSearch = jest.fn();
|
||||
// const wrapper = mount(
|
||||
// <Search defaultValue="search text" enterButton={<button type="button">antd button</button>} onSearch={onSearch} />
|
||||
// );
|
||||
// wrapper.find('button').simulate('click');
|
||||
// expect(onSearch).toHaveBeenCalledTimes(1);
|
||||
// expect(onSearch).toBeCalledWith('search text', expect.objectContaining({
|
||||
// type: 'click',
|
||||
// preventDefault: expect.any(Function),
|
||||
// }));
|
||||
// });
|
||||
|
||||
// it('should trigger onSearch when press enter', () => {
|
||||
// const onSearch = jest.fn();
|
||||
// const wrapper = mount(
|
||||
// <Search defaultValue="search text" onSearch={onSearch} />
|
||||
// );
|
||||
// wrapper.find('input').simulate('keydown', { key: 'Enter', keyCode: 13 });
|
||||
// expect(onSearch).toHaveBeenCalledTimes(1);
|
||||
// expect(onSearch).toBeCalledWith('search text', expect.objectContaining({
|
||||
// type: 'keydown',
|
||||
// preventDefault: expect.any(Function),
|
||||
// }));
|
||||
// });
|
||||
})
|
||||
|
@ -15,6 +15,10 @@ describe('Input', () => {
|
||||
expect(wrapper.html()).toMatchSnapshot()
|
||||
}, 0)
|
||||
})
|
||||
it('select()', () => {
|
||||
const wrapper = mount(Input)
|
||||
wrapper.vm.select()
|
||||
})
|
||||
})
|
||||
|
||||
focusTest(TextArea)
|
||||
|
@ -19,6 +19,7 @@
|
||||
### Input Events
|
||||
| Events Name | Description | Arguments |
|
||||
| --- | --- | --- |
|
||||
| change | callback when user input | function(e) | |
|
||||
| pressEnter | The callback function that is triggered when Enter key is pressed. | function(e) |
|
||||
|
||||
> When `Input` is used in a `Form.Item` context, if the `Form.Item` has the `id` and `options` props defined
|
||||
|
@ -19,6 +19,7 @@
|
||||
### Input 事件
|
||||
| 事件名称 | 说明 | 回调参数 |
|
||||
| --- | --- | --- |
|
||||
| change | 输入框内容变化时的回调 | function(e) | |
|
||||
| pressEnter | 按下回车的回调 | function(e) |
|
||||
|
||||
> 如果 `Input` 在 `Form.Item` 内,并且 `Form.Item` 设置了 `id` 和 `options` 属性,则 `value` `defaultValue` 和 `id` 属性会被自动设置。
|
||||
|
Loading…
Reference in New Issue
Block a user