Last active
March 25, 2020 15:45
-
-
Save caasi/ec4388d5c2ec33999f4803f93d5eb6b3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import { of } from 'rxjs'; | |
import { flatMap, tap } from 'rxjs/operators'; | |
describe('containers', () => { | |
it('promise works', () => { | |
const c = | |
Promise.resolve(1).then(a => | |
Promise.resolve(2).then(b => | |
a + b | |
) | |
); | |
return c.then((d: number) => expect(d).toBe(3)); | |
}); | |
it('async/await works', async () => { | |
const a = await Promise.resolve(1); | |
const b = await Promise.resolve(2); | |
const c = a + b; | |
expect(c).toBe(3); | |
}); | |
it('rx works', () => { | |
const c = | |
of(1).pipe(flatMap(a => | |
of(2).pipe(flatMap(b => | |
of(a + b) | |
)) | |
)); | |
c.pipe( | |
tap((d: number) => expect(d).toBe(3)), | |
); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment