distinct.lua 777 B

123456789101112131415161718192021
  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 observable = Rx.Observable.fromValue(''):map(function(x) return x() end)
  8. expect(observable.subscribe).to.fail()
  9. expect(observable:distinct().subscribe).to.fail()
  10. end)
  11. it('completes when its parent completes', function()
  12. local subject = Rx.Subject.create()
  13. local onCompleted = spy()
  14. subject:distinct():subscribe(nil, nil, onCompleted)
  15. expect(#onCompleted).to.equal(0)
  16. subject:onCompleted()
  17. expect(#onCompleted).to.equal(1)
  18. end)
  19. end)