Skip to content

Commit 25f50d0

Browse files
committed
feat(ActionsObservable.of): Added support for ActionsObservable.of(...actions) as shorthand, mostly useful for testing Epics
Closes #98
1 parent b595a56 commit 25f50d0

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/ActionsObservable.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import { Observable } from 'rxjs/Observable';
2+
import { of } from 'rxjs/observable/of';
23
import { filter } from 'rxjs/operator/filter';
34

45
export class ActionsObservable extends Observable {
6+
static of(...actions) {
7+
return new this(of(...actions));
8+
}
9+
510
constructor(actionsSubject) {
611
super();
712
this.source = actionsSubject;

test/ActionsObservable-spec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ describe('ActionsObservable', () => {
1010
expect(ActionsObservable).to.be.a('function');
1111
});
1212

13+
it('should support ActionsObservable.of(...actions)', () => {
14+
const output = [];
15+
const action$ = ActionsObservable.of({ type: 'FIRST', type: 'SECOND' });
16+
action$.subscribe(x => output.push(x));
17+
18+
expect(action$).to.be.an.instanceof(ActionsObservable);
19+
expect(output).to.deep.equal([{ type: 'FIRST', type: 'SECOND' }]);
20+
});
21+
1322
it('should be the type provided to a dispatched function', () => {
1423
let middleware = createEpicMiddleware();
1524
let reducer = (state, action) => {

0 commit comments

Comments
 (0)