Skip to content

Commit

Permalink
feat(ActionsObservable.of): Added support for ActionsObservable.of(..…
Browse files Browse the repository at this point in the history
….actions) as shorthand, mostly useful for testing Epics

Closes #98
  • Loading branch information
jayphelps committed Sep 11, 2016
1 parent b595a56 commit 25f50d0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/ActionsObservable.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { Observable } from 'rxjs/Observable';
import { of } from 'rxjs/observable/of';
import { filter } from 'rxjs/operator/filter';

export class ActionsObservable extends Observable {
static of(...actions) {
return new this(of(...actions));
}

constructor(actionsSubject) {
super();
this.source = actionsSubject;
Expand Down
9 changes: 9 additions & 0 deletions test/ActionsObservable-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ describe('ActionsObservable', () => {
expect(ActionsObservable).to.be.a('function');
});

it('should support ActionsObservable.of(...actions)', () => {
const output = [];
const action$ = ActionsObservable.of({ type: 'FIRST', type: 'SECOND' });
action$.subscribe(x => output.push(x));

expect(action$).to.be.an.instanceof(ActionsObservable);
expect(output).to.deep.equal([{ type: 'FIRST', type: 'SECOND' }]);
});

it('should be the type provided to a dispatched function', () => {
let middleware = createEpicMiddleware();
let reducer = (state, action) => {
Expand Down

0 comments on commit 25f50d0

Please sign in to comment.