takeLast.lua 1.1 KB

12345678910111213141516171819202122232425262728
  1. describe('takeLast', function()
  2. it('produces an error if its parent errors', function()
  3. expect(Rx.Observable.throw():takeLast(1).subscribe).to.fail()
  4. end)
  5. it('produces an error if the count is not specified', function()
  6. expect(Rx.Observable.fromRange(3):takeLast().subscribe).to.fail()
  7. end)
  8. it('produces nothing if the count is zero', function()
  9. local observable = Rx.Observable.fromRange(3):takeLast(0)
  10. expect(observable).to.produce.nothing()
  11. end)
  12. it('produces all values if the count is greater than the number of elements produced', function()
  13. local observable = Rx.Observable.fromRange(3):takeLast(10)
  14. expect(observable).to.produce(1, 2, 3)
  15. end)
  16. it('produces no elements if the count is less than or equal to zero', function()
  17. expect(Rx.Observable.fromRange(3):takeLast(0)).to.produce.nothing()
  18. expect(Rx.Observable.fromRange(3):takeLast(-1)).to.produce.nothing()
  19. end)
  20. it('produces no elements if the source Observable produces no elements', function()
  21. expect(Rx.Observable.empty():takeLast(1)).to.produce.nothing()
  22. end)
  23. end)