Skip to content

Commit

Permalink
Add unsubscription test for zip operator
Browse files Browse the repository at this point in the history
  • Loading branch information
StrangePan committed May 7, 2019
1 parent cf92f8e commit 4a47520
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/zip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@ describe('zip', function()
expect(Rx.Observable.fromRange(1, 5):zip()).to.produce(1, 2, 3, 4, 5)
end)

it('unsubscribes from all input observables', function()
local unsubscribeA = spy()
local subscriptionA = Rx.Subscription.create(unsubscribeA)
local observableA = Rx.Observable.create(function(observer)
return subscriptionA
end)

local unsubscribeB = spy()
local subscriptionB = Rx.Subscription.create(unsubscribeB)
local observableB = Rx.Observable.create(function(observer)
return subscriptionB
end)

local subscription = Rx.Observable.zip(observableA, observableB):subscribe()
subscription:unsubscribe()
expect(#unsubscribeA).to.equal(1)
expect(#unsubscribeB).to.equal(1)
end)

it('groups values produced by the sources by their index', function()
local observableA = Rx.Observable.fromRange(1, 3)
local observableB = Rx.Observable.fromRange(2, 4)
Expand Down

0 comments on commit 4a47520

Please sign in to comment.