|
@@ -0,0 +1,19 @@
|
|
|
+describe('map', function()
|
|
|
+ it('produces an error if its parent errors', function()
|
|
|
+ local observable = Rx.Observable.fromValue(''):map(function(x) return x() end)
|
|
|
+ expect(observable.subscribe).to.fail()
|
|
|
+ expect(observable:map().subscribe).to.fail()
|
|
|
+ end)
|
|
|
+
|
|
|
+ it('uses the identity function as the callback if none is specified', function()
|
|
|
+ local observable = Rx.Observable.fromRange(5):map()
|
|
|
+ expect(observable).to.produce(1, 2, 3, 4, 5)
|
|
|
+ end)
|
|
|
+
|
|
|
+ it('passes all arguments to the predicate and produces all of its return values', function()
|
|
|
+ local callback = spy(function() return 1, 2, 3 end)
|
|
|
+ local observable = Rx.Observable.fromTable({3, 2, 1}, ipairs, true):map(callback)
|
|
|
+ expect(observable).to.produce({{1, 2, 3}, {1, 2, 3}, {1, 2, 3}})
|
|
|
+ expect(callback).to.equal({{3, 1}, {2, 2}, {1, 3}})
|
|
|
+ end)
|
|
|
+end)
|