Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 138221

Testing- onClick - document.getElementById

$
0
0

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>;

Viewing all articles
Browse latest Browse all 138221

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>