test(input): add testcase for input ref

This commit is contained in:
unix
2020-05-09 11:17:41 +08:00
parent 7c9257543c
commit e746f913bb

View File

@@ -151,4 +151,12 @@ describe('Input', () => {
wrapper.find('#test-icon').simulate('click', nativeEvent)
expect(click).not.toHaveBeenCalled()
})
// check ref is available: https://github.com/zeit-ui/react/issues/189
it('should forward ref by default', () => {
const ref = React.createRef<HTMLInputElement>()
const wrapper = mount(<Input ref={ref} />)
expect(ref.current).not.toBeNull()
expect(() => wrapper.unmount()).not.toThrow()
})
})