Skip to content

Instantly share code, notes, and snippets.

@DanielRamosAcosta
Last active August 14, 2018 20:11
Show Gist options
  • Save DanielRamosAcosta/aef483916e0443d465b98d424f8e0ee5 to your computer and use it in GitHub Desktop.
Save DanielRamosAcosta/aef483916e0443d465b98d424f8e0ee5 to your computer and use it in GitHub Desktop.
RxJS test without marbles diagrams
it('multiplies each number by 2', done => {
const numbers$ = interval(1000).pipe(
take(3),
map(n => n + 1)
)
// This emits: -1-2-3-|
const numbersTwoTimes$ = numTwoTimes(numbers$)
const results: number[] = []
numbersTwoTimes$.subscribe(
n => {
results.push(n)
},
err => {
done(err)
},
() => {
expect(results).toEqual([2, 4, 6])
done()
}
)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment