Skip to content

Commit

Permalink
test(core): missing test for connectFactoryObservable
Browse files Browse the repository at this point in the history
  • Loading branch information
josepot committed Oct 15, 2020
1 parent ce05cf3 commit ea14185
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions packages/core/src/bind/connectFactoryObservable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,30 @@ describe("connectFactoryObservable", () => {

expect(errorCallback).not.toHaveBeenCalled()
})

it("does not resubscribe to an observable that emits synchronously and that does not have a top-level subscription after a re-render", () => {
let nTopSubscriptions = 0

const [useNTopSubscriptions] = bind((id: number) =>
defer(() => {
return of(++nTopSubscriptions + id)
}),
)

const { result, rerender, unmount } = renderHook(() =>
useNTopSubscriptions(0),
)

expect(result.current).toBe(2)

actHook(() => {
rerender()
})
expect(result.current).toBe(2)
expect(nTopSubscriptions).toBe(2)

unmount()
})
})

describe("observable", () => {
Expand Down

0 comments on commit ea14185

Please sign in to comment.