@@ -141,16 +141,44 @@ describe('throttleTime operator', () => {
141
141
} ) ;
142
142
143
143
describe ( 'throttleTime(fn, { leading: true, trailing: true })' , ( ) => {
144
- asDiagram ( 'throttleTime(fn, { leading: true, trailing: true })' ) ( 'should immediately emit the first and last values in each time window' , ( ) => {
145
- const e1 = hot ( '-a-xy-----b--x--cxxx--|' ) ;
146
- const e1subs = '^ !' ;
147
- const t = time ( '----| ' ) ;
148
- const expected = '-a---y----b---x-c---x-|' ;
144
+ asDiagram ( 'throttleTime(fn, { leading: true, trailing: true })' ) ( 'should immediately emit the first and last values in each time window' , ( ) => {
145
+ const e1 = hot ( 'a123b12-c-23d-2-ef---|' ) ;
146
+ const t = time ( '----| ' ) ;
147
+ const expected = 'a---b---c---d---e---f|' ;
148
+
149
+ const result = e1 . pipe ( throttleTime ( t , rxTestScheduler , { leading : true , trailing : true } ) ) ;
150
+
151
+ expectObservable ( result ) . toBe ( expected ) ;
152
+ } ) ;
153
+
154
+ it ( 'should immediately emit the first value in each time window' , ( ) => {
155
+ const e1 = hot ( '-a---x------b|' ) ;
156
+ const t = time ( '----| ' ) ;
157
+ const expected = '-a---x------b|' ;
158
+
159
+ const result = e1 . pipe ( throttleTime ( t , rxTestScheduler , { leading : true , trailing : true } ) ) ;
160
+
161
+ expectObservable ( result ) . toBe ( expected ) ;
162
+ } ) ;
163
+
164
+ it ( 'should emit the last throttled value when complete' , ( ) => {
165
+ const e1 = hot ( '-x--|' ) ;
166
+ const t = time ( '----|' ) ;
167
+ const expected = '----(x|)' ;
168
+
169
+ const result = e1 . pipe ( throttleTime ( t , rxTestScheduler , { leading : false , trailing : true } ) ) ;
170
+
171
+ expectObservable ( result ) . toBe ( expected ) ;
172
+ } ) ;
173
+
174
+ it ( 'should emit both simple leading and trailing' , ( ) => {
175
+ const e1 = hot ( '-a-b------------------|' ) ;
176
+ const t = time ( '----| ' ) ;
177
+ const expected = '-a---b----------------|' ;
149
178
150
179
const result = e1 . pipe ( throttleTime ( t , rxTestScheduler , { leading : true , trailing : true } ) ) ;
151
180
152
181
expectObservable ( result ) . toBe ( expected ) ;
153
- expectSubscriptions ( e1 . subscriptions ) . toBe ( e1subs ) ;
154
182
} ) ;
155
183
156
184
it ( 'should emit the value if only a single one is given' , ( ) => {
0 commit comments