first.lua 691 B

1234567891011121314151617
  1. describe('first', function()
  2. it('produces an error if its parent errors', function()
  3. local observable = Rx.Observable.of(''):map(function(x) return x() end)
  4. expect(observable.subscribe).to.fail()
  5. expect(observable:first().subscribe).to.fail()
  6. end)
  7. it('produces no elements if its parent produces no elements', function()
  8. local observable = Rx.Observable.create(function(observer) return observer:onCompleted() end):first()
  9. expect(observable).to.produce.nothing()
  10. end)
  11. it('produces the first element of its parent and immediately completes', function()
  12. local observable = Rx.Observable.fromRange(5):first()
  13. expect(observable).to.produce(1)
  14. end)
  15. end)