Last active
March 30, 2016 15:32
-
-
Save dsuket/c814692c58443c2d01372eae7ec58047 to your computer and use it in GitHub Desktop.
Observable Test using RxJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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