amb.lua 762 B

12345678910111213141516171819202122232425262728
  1. describe('amb', function()
  2. it('returns nil if it is passed nil', function()
  3. expect(Rx.Observable.amb()).to.equal(nil)
  4. end)
  5. it('returns the Observable unchanged if it is the only one supplied', function()
  6. expect(Rx.Observable.amb(Rx.Observable.fromRange(3))).to.produce(1, 2, 3)
  7. end)
  8. it('produces values from the first Observable to produce a value', function()
  9. local a = Rx.Subject.create()
  10. local b = Rx.Subject.create()
  11. local onNext = spy()
  12. local observer = Rx.Observer.create(onNext)
  13. local amb = a:amb(b):subscribe(observer)
  14. b:onNext(4)
  15. a:onNext(1)
  16. b:onNext(5)
  17. b:onNext(6)
  18. b:onCompleted()
  19. a:onNext(2)
  20. a:onNext(3)
  21. a:onCompleted()
  22. expect(onNext).to.equal({{4}, {5}, {6}})
  23. end)
  24. end)