Browse Source

Add test cases

pull/15184/head
afc163 6 years ago
parent
commit
216c85211b
No known key found for this signature in database GPG Key ID: 738F973FCE5C6B48
  1. 29
      components/input/__tests__/index.test.js

29
components/input/__tests__/index.test.js

@ -137,6 +137,24 @@ describe('Input.Password', () => {
wrapper.setProps({ visibilityToggle: true });
expect(wrapper.find('.anticon-eye').length).toBe(1);
});
it('should keep focus state', () => {
const wrapper = mount(<Input.Password defaultValue="111" autoFocus />);
expect(document.activeElement).toBe(
wrapper.find('input').at(0).getDOMNode()
);
wrapper
.find('.ant-input-password-icon')
.at(0)
.simulate('mousedown');
wrapper
.find('.ant-input-password-icon')
.at(0)
.simulate('click');
expect(document.activeElement).toBe(
wrapper.find('input').at(0).getDOMNode()
);
});
});
describe('Input allowClear', () => {
@ -216,4 +234,15 @@ describe('Input allowClear', () => {
.getDOMNode().value,
).toBe('111');
});
it('should focus input after clear', () => {
const wrapper = mount(<Input allowClear defaultValue="111" />);
wrapper
.find('.ant-input-clear-icon')
.at(0)
.simulate('click');
expect(document.activeElement).toBe(
wrapper.find('input').at(0).getDOMNode()
);
});
});

Loading…
Cancel
Save