count.lua 693 B

12345678910111213141516171819
  1. describe('count', function()
  2. it('passes through errors', function()
  3. expect(Rx.Observable.throw():count()).to.produce.error()
  4. end)
  5. it('produces a single value representing the number of elements produced by the source', function()
  6. local observable = Rx.Observable.fromRange(5):count()
  7. expect(observable).to.produce(5)
  8. end)
  9. it('uses the predicate to filter for values if it is specified', function()
  10. local observable = Rx.Observable.fromRange(5):count(function(x) return x > 3 end)
  11. expect(observable).to.produce(2)
  12. end)
  13. it('calls onError if the predicate errors', function()
  14. expect(Rx.Observable.fromRange(3):count(error)).to.produce.error()
  15. end)
  16. end)