all.lua 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. describe('all', function()
  2. it('passes through errors', function()
  3. expect(Rx.Observable.throw():all()).to.produce.error()
  4. end)
  5. it('calls onError if the predicate errors', function()
  6. expect(Rx.Observable.fromRange(3):all(error)).to.produce.error()
  7. end)
  8. it('produces an error if the parent errors', function()
  9. expect(Rx.Observable.throw():all(function(x) return x end)).to.produce.error()
  10. end)
  11. it('produces true if all elements satisfy the predicate', function()
  12. local observable = Rx.Observable.fromRange(5):all(function(x) return x < 10 end)
  13. expect(observable).to.produce({{true}})
  14. end)
  15. it('produces false if one element does not satisfy the predicate', function()
  16. local observable = Rx.Observable.fromRange(5):all(function(x) return x ~= 3 end)
  17. expect(observable).to.produce({{false}})
  18. end)
  19. it('uses the identity function as a predicate if none is specified', function()
  20. local observable = Rx.Observable.of(false):all()
  21. expect(observable).to.produce({{false}})
  22. observable = Rx.Observable.of(true):all()
  23. expect(observable).to.produce({{true}})
  24. end)
  25. end)