Add test cases

This commit is contained in:
afc163 2019-03-05 11:16:13 +08:00
parent 1b713c94e6
commit 216c85211b
No known key found for this signature in database
GPG Key ID: 738F973FCE5C6B48

View File

@ -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()
);
});
});