@@ -8,18 +8,80 @@ describe('Observable.forkJoin', function () {
8
8
hot ( '--a--b--c--d--|' ) ,
9
9
hot ( '(b|)' ) ,
10
10
hot ( '--1--2--3--|' )
11
- ) ;
11
+ ) ;
12
12
var expected = '--------------(x|)' ;
13
13
14
14
expectObservable ( e1 ) . toBe ( expected , { x : [ 'd' , 'b' , '3' ] } ) ;
15
15
} ) ;
16
16
17
+ it ( 'should join the last values of the provided observables with selector' , function ( ) {
18
+ function selector ( x , y , z ) {
19
+ return x + y + z ;
20
+ }
21
+
22
+ var e1 = Observable . forkJoin (
23
+ hot ( '--a--b--c--d--|' ) ,
24
+ hot ( '(b|)' ) ,
25
+ hot ( '--1--2--3--|' ) ,
26
+ selector
27
+ ) ;
28
+ var expected = '--------------(x|)' ;
29
+
30
+ expectObservable ( e1 ) . toBe ( expected , { x : 'db3' } ) ;
31
+ } ) ;
32
+
33
+ it ( 'should accept single observable' , function ( ) {
34
+ var e1 = Observable . forkJoin (
35
+ hot ( '--a--b--c--d--|' )
36
+ ) ;
37
+ var expected = '--------------(x|)' ;
38
+
39
+ expectObservable ( e1 ) . toBe ( expected , { x : [ 'd' ] } ) ;
40
+ } ) ;
41
+
42
+ it ( 'should accept array of observable contains single' , function ( ) {
43
+ var e1 = Observable . forkJoin (
44
+ [ hot ( '--a--b--c--d--|' ) ]
45
+ ) ;
46
+ var expected = '--------------(x|)' ;
47
+
48
+ expectObservable ( e1 ) . toBe ( expected , { x : [ 'd' ] } ) ;
49
+ } ) ;
50
+
51
+ it ( 'should accept single observable with selector' , function ( ) {
52
+ function selector ( x ) {
53
+ return x + x ;
54
+ }
55
+
56
+ var e1 = Observable . forkJoin (
57
+ hot ( '--a--b--c--d--|' ) ,
58
+ selector
59
+ ) ;
60
+ var expected = '--------------(x|)' ;
61
+
62
+ expectObservable ( e1 ) . toBe ( expected , { x : 'dd' } ) ;
63
+ } ) ;
64
+
65
+ it ( 'should accept array of observable contains single with selector' , function ( ) {
66
+ function selector ( x ) {
67
+ return x + x ;
68
+ }
69
+
70
+ var e1 = Observable . forkJoin (
71
+ [ hot ( '--a--b--c--d--|' ) ] ,
72
+ selector
73
+ ) ;
74
+ var expected = '--------------(x|)' ;
75
+
76
+ expectObservable ( e1 ) . toBe ( expected , { x : 'dd' } ) ;
77
+ } ) ;
78
+
17
79
it ( 'should accept lowercase-o observables' , function ( ) {
18
80
var e1 = Observable . forkJoin (
19
81
hot ( '--a--b--c--d--|' ) ,
20
82
hot ( '(b|)' ) ,
21
83
lowerCaseO ( '1' , '2' , '3' )
22
- ) ;
84
+ ) ;
23
85
var expected = '--------------(x|)' ;
24
86
25
87
expectObservable ( e1 ) . toBe ( expected , { x : [ 'd' , 'b' , '3' ] } ) ;
@@ -29,7 +91,7 @@ describe('Observable.forkJoin', function () {
29
91
var e1 = Observable . forkJoin (
30
92
Observable . of ( 1 ) ,
31
93
Promise . resolve ( 2 )
32
- ) ;
94
+ ) ;
33
95
34
96
e1 . subscribe ( function ( x ) {
35
97
expect ( x ) . toEqual ( [ 1 , 2 ] ) ;
@@ -40,18 +102,45 @@ describe('Observable.forkJoin', function () {
40
102
done ) ;
41
103
} ) ;
42
104
43
- it ( 'forkJoin n-ary parameters empty' , function ( ) {
105
+ it ( 'should accept array of observables' , function ( ) {
106
+ var e1 = Observable . forkJoin (
107
+ [ hot ( '--a--b--c--d--|' ) ,
108
+ hot ( '(b|)' ) ,
109
+ hot ( '--1--2--3--|' ) ]
110
+ ) ;
111
+ var expected = '--------------(x|)' ;
112
+
113
+ expectObservable ( e1 ) . toBe ( expected , { x : [ 'd' , 'b' , '3' ] } ) ;
114
+ } ) ;
115
+
116
+ it ( 'should accept array of observables with selector' , function ( ) {
117
+ function selector ( x , y , z ) {
118
+ return x + y + z ;
119
+ }
120
+
121
+ var e1 = Observable . forkJoin (
122
+ [ hot ( '--a--b--c--d--|' ) ,
123
+ hot ( '(b|)' ) ,
124
+ hot ( '--1--2--3--|' ) ] ,
125
+ selector
126
+ ) ;
127
+ var expected = '--------------(x|)' ;
128
+
129
+ expectObservable ( e1 ) . toBe ( expected , { x : 'db3' } ) ;
130
+ } ) ;
131
+
132
+ it ( 'should not emit if any of source observable is empty' , function ( ) {
44
133
var e1 = Observable . forkJoin (
45
134
hot ( '--a--b--c--d--|' ) ,
46
135
hot ( '(b|)' ) ,
47
136
hot ( '------------------|' )
48
- ) ;
137
+ ) ;
49
138
var expected = '------------------|' ;
50
139
51
140
expectObservable ( e1 ) . toBe ( expected ) ;
52
141
} ) ;
53
142
54
- it ( 'forkJoin n-ary parameters empty before end ' , function ( ) {
143
+ it ( 'should complete early if any of source is empty and completes before than others ' , function ( ) {
55
144
var e1 = Observable . forkJoin (
56
145
hot ( '--a--b--c--d--|' ) ,
57
146
hot ( '(b|)' ) ,
@@ -62,7 +151,7 @@ describe('Observable.forkJoin', function () {
62
151
expectObservable ( e1 ) . toBe ( expected ) ;
63
152
} ) ;
64
153
65
- it ( 'forkJoin empty empty' , function ( ) {
154
+ it ( 'should complete when all sources are empty' , function ( ) {
66
155
var e1 = Observable . forkJoin (
67
156
hot ( '--------------|' ) ,
68
157
hot ( '---------|' )
@@ -72,14 +161,14 @@ describe('Observable.forkJoin', function () {
72
161
expectObservable ( e1 ) . toBe ( expected ) ;
73
162
} ) ;
74
163
75
- it ( 'forkJoin none ' , function ( ) {
164
+ it ( 'should complete if source is not provided ' , function ( ) {
76
165
var e1 = Observable . forkJoin ( ) ;
77
166
var expected = '|' ;
78
167
79
168
expectObservable ( e1 ) . toBe ( expected ) ;
80
169
} ) ;
81
170
82
- it ( 'forkJoin empty return ' , function ( ) {
171
+ it ( 'should complete when any of source is empty with selector ' , function ( ) {
83
172
function selector ( x , y ) {
84
173
return x + y ;
85
174
}
@@ -93,7 +182,7 @@ describe('Observable.forkJoin', function () {
93
182
expectObservable ( e1 ) . toBe ( expected ) ;
94
183
} ) ;
95
184
96
- it ( 'forkJoin return return ' , function ( ) {
185
+ it ( 'should emit results by resultselector ' , function ( ) {
97
186
function selector ( x , y ) {
98
187
return x + y ;
99
188
}
@@ -107,7 +196,7 @@ describe('Observable.forkJoin', function () {
107
196
expectObservable ( e1 ) . toBe ( expected , { x : 'd2' } ) ;
108
197
} ) ;
109
198
110
- it ( 'forkJoin empty throw ' , function ( ) {
199
+ it ( 'should raise error when any of source raises error with empty observable ' , function ( ) {
111
200
var e1 = Observable . forkJoin (
112
201
hot ( '------#' ) ,
113
202
hot ( '---------|' ) ) ;
@@ -116,7 +205,7 @@ describe('Observable.forkJoin', function () {
116
205
expectObservable ( e1 ) . toBe ( expected ) ;
117
206
} ) ;
118
207
119
- it ( 'forkJoin empty throw ' , function ( ) {
208
+ it ( 'should raise error when any of source raises error with selector with empty observable ' , function ( ) {
120
209
function selector ( x , y ) {
121
210
return x + y ;
122
211
}
@@ -130,7 +219,7 @@ describe('Observable.forkJoin', function () {
130
219
expectObservable ( e1 ) . toBe ( expected ) ;
131
220
} ) ;
132
221
133
- it ( 'forkJoin return throw ' , function ( ) {
222
+ it ( 'should raise error when source raises error ' , function ( ) {
134
223
var e1 = Observable . forkJoin (
135
224
hot ( '------#' ) ,
136
225
hot ( '---a-----|' ) ) ;
@@ -139,7 +228,7 @@ describe('Observable.forkJoin', function () {
139
228
expectObservable ( e1 ) . toBe ( expected ) ;
140
229
} ) ;
141
230
142
- it ( 'forkJoin return throw ' , function ( ) {
231
+ it ( 'should raise error when source raises error with selector ' , function ( ) {
143
232
function selector ( x , y ) {
144
233
return x + y ;
145
234
}
@@ -152,4 +241,4 @@ describe('Observable.forkJoin', function () {
152
241
153
242
expectObservable ( e1 ) . toBe ( expected ) ;
154
243
} ) ;
155
- } ) ;
244
+ } ) ;
0 commit comments