1234567891011121314151617181920212223242526272829303132333435 |
- describe('all', function()
- it('passes through errors', function()
- expect(Rx.Observable.throw():all().subscribe).to.fail()
- end)
- it('calls onError if the predicate errors', function()
- local observable = Rx.Observable.fromRange(3):all(error)
- local onError = spy()
- observable:subscribe(nil, onError, nil)
- expect(#onError).to.equal(1)
- end)
- it('produces an error if the parent errors', function()
- local _, onError = observableSpy(Rx.Observable.throw():all(function(x) return x end))
- expect(#onError).to.equal(1)
- end)
- it('produces true if all elements satisfy the predicate', function()
- local observable = Rx.Observable.fromRange(5):all(function(x) return x < 10 end)
- expect(observable).to.produce({{true}})
- end)
- it('produces false if one element does not satisfy the predicate', function()
- local observable = Rx.Observable.fromRange(5):all(function(x) return x ~= 3 end)
- expect(observable).to.produce({{false}})
- end)
- it('uses the identity function as a predicate if none is specified', function()
- local observable = Rx.Observable.of(false):all()
- expect(observable).to.produce({{false}})
- observable = Rx.Observable.of(true):all()
- expect(observable).to.produce({{true}})
- end)
- end)
|