Trying to get the following click event to pass but not really sure how to call onclick
on document.getElementById('file-input').value
Here is the testfile.js:
beforeEach(() => {
wrapper = shallow(<Component {...baseProps} />
});
it('should call click event on File Input', () => {
baseProps.onClick.mockClear();
wrapper.setProps({});
wrapper.setState({});
wrapper.update();
wrapper.find('#fileinput-testclick').simulate('click');
expect(toJson(wrapper)).toMatchSnapshot();
});
It seems that I can't find #id
. Any reason?
here is file.js
<label
for="file-input"
id="fileinput-testclick"
onClick={() => {
document.getElementById('file-input').value = '';
document.getElementById('file-input').click();
}}
className="tran-button file-button">
{this.state.fileName ? 'Change File' : 'Choose File'}
</label>;