You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Events like onClick, onMouseEnter and onMouseLeave are not triggered if button is disabled, simulate function works fine for click and mouseenter but it doesn't not work for mouseleave event.
Current behavior
Unlike click and mouseenter, simulate triggers mouseleave for disable button.
import{mount}from'enzyme';describe('button',()=>{it('should not trigger onClick when button is disabled',()=>{consthandleClick=jest.fn();constwrapper=mount(<buttondisabledonClick={handleClick}>
Text
</button>);wrapper.simulate('click');expect(handleClick).not.toHaveBeenCalled();});it('should not trigger onMouseEnter when button is disabled',()=>{consthandleMouseEnter=jest.fn();constwrapper=mount(<buttondisabledonMouseEnter={handleMouseEnter}>
Text
</button>);wrapper.simulate('mouseenter');expect(handleMouseEnter).not.toHaveBeenCalled();});it('should not trigger onMouseLeave when button is disabled',()=>{consthandleMouseLeave=jest.fn();constwrapper=mount(<buttondisabledonMouseLeave={handleMouseLeave}>
Text
</button>);wrapper.simulate('mouseleave');expect(handleMouseLeave).not.toHaveBeenCalled();});});
Third test case (should not trigger onMouseLeave when button is disabled) fails.
Expected behavior
Third test case (should not trigger onMouseLeave when button is disabled) passes.
Your environment
MacOS
Yarn
Visual Studio Code
API
shallow
mount
render
Version
library
version
enzyme
3.11.0
react
16.14.0
react-dom
16.14.0
react-test-renderer
n/a
adapter (below)
Adapter
enzyme-adapter-react-16
enzyme-adapter-react-16.2
enzyme-adapter-react-16.3
enzyme-adapter-react-16.1
enzyme-adapter-react-15
enzyme-adapter-react-15.4
enzyme-adapter-react-14
enzyme-adapter-react-13
enzyme-adapter-react-helper
others ( )
The text was updated successfully, but these errors were encountered:
Events like
onClick
,onMouseEnter
andonMouseLeave
are not triggered if button is disabled, simulate function works fine for click and mouseenter but it doesn't not work for mouseleave event.Current behavior
Unlike click and mouseenter, simulate triggers mouseleave for disable button.
Third test case (
should not trigger onMouseLeave when button is disabled
) fails.Expected behavior
Third test case (
should not trigger onMouseLeave when button is disabled
) passes.Your environment
MacOS
Yarn
Visual Studio Code
API
Version
Adapter
The text was updated successfully, but these errors were encountered: