Skip to content

Commit

Permalink
add subscribe function
Browse files Browse the repository at this point in the history
  • Loading branch information
jribbink committed Nov 24, 2024
1 parent 563c092 commit f10bca0
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/sdk/src/subscribe/subscription-manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,18 @@ describe("SubscriptionManager", () => {
})
expect(mockSubscriptionTransport.subscribe.mock.results[0].value.unsubscribe).toHaveBeenCalledTimes(1)
})

test("receives decoded data from subscription", async () => {
const topic = "topic"
const args = {foo: "bar"}
const onData = jest.fn()
const onError = jest.fn()

const sub = manager.subscribe({topic, args, onData, onError})
const onDataCallback = mockSubscriptionTransport.subscribe.mock.calls[0][0].onData
onDataCallback("data")

expect(onData).toHaveBeenCalledTimes(1)
expect(onData).toHaveBeenCalledWith("data")
})
})

0 comments on commit f10bca0

Please sign in to comment.