catch.lua 917 B

12345678910111213141516171819202122232425262728293031
  1. describe('catch', function()
  2. it('ignores errors if no handler is specified', function()
  3. expect(Rx.Observable.throw():catch()).to.produce.nothing()
  4. end)
  5. it('continues producing values from the specified observable if the source errors', function()
  6. local handler = Rx.Subject.create()
  7. local observable = Rx.Observable.create(function(observer)
  8. observer:onNext(1)
  9. observer:onNext(2)
  10. observer:onError('ohno')
  11. observer:onNext(3)
  12. observer:onCompleted()
  13. end)
  14. handler:onNext(5)
  15. local onNext = observableSpy(observable:catch(handler))
  16. handler:onNext(6)
  17. handler:onNext(7)
  18. handler:onCompleted()
  19. expect(onNext).to.equal({{1}, {2}, {6}, {7}})
  20. end)
  21. it('allows a function as an argument', function()
  22. local handler = function() return Rx.Observable.empty() end
  23. expect(Rx.Observable.throw():catch(handler)).to.produce.nothing()
  24. end)
  25. end)