11import { expect } from 'chai' ;
2- import * as Rx from 'rxjs/Rx';
2+ import { Observable , partition , of } from 'rxjs' ;
3+ import { map , mergeMap } from 'rxjs/operators' ;
34import { hot , cold , expectObservable , expectSubscriptions } from '../helpers/marble-testing' ;
45
5- // TODO: The imports on these tests can't be modernized until we do away with
6- // the partition "operator" and make it a creation method.
76declare function asDiagram ( arg : string ) : Function ;
87
9- const Observable = Rx.Observable;
10-
118/** @test {partition} */
129describe ( 'Observable.prototype.partition' , ( ) => {
13- function expectObservableArray(result: Rx. Observable<string>[], expected: string[]) {
10+ function expectObservableArray ( result : Observable < string > [ ] , expected : string [ ] ) {
1411 for ( let idx = 0 ; idx < result . length ; idx ++ ) {
1512 expectObservable ( result [ idx ] ) . toBe ( expected [ idx ] ) ;
1613 }
@@ -23,7 +20,7 @@ describe('Observable.prototype.partition', () => {
2320 const expected = [ '--1-----3---------5------|' ,
2421 '----2----------4------6--|' ] ;
2522
26- const result = e1. partition((x: any) => x % 2 === 1);
23+ const result = partition ( e1 , ( x : any ) => x % 2 === 1 ) ;
2724
2825 expectObservableArray ( result , expected ) ;
2926 expectSubscriptions ( e1 . subscriptions ) . toBe ( [ e1subs , e1subs ] ) ;
@@ -39,7 +36,7 @@ describe('Observable.prototype.partition', () => {
3936 return x === 'a' ;
4037 }
4138
42- expectObservableArray(e1. partition(predicate), expected);
39+ expectObservableArray ( partition ( e1 , predicate ) , expected ) ;
4340 expectSubscriptions ( e1 . subscriptions ) . toBe ( [ e1subs , e1subs ] ) ;
4441 } ) ;
4542
@@ -53,7 +50,7 @@ describe('Observable.prototype.partition', () => {
5350 return index % 2 === 0 ;
5451 }
5552
56- expectObservableArray(e1. partition(predicate), expected);
53+ expectObservableArray ( partition ( e1 , predicate ) , expected ) ;
5754 expectSubscriptions ( e1 . subscriptions ) . toBe ( [ e1subs , e1subs ] ) ;
5855 } ) ;
5956
@@ -67,7 +64,7 @@ describe('Observable.prototype.partition', () => {
6764 return x === this . value ;
6865 }
6966
70- expectObservableArray(e1. partition(predicate, {value: 'a'}), expected);
67+ expectObservableArray ( partition ( e1 , predicate , { value : 'a' } ) , expected ) ;
7168 expectSubscriptions ( e1 . subscriptions ) . toBe ( [ e1subs , e1subs ] ) ;
7269 } ) ;
7370
@@ -81,7 +78,7 @@ describe('Observable.prototype.partition', () => {
8178 return x === 'a' ;
8279 }
8380
84- expectObservableArray(e1. partition(predicate), expected);
81+ expectObservableArray ( partition ( e1 , predicate ) , expected ) ;
8582 expectSubscriptions ( e1 . subscriptions ) . toBe ( [ e1subs , e1subs ] ) ;
8683 } ) ;
8784
@@ -95,7 +92,7 @@ describe('Observable.prototype.partition', () => {
9592 return x === 'a' ;
9693 }
9794
98- expectObservableArray(e1. partition(predicate), expected);
95+ expectObservableArray ( partition ( e1 , predicate ) , expected ) ;
9996 expectSubscriptions ( e1 . subscriptions ) . toBe ( [ e1subs , e1subs ] ) ;
10097 } ) ;
10198
@@ -115,7 +112,7 @@ describe('Observable.prototype.partition', () => {
115112 return match ;
116113 }
117114
118- expectObservableArray(e1. partition(predicate), expected);
115+ expectObservableArray ( partition ( e1 , predicate ) , expected ) ;
119116 expectSubscriptions ( e1 . subscriptions ) . toBe ( [ e1subs , e1subs ] ) ;
120117 } ) ;
121118
@@ -129,7 +126,7 @@ describe('Observable.prototype.partition', () => {
129126 return x === 'x' ;
130127 }
131128
132- expectObservableArray(e1. partition(predicate), expected);
129+ expectObservableArray ( partition ( e1 , predicate ) , expected ) ;
133130 expectSubscriptions ( e1 . subscriptions ) . toBe ( [ e1subs , e1subs ] ) ;
134131 } ) ;
135132
@@ -143,7 +140,7 @@ describe('Observable.prototype.partition', () => {
143140 return x === 'x' ;
144141 }
145142
146- expectObservableArray(e1. partition(predicate), expected);
143+ expectObservableArray ( partition ( e1 , predicate ) , expected ) ;
147144 expectSubscriptions ( e1 . subscriptions ) . toBe ( [ e1subs , e1subs ] ) ;
148145 } ) ;
149146
@@ -157,7 +154,7 @@ describe('Observable.prototype.partition', () => {
157154 return x === 'a' ;
158155 }
159156
160- expectObservableArray(e1. partition(predicate), expected);
157+ expectObservableArray ( partition ( e1 , predicate ) , expected ) ;
161158 expectSubscriptions ( e1 . subscriptions ) . toBe ( [ e1subs , e1subs ] ) ;
162159 } ) ;
163160
@@ -171,7 +168,7 @@ describe('Observable.prototype.partition', () => {
171168 return x === 'a' ;
172169 }
173170
174- expectObservableArray(e1. partition(predicate), expected);
171+ expectObservableArray ( partition ( e1 , predicate ) , expected ) ;
175172 expectSubscriptions ( e1 . subscriptions ) . toBe ( [ e1subs , e1subs ] ) ;
176173 } ) ;
177174
@@ -185,7 +182,7 @@ describe('Observable.prototype.partition', () => {
185182 return x === 'a' ;
186183 }
187184
188- expectObservableArray(e1. partition(predicate), expected);
185+ expectObservableArray ( partition ( e1 , predicate ) , expected ) ;
189186 expectSubscriptions ( e1 . subscriptions ) . toBe ( [ e1subs , e1subs ] ) ;
190187 } ) ;
191188
@@ -199,7 +196,7 @@ describe('Observable.prototype.partition', () => {
199196 return x === 'a' ;
200197 }
201198
202- expectObservableArray(e1. partition(predicate), expected);
199+ expectObservableArray ( partition ( e1 , predicate ) , expected ) ;
203200 expectSubscriptions ( e1 . subscriptions ) . toBe ( [ e1subs , e1subs ] ) ;
204201 } ) ;
205202
@@ -213,7 +210,7 @@ describe('Observable.prototype.partition', () => {
213210 return x === 'a' ;
214211 }
215212
216- expectObservableArray(e1. partition(predicate), expected);
213+ expectObservableArray ( partition ( e1 , predicate ) , expected ) ;
217214 expectSubscriptions ( e1 . subscriptions ) . toBe ( [ e1subs , e1subs ] ) ;
218215 } ) ;
219216
@@ -227,7 +224,7 @@ describe('Observable.prototype.partition', () => {
227224 function predicate ( x : string ) {
228225 return x === 'a' ;
229226 }
230- const result = e1. partition(predicate);
227+ const result = partition ( e1 , predicate ) ;
231228
232229 for ( let idx = 0 ; idx < result . length ; idx ++ ) {
233230 expectObservable ( result [ idx ] , unsub ) . toBe ( expected [ idx ] ) ;
@@ -242,11 +239,10 @@ describe('Observable.prototype.partition', () => {
242239 '----b--- ' ] ;
243240 const unsub = ' ! ' ;
244241
245- const result = e1
246- .mergeMap((x: string) => Observable.of(x))
247- .partition((x: string) => x === 'a')
248- .map((observable: Rx.Observable<string>) =>
249- observable.mergeMap((x: string) => Observable.of(x)));
242+ const e1Pipe = e1 . pipe (
243+ mergeMap ( ( x : string ) => of ( x ) )
244+ ) ;
245+ const result = partition ( e1Pipe , ( x : string ) => x === 'a' ) ;
250246
251247 expectObservable ( result [ 0 ] , unsub ) . toBe ( expected [ 0 ] ) ;
252248 expectObservable ( result [ 1 ] , unsub ) . toBe ( expected [ 1 ] ) ;
@@ -256,10 +252,10 @@ describe('Observable.prototype.partition', () => {
256252 it ( 'should accept thisArg' , ( ) => {
257253 const thisArg = { } ;
258254
259- Observable. of(1).partition( function (this: any, value: number) {
255+ partition ( of ( 1 ) , function ( this : any , value : number ) {
260256 expect ( this ) . to . deep . equal ( thisArg ) ;
261257 return true ;
262258 } , thisArg )
263- .forEach((observable: Rx. Observable<number>) => observable.subscribe());
259+ . forEach ( ( observable : Observable < number > ) => observable . subscribe ( ) ) ;
264260 } ) ;
265261} ) ;
0 commit comments