flatMap.lua 777 B

12345678910111213141516171819202122
  1. describe('flatMap', function()
  2. it('produces an error if its parent errors', function()
  3. local observable = Rx.Observable.of(''):flatMap(function(x) return x() end)
  4. expect(observable.subscribe).to.fail()
  5. end)
  6. it('uses the identity function as the callback if none is specified', function()
  7. local observable = Rx.Observable.fromTable{
  8. Rx.Observable.fromRange(3),
  9. Rx.Observable.fromRange(5)
  10. }:flatMap()
  11. expect(observable).to.produce(1, 2, 3, 1, 2, 3, 4, 5)
  12. end)
  13. it('produces all values produced by the observables produced by its parent', function()
  14. local observable = Rx.Observable.fromRange(3):flatMap(function(i)
  15. return Rx.Observable.fromRange(i, 3)
  16. end)
  17. expect(observable).to.produce(1, 2, 3, 2, 3, 3)
  18. end)
  19. end)