28 lines
984 B
Lua
28 lines
984 B
Lua
describe('buffer', function()
|
|
it('produces an error if its parent errors', function()
|
|
local observable = Rx.Observable.of(''):map(function(x) return x() end)
|
|
expect(observable.subscribe).to.fail()
|
|
expect(observable:buffer().subscribe).to.fail()
|
|
end)
|
|
|
|
it('fails if size is not specified', function()
|
|
expect(Rx.Observable.fromRange(5):buffer().subscribe).to.fail()
|
|
end)
|
|
|
|
it('produces values wrapped to the specified width', function()
|
|
local observable = Rx.Observable.create(function(observer)
|
|
observer:onNext(1)
|
|
observer:onNext(2, 3)
|
|
observer:onNext(4, 5, 6)
|
|
observer:onCompleted()
|
|
end)
|
|
expect(observable).to.produce({{1}, {2, 3}, {4, 5, 6}})
|
|
expect(observable:buffer(2)).to.produce({{1, 2}, {3, 4}, {5, 6}})
|
|
end)
|
|
|
|
it('produces a partial buffer if the observable completes', function()
|
|
local observable = Rx.Observable.fromRange(5)
|
|
expect(observable:buffer(2)).to.produce({{1, 2}, {3, 4}, {5}})
|
|
end)
|
|
end)
|