Skip to content

Commit 7d09bfd

Browse files
committed
add test for mouseLeave event
1 parent 3f814e4 commit 7d09bfd

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

__tests__/HoverableContainer.jsx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import React from 'react';
22
import { Provider } from 'react-redux';
33
import { mount } from 'enzyme';
44
import HoverableContainer from '../src/HoverableContainer';
5+
import {
6+
HOVER,
7+
UNHOVER,
8+
} from '../src/action';
59

610
const storeFake = state => ({
711
default: () => {},
@@ -77,6 +81,28 @@ describe('HoverableContainer', () => {
7781
);
7882
wrapper.find(HoverableContainer).simulate('mouseEnter');
7983
expect(store.dispatch)
80-
.toBeCalled();
84+
.toBeCalledWith({
85+
type: HOVER,
86+
id,
87+
});
88+
});
89+
90+
it('should dispatch onMouseLeave event', () => {
91+
const text = 'Hi!';
92+
const id = 'someid';
93+
const store = storeFake({});
94+
const wrapper = mount(
95+
<Provider store={store}>
96+
<HoverableContainer id={id}>
97+
<TestComponent>{text}</TestComponent>
98+
</HoverableContainer>
99+
</Provider>,
100+
);
101+
wrapper.find(HoverableContainer).simulate('mouseLeave');
102+
expect(store.dispatch)
103+
.toBeCalledWith({
104+
type: UNHOVER,
105+
id,
106+
});
81107
});
82108
});

0 commit comments

Comments
 (0)