|
@@ -12,22 +12,22 @@ describe('Observer', function()
|
|
|
end)
|
|
|
|
|
|
it('works when onNext callback parameter is passed', function()
|
|
|
- local observer = Rx.Observer.create(function () end)
|
|
|
+ local observer = Rx.Observer.create(function() end)
|
|
|
expectObserverToBeInCleanStateAndValid(observer)
|
|
|
end)
|
|
|
|
|
|
it('works when onError callback parameter is passed', function()
|
|
|
- local observer = Rx.Observer.create(nil, function () end)
|
|
|
+ local observer = Rx.Observer.create(nil, function() end)
|
|
|
expectObserverToBeInCleanStateAndValid(observer)
|
|
|
end)
|
|
|
|
|
|
it('works when onComplete callback parameter is passed', function()
|
|
|
- local observer = Rx.Observer.create(nil, nil, function () end)
|
|
|
+ local observer = Rx.Observer.create(nil, nil, function() end)
|
|
|
expectObserverToBeInCleanStateAndValid(observer)
|
|
|
end)
|
|
|
|
|
|
it('works when all callback parameters are passed', function()
|
|
|
- local observer = Rx.Observer.create(function () end, function () end, function () end)
|
|
|
+ local observer = Rx.Observer.create(function() end, function() end, function() end)
|
|
|
expectObserverToBeInCleanStateAndValid(observer)
|
|
|
end)
|
|
|
end)
|
|
@@ -53,12 +53,12 @@ describe('Observer', function()
|
|
|
|
|
|
-- would gladly use something like to_not.fail() here but it's
|
|
|
-- not quite good with producing useful error messages
|
|
|
- local success = tryCall(function () observer:onNext() end, errors)
|
|
|
- tryCall(function () expect(success).to.equal(true) end, errors)
|
|
|
+ local success = tryCall(function() observer:onNext() end, errors)
|
|
|
+ tryCall(function() expect(success).to.equal(true) end, errors)
|
|
|
throwErrorsIfAny(errors)
|
|
|
end)
|
|
|
|
|
|
- describe('does not call custom onError callback', function ()
|
|
|
+ describe('does not call custom onError callback', function()
|
|
|
it('if observer already received completion notification', function()
|
|
|
local onNext = spy()
|
|
|
local observer = Rx.Observer.create(onNext, nil, nil)
|
|
@@ -80,7 +80,7 @@ describe('Observer', function()
|
|
|
describe('onError', function()
|
|
|
it('causes an error by default if custom onError callback was not provided', function()
|
|
|
local observer = Rx.Observer.create()
|
|
|
- expect(function () observer:onError() end).to.fail()
|
|
|
+ expect(function() observer:onError() end).to.fail()
|
|
|
end)
|
|
|
|
|
|
it('calls custom onError callback if it was provided', function()
|
|
@@ -103,7 +103,7 @@ describe('Observer', function()
|
|
|
expect(observer.stopped).to.equal(true)
|
|
|
end)
|
|
|
|
|
|
- describe('does not call custom onError callback', function ()
|
|
|
+ describe('does not call custom onError callback', function()
|
|
|
it('if observer already received completion notification', function()
|
|
|
local onError = spy()
|
|
|
local observer = Rx.Observer.create(nil, onError, nil)
|
|
@@ -115,7 +115,7 @@ describe('Observer', function()
|
|
|
it('if observer already received error notification', function()
|
|
|
local spyEnabled = false
|
|
|
local onError = spy()
|
|
|
- local observer = Rx.Observer.create(nil, function () if spyEnabled then onError() end end, nil)
|
|
|
+ local observer = Rx.Observer.create(nil, function() if spyEnabled then onError() end end, nil)
|
|
|
observer:onError()
|
|
|
spyEnabled = true
|
|
|
observer:onError()
|
|
@@ -145,11 +145,11 @@ describe('Observer', function()
|
|
|
expect(observer.stopped).to.equal(true)
|
|
|
end)
|
|
|
|
|
|
- describe('does not call custom onCompleted callback', function ()
|
|
|
+ describe('does not call custom onCompleted callback', function()
|
|
|
it('if observer already received completion notification', function()
|
|
|
local spyEnabled = false
|
|
|
local onCompleted = spy()
|
|
|
- local observer = Rx.Observer.create(nil, function () if spyEnabled then onCompleted() end end, nil)
|
|
|
+ local observer = Rx.Observer.create(nil, function() if spyEnabled then onCompleted() end end, nil)
|
|
|
observer:onCompleted()
|
|
|
spyEnabled = true
|
|
|
observer:onCompleted()
|
|
@@ -158,7 +158,7 @@ describe('Observer', function()
|
|
|
|
|
|
it('if observer already received error notification', function()
|
|
|
local onCompleted = spy()
|
|
|
- local observer = Rx.Observer.create(nil, function () end, onCompleted)
|
|
|
+ local observer = Rx.Observer.create(nil, function() end, onCompleted)
|
|
|
observer:onError()
|
|
|
observer:onCompleted()
|
|
|
expect(#onCompleted).to.equal(0)
|