average.lua 552 B

1234567891011121314
  1. describe('average', function()
  2. it('errors when its parent errors', function()
  3. expect(Rx.Observable.throw():average()).to.produce.error()
  4. end)
  5. it('produces a single value representing the average of the values produced by the source', function()
  6. expect(Rx.Observable.fromRange(3, 9, 2):average()).to.produce(6)
  7. expect(Rx.Observable.fromTable({-1, 0, 1}):average()).to.produce(0)
  8. end)
  9. it('produces nothing if there are no values to average', function()
  10. expect(Rx.Observable.empty():average()).to.produce.nothing()
  11. end)
  12. end)