@@ -75,56 +75,6 @@ describe('Observable.prototype.mergeMapTo', () => {
7575 } ) ;
7676 } ) ;
7777
78- it ( 'should mergeMapTo values to resolved promises with resultSelector' , ( done ) => {
79- const source = Rx . Observable . from ( [ 4 , 3 , 2 , 1 ] ) ;
80- const resultSelectorCalledWith : number [ ] [ ] = [ ] ;
81- const inner = Observable . from ( Promise . resolve ( 42 ) ) ;
82- const resultSelector = function ( outerVal : number , innerVal : number , outerIndex : number , innerIndex : number ) {
83- resultSelectorCalledWith . push ( [ ] . slice . call ( arguments ) ) ;
84- return 8 ;
85- } ;
86-
87- const results : number [ ] = [ ] ;
88- const expectedCalls = [
89- [ 4 , 42 , 0 , 0 ] ,
90- [ 3 , 42 , 1 , 0 ] ,
91- [ 2 , 42 , 2 , 0 ] ,
92- [ 1 , 42 , 3 , 0 ] ,
93- ] ;
94- source . mergeMapTo ( inner , resultSelector ) . subscribe (
95- ( x ) => {
96- results . push ( x ) ;
97- } ,
98- ( err ) => {
99- done ( new Error ( 'Subscriber error handler not supposed to be called.' ) ) ;
100- } ,
101- ( ) => {
102- expect ( results ) . to . deep . equal ( [ 8 , 8 , 8 , 8 ] ) ;
103- expect ( resultSelectorCalledWith ) . to . deep . equal ( expectedCalls ) ;
104- done ( ) ;
105- } ) ;
106- } ) ;
107-
108- it ( 'should mergeMapTo values to rejected promises with resultSelector' , ( done ) => {
109- const source = Rx . Observable . from ( [ 4 , 3 , 2 , 1 ] ) ;
110- const inner = Observable . from ( Promise . reject ( 42 ) ) ;
111- const resultSelector = ( ) => {
112- throw 'this should not be called' ;
113- } ;
114-
115- source . mergeMapTo ( inner , resultSelector ) . subscribe (
116- ( x ) => {
117- done ( new Error ( 'Subscriber next handler not supposed to be called.' ) ) ;
118- } ,
119- ( err ) => {
120- expect ( err ) . to . equal ( 42 ) ;
121- done ( ) ;
122- } ,
123- ( ) => {
124- done ( new Error ( 'Subscriber complete handler not supposed to be called.' ) ) ;
125- } ) ;
126- } ) ;
127-
12878 it ( 'should mergeMapTo many outer values to many inner values' , ( ) => {
12979 const values = { i : 'foo' , j : 'bar' , k : 'baz' , l : 'qux' } ;
13080 const e1 = hot ( '-a-------b-------c-------d-------| ' ) ;
@@ -264,42 +214,6 @@ describe('Observable.prototype.mergeMapTo', () => {
264214 expectSubscriptions ( e1 . subscriptions ) . toBe ( e1subs ) ;
265215 } ) ;
266216
267- it ( 'should mergeMapTo many cold Observable, with parameter concurrency=1' , ( ) => {
268- const values = { i : 'foo' , j : 'bar' , k : 'baz' , l : 'qux' } ;
269- const e1 = hot ( '-a-------b-------c---| ' ) ;
270- const e1subs = '^ !' ;
271- const inner = cold ( '----i---j---k---l---| ' , values ) ;
272- const innersubs = [ ' ^ ! ' ,
273- ' ^ ! ' ,
274- ' ^ !' ] ;
275- const expected = '-----i---j---k---l-------i---j---k---l-------i---j---k---l---|' ;
276-
277- function resultSelector ( oV : string , iV : string , oI : number , iI : number ) { return iV ; }
278- const result = e1 . mergeMapTo ( inner , resultSelector , 1 ) ;
279-
280- expectObservable ( result ) . toBe ( expected , values ) ;
281- expectSubscriptions ( inner . subscriptions ) . toBe ( innersubs ) ;
282- expectSubscriptions ( e1 . subscriptions ) . toBe ( e1subs ) ;
283- } ) ;
284-
285- it ( 'should mergeMap to many cold Observable, with parameter concurrency=2' , ( ) => {
286- const values = { i : 'foo' , j : 'bar' , k : 'baz' , l : 'qux' } ;
287- const e1 = hot ( '-a-------b-------c---| ' ) ;
288- const e1subs = '^ !' ;
289- const inner = cold ( '----i---j---k---l---| ' , values ) ;
290- const innersubs = [ ' ^ ! ' ,
291- ' ^ ! ' ,
292- ' ^ !' ] ;
293- const expected = '-----i---j---(ki)(lj)k---(li)j---k---l---|' ;
294-
295- function resultSelector ( oV : string , iV : string , oI : number , iI : number ) { return iV ; }
296- const result = e1 . mergeMapTo ( inner , resultSelector , 2 ) ;
297-
298- expectObservable ( result ) . toBe ( expected , values ) ;
299- expectSubscriptions ( inner . subscriptions ) . toBe ( innersubs ) ;
300- expectSubscriptions ( e1 . subscriptions ) . toBe ( e1subs ) ;
301- } ) ;
302-
303217 it ( 'should mergeMapTo many cold Observable, with parameter concurrency=1, without resultSelector' , ( ) => {
304218 const values = { i : 'foo' , j : 'bar' , k : 'baz' , l : 'qux' } ;
305219 const e1 = hot ( '-a-------b-------c---| ' ) ;
@@ -345,18 +259,6 @@ describe('Observable.prototype.mergeMapTo', () => {
345259 expectSubscriptions ( e1 . subscriptions ) . toBe ( e1subs ) ;
346260 } ) ;
347261
348- it ( 'should mergeMapTo many outer to inner arrays, using resultSelector' , ( ) => {
349- const e1 = hot ( '2-----4--------3--------2-------|' ) ;
350- const e1subs = '^ !' ;
351- const expected = '(2345)(4567)---(3456)---(2345)--|' ;
352-
353- const source = e1 . mergeMapTo ( [ '0' , '1' , '2' , '3' ] ,
354- ( x , y ) => String ( parseInt ( x ) + parseInt ( y ) ) ) ;
355-
356- expectObservable ( source ) . toBe ( expected ) ;
357- expectSubscriptions ( e1 . subscriptions ) . toBe ( e1subs ) ;
358- } ) ;
359-
360262 it ( 'should mergeMapTo many outer to inner arrays, and outer throws' , ( ) => {
361263 const e1 = hot ( '2-----4--------3--------2-------#' ) ;
362264 const e1subs = '^ !' ;
@@ -368,18 +270,6 @@ describe('Observable.prototype.mergeMapTo', () => {
368270 expectSubscriptions ( e1 . subscriptions ) . toBe ( e1subs ) ;
369271 } ) ;
370272
371- it ( 'should mergeMapTo many outer to inner arrays, resultSelector, outer throws' , ( ) => {
372- const e1 = hot ( '2-----4--------3--------2-------#' ) ;
373- const e1subs = '^ !' ;
374- const expected = '(2345)(4567)---(3456)---(2345)--#' ;
375-
376- const source = e1 . mergeMapTo ( [ '0' , '1' , '2' , '3' ] ,
377- ( x , y ) => String ( parseInt ( x ) + parseInt ( y ) ) ) ;
378-
379- expectObservable ( source ) . toBe ( expected ) ;
380- expectSubscriptions ( e1 . subscriptions ) . toBe ( e1subs ) ;
381- } ) ;
382-
383273 it ( 'should mergeMapTo many outer to inner arrays, outer gets unsubscribed' , ( ) => {
384274 const e1 = hot ( '2-----4--------3--------2-------|' ) ;
385275 const e1subs = '^ !' ;
@@ -392,35 +282,6 @@ describe('Observable.prototype.mergeMapTo', () => {
392282 expectSubscriptions ( e1 . subscriptions ) . toBe ( e1subs ) ;
393283 } ) ;
394284
395- it ( 'should mergeMapTo many outer to inner arrays, resultSelector, outer unsubscribed' , ( ) => {
396- const e1 = hot ( '2-----4--------3--------2-------|' ) ;
397- const e1subs = '^ !' ;
398- const unsub = ' !' ;
399- const expected = '(2345)(4567)--' ;
400-
401- const source = e1 . mergeMapTo ( [ '0' , '1' , '2' , '3' ] ,
402- ( x , y ) => String ( parseInt ( x ) + parseInt ( y ) ) ) ;
403-
404- expectObservable ( source , unsub ) . toBe ( expected ) ;
405- expectSubscriptions ( e1 . subscriptions ) . toBe ( e1subs ) ;
406- } ) ;
407-
408- it ( 'should mergeMapTo many outer to inner arrays, resultSelector throws' , ( ) => {
409- const e1 = hot ( '2-----4--------3--------2-------|' ) ;
410- const e1subs = '^ !' ;
411- const expected = '(2345)(4567)---#' ;
412-
413- const source = e1 . mergeMapTo ( [ '0' , '1' , '2' , '3' ] , ( outer , inner ) => {
414- if ( outer === '3' ) {
415- throw 'error' ;
416- }
417- return String ( parseInt ( outer ) + parseInt ( inner ) ) ;
418- } ) ;
419-
420- expectObservable ( source ) . toBe ( expected ) ;
421- expectSubscriptions ( e1 . subscriptions ) . toBe ( e1subs ) ;
422- } ) ;
423-
424285 it ( 'should map and flatten' , ( ) => {
425286 const source = Observable . of ( 1 , 2 , 3 , 4 ) . mergeMapTo ( Observable . of ( '!' ) ) ;
426287
@@ -460,8 +321,6 @@ describe('Observable.prototype.mergeMapTo', () => {
460321 /* tslint:disable:no-unused-variable */
461322 let a1 : Rx . Observable < string > = o . mergeMapTo ( m ) ;
462323 let a2 : Rx . Observable < string > = o . mergeMapTo ( m , 3 ) ;
463- let a3 : Rx . Observable < { o : number ; i : string ; } > = o . mergeMapTo ( m , ( o , i ) => ( { o, i } ) ) ;
464- let a4 : Rx . Observable < { o : number ; i : string ; } > = o . mergeMapTo ( m , ( o , i ) => ( { o, i } ) , 3 ) ;
465324 /* tslint:enable:no-unused-variable */
466325 } ) ;
467326} ) ;
0 commit comments