Skip to content

Instantly share code, notes, and snippets.

@chrismay
Created August 1, 2018 11:23
Show Gist options
  • Save chrismay/44d987f7b5c8a6e06ed9dc9ee5c82a4f to your computer and use it in GitHub Desktop.
Save chrismay/44d987f7b5c8a6e06ed9dc9ee5c82a4f to your computer and use it in GitHub Desktop.
Jasmine/Karma test of cold observables
it('delete me', async (done) => {
const addAll = nums => nums.reduce((a, b) => a + b, 0);
const o1 = Observable.of(1);
const o2 = Observable.of(2).delay(1000).shareReplay(1);
const o1p2 = Observable.forkJoin([o1, o2]).pipe(
map(addAll),
shareReplay(1));
const o3 = Observable.of(3);
const o1p2p3 = Observable.forkJoin([o1p2, o3]).pipe(
map(addAll),
);
const val = await o1p2p3.toPromise();
expect(val).toEqual(6);
done();
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment