mirror of
https://github.com/re-rxjs/react-rxjs.git
synced 2025-12-08 18:01:51 +00:00
test(shareLatest): recursive sync subscriptions
This commit is contained in:
parent
ca5d2ea5e6
commit
5e9be40398
@ -1,6 +1,7 @@
|
||||
import { TestScheduler } from "rxjs/testing"
|
||||
import { from } from "rxjs"
|
||||
import { from, merge, defer } from "rxjs"
|
||||
import { shareLatest } from "../"
|
||||
import { withLatestFrom, startWith, map } from "rxjs/operators"
|
||||
|
||||
const scheduler = () =>
|
||||
new TestScheduler((actual, expected) => {
|
||||
@ -49,6 +50,29 @@ describe("shareLatest", () => {
|
||||
})
|
||||
})
|
||||
|
||||
// prettier-ignore
|
||||
it("should be able to handle recursively synchronous subscriptions", () => {
|
||||
scheduler().run(({ expectObservable, hot }) => {
|
||||
const values$ = hot('----b-c-d---')
|
||||
const latest$ = hot('----------x-')
|
||||
const expected = ' a---b-c-d-d-'
|
||||
const input$ = merge(
|
||||
values$,
|
||||
latest$.pipe(
|
||||
withLatestFrom(defer(() => result$)),
|
||||
map(([, latest]) => latest)
|
||||
)
|
||||
)
|
||||
|
||||
const result$ = input$.pipe(
|
||||
startWith('a'),
|
||||
shareLatest()
|
||||
)
|
||||
|
||||
expectObservable(result$, '^').toBe(expected)
|
||||
})
|
||||
})
|
||||
|
||||
// prettier-ignore
|
||||
it("should not skip values on a sync source", () => {
|
||||
scheduler().run(({ expectObservable }) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user