Skip to content

Instantly share code, notes, and snippets.

@dsuket
Last active March 30, 2016 15:32
Show Gist options
  • Save dsuket/c814692c58443c2d01372eae7ec58047 to your computer and use it in GitHub Desktop.
Save dsuket/c814692c58443c2d01372eae7ec58047 to your computer and use it in GitHub Desktop.
Observable Test using RxJS
'use strict';
const assert = require('power-assert');
const {Observable} = require('rxjs/Rx');
describe('Stream', () => {
const expectedCount = 20;
// create something stream
function createStream() {
return Observable.range(0, expectedCount);
}
it('should contain number 10', () => {
const stream$ = createStream().share();
const assertCount$ = stream$
.count()
.map(count => assert(count === expectedCount));
const assertContain$ = stream$
.filter(n => n === 10)
.count()
.map(count => assert(count === 1));
return Observable.merge(
assertCount$,
assertContain$
).toPromise();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment