Having the following redux-observable epic:
export const mouseEventEpic = (action$, store) =>
action$
::filter(action => action.type === MOUSE_OUT || action.type === MOUSE_OVER)
::debounceTime(200)
::map(action => getMappedAction(action, store));
const getMappedAction = (action, store) => {
switch (action.type) {
case MOUSE_OVER:
return {type: "OVER"};
case MOUSE_OUT:
return {type: "OUT"};
}
};
and the following test
import { expect } from 'chai';
import configureMockStore from 'redux-mock-store';
import { createEpicMiddleware } from 'redux-observable';
import { mouseEventEpic } from '...';
const epicMiddleware = createEpicMiddleware(mouseEventEpic );
const mockStore = configureMockStore([epicMiddleware]);
describe('Epic...', () => {
let store;
beforeEach(() => {
store = mockStore({});
});
it('test...', () => {
store.dispatch({type:'MOUSE_OVER'});
expect(store.getActions()).to.deep.equal([]);
});
});
The store.getActions() returns an array with one action - "MOUSE_OVER". Whereas when removing the debounce it returns another (and the expected) action - "OVER".
I'd like to stub/remove the debounce operator in the test.
Tried to follow the ideas in this link using the sinon stub function with no success.
Some guideline on how to mock a RxJS operator or specifically the debounce/throttle would be appreciated.
Using React, Mocha, Chai, Enzyme...
thanks