distinct.lua 661 B

12345678910111213141516171819
  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. expect(Rx.Observable.throw():distinct()).to.produce.error()
  8. end)
  9. it('completes when its parent completes', function()
  10. local subject = Rx.Subject.create()
  11. local onCompleted = spy()
  12. subject:distinct():subscribe(nil, nil, onCompleted)
  13. expect(#onCompleted).to.equal(0)
  14. subject:onCompleted()
  15. expect(#onCompleted).to.equal(1)
  16. end)
  17. end)