File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,6 +2,10 @@ import React from 'react';
22import { Provider } from 'react-redux' ;
33import { mount } from 'enzyme' ;
44import HoverableContainer from '../src/HoverableContainer' ;
5+ import {
6+ HOVER ,
7+ UNHOVER ,
8+ } from '../src/action' ;
59
610const 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} ) ;
You can’t perform that action at this time.
0 commit comments