|
@@ -0,0 +1,26 @@
|
|
|
+describe('Subscription', function()
|
|
|
+ describe('create', function()
|
|
|
+ it('returns a Subscription', function()
|
|
|
+ local subscription = Rx.Subscription.create()
|
|
|
+ expect(subscription).to.be.an(Rx.Subscription)
|
|
|
+ end)
|
|
|
+ end)
|
|
|
+
|
|
|
+ describe('unsubscribe', function()
|
|
|
+ it('runs the function passed to create', function()
|
|
|
+ local unsubscribe = spy()
|
|
|
+ local subscription = Rx.Subscription.create(unsubscribe)
|
|
|
+ subscription:unsubscribe()
|
|
|
+ expect(#unsubscribe).to.equal(1)
|
|
|
+ end)
|
|
|
+
|
|
|
+ it('does not run the function passed to create more than once', function()
|
|
|
+ local unsubscribe = spy()
|
|
|
+ local subscription = Rx.Subscription.create(unsubscribe)
|
|
|
+ subscription:unsubscribe()
|
|
|
+ subscription:unsubscribe()
|
|
|
+ subscription:unsubscribe()
|
|
|
+ expect(#unsubscribe).to.equal(1)
|
|
|
+ end)
|
|
|
+ end)
|
|
|
+end)
|