Skip to content
Permalink
Browse files

fix(actions): Wasn't actually emitting the correct actions to the act…

…ions Subject
  • Loading branch information...
jayphelps authored and benlesh committed May 12, 2016
1 parent 2f34fb5 commit a1cf32ee92039ee0f2a45653f41a35053b3b9a04
Showing with 34 additions and 1 deletion.
  1. +1 −1 src/middleware.js
  2. +33 −0 test/middleware-spec.js
@@ -9,9 +9,9 @@ export function reduxObservable() {
if (typeof action === 'function') {
let obs = from(action(actions, store));
let sub = obs.subscribe(next);
actions.next(action);
return sub;
} else {
actions.next(action);
return next(action);
}
};
@@ -114,4 +114,37 @@ describe('reduxObservable', () => {
done();
}, 100);
});

it('should emit POJO actions to the actions Subject', (done) => {
const reducer = (state = [], action) => state.concat(action);

const middleware = reduxObservable();

const store = createStore(reducer, applyMiddleware(middleware));

store.dispatch(
(actions) => Observable.of({ type: 'ASYNC_ACTION_2' })
.delay(10)
.takeUntil(actions.filter(action => action.type === 'ASYNC_ACTION_ABORT'))
.merge(
actions.map(
action => ({ type: action.type + '_MERGED' })
)
)
.startWith({ type: 'ASYNC_ACTION_1' })
);

store.dispatch({ type: 'ASYNC_ACTION_ABORT' });

// HACKY: but should work until we use TestScheduler.
setTimeout(() => {
expect(store.getState()).to.deep.equal([
{ type: '@@redux/INIT' },
{ type: 'ASYNC_ACTION_1' },
{ type: 'ASYNC_ACTION_ABORT_MERGED' },
{ type: 'ASYNC_ACTION_ABORT' }
]);
done();
}, 100);
});
});

0 comments on commit a1cf32e

Please sign in to comment.
You can’t perform that action at this time.