RxLua/tests/contains.lua
Junseong Jang f9ff630135 Add an assertion like 'expect(observable).to.produce.error()' to test 'onError'.
Fixed wrong test codes with the assertion.

Changed the behaviors of the following functions caused by argument types, to raise an error in the creation phase.

- Observable.defer
- Observable:buffer
- Observable:elementAt
- Observable:skipLast
- Observable:takeLast
- Observable:window
2019-03-28 03:04:58 +09:00

30 lines
1009 B
Lua

describe('contains', function()
it('errors when its parent errors', function()
expect(Rx.Observable.throw():contains(1)).to.produce.error()
end)
it('returns false if the source Observable produces no values', function()
expect(Rx.Observable.empty():contains(3)).to.produce(false)
end)
it('returns true if the value is nil and the Observable produces an empty value', function()
local observable = Rx.Observable.create(function(observer)
observer:onNext(nil)
observer:onCompleted()
end)
expect(observable:contains(nil)).to.produce(true)
end)
it('returns true if the source Observable produces the specified value', function()
local observable = Rx.Observable.fromRange(5)
expect(observable:contains(3)).to.produce(true)
end)
it('supports multiple values', function()
local observable = Rx.Observable.fromRange(6):wrap(3)
expect(observable).to.produce({{1, 2, 3}, {4, 5, 6}})
expect(observable:contains(5)).to.produce(true)
end)
end)