distinct.lua 701 B

1234567891011121314151617181920
  1. describe('distinct', function()
  2. it('does not produce the same value twice', function()
  3. local observable = Rx.Observable.fromTable({1, 1, 2, 1, 3, 3, 2, 1, 4}, ipairs):distinct()
  4. expect(observable).to.produce(1, 2, 3, 4)
  5. end)
  6. it('produces an error if its parent errors', function()
  7. local _, onError = observableSpy(Rx.Observable.throw():distinct())
  8. expect(#onError).to.equal(1)
  9. end)
  10. it('completes when its parent completes', function()
  11. local subject = Rx.Subject.create()
  12. local onCompleted = spy()
  13. subject:distinct():subscribe(nil, nil, onCompleted)
  14. expect(#onCompleted).to.equal(0)
  15. subject:onCompleted()
  16. expect(#onCompleted).to.equal(1)
  17. end)
  18. end)