This is my part of React component
... componentDidMount(): void { window.addEventListener('scroll', this.handleScroll, true); } handleScroll() { const hello = 'assign'; this.setState({blah: 'blah'}); /// whole function is not covered. }...
enzyme test
describe('when is scrolled', () => { beforeEach(() => { wrapper.simulate('scroll', true); <-- simulate scroll }); test('should match snapshot', () => { expect(wrapper).toMatchSnapshot(); <<< should cover `handleScroll` })});
This should cover handleScroll
but enzyme test doesn't cover the whole function (for code coverage)