1- QUnit . module ( 'Throttle ' ) ;
1+ QUnit . module ( 'Debounce ' ) ;
22
33var Observable = Rx . Observable ,
44 TestScheduler = Rx . TestScheduler ,
@@ -7,7 +7,7 @@ var Observable = Rx.Observable,
77 onCompleted = Rx . ReactiveTest . onCompleted ,
88 subscribe = Rx . ReactiveTest . subscribe ;
99
10- test ( 'Throttle_TimeSpan_AllPass ' , function ( ) {
10+ test ( 'Debounce_TimeSpan_AllPass ' , function ( ) {
1111 var scheduler = new TestScheduler ( ) ;
1212
1313 var xs = scheduler . createHotObservable (
@@ -20,7 +20,7 @@ test('Throttle_TimeSpan_AllPass', function () {
2020 ) ;
2121
2222 var res = scheduler . startWithCreate ( function ( ) {
23- return xs . throttleWithSelector ( function ( ) { return Observable . timer ( 20 , scheduler ) ; } ) ;
23+ return xs . debounceWithSelector ( function ( ) { return Observable . timer ( 20 , scheduler ) ; } ) ;
2424 } ) ;
2525
2626 res . messages . assertEqual (
@@ -36,7 +36,7 @@ test('Throttle_TimeSpan_AllPass', function () {
3636 ) ;
3737} ) ;
3838
39- test ( 'Throttle_TimeSpan_AllPass_ErrorEnd ' , function ( ) {
39+ test ( 'Debounce_TimeSpan_AllPass_ErrorEnd ' , function ( ) {
4040 var ex = new Error ( ) ;
4141
4242 var scheduler = new TestScheduler ( ) ;
@@ -51,7 +51,7 @@ test('Throttle_TimeSpan_AllPass_ErrorEnd', function () {
5151 ) ;
5252
5353 var res = scheduler . startWithCreate ( function ( ) {
54- return xs . throttleWithSelector ( function ( ) { return Observable . timer ( 20 , scheduler ) ; } ) ;
54+ return xs . debounceWithSelector ( function ( ) { return Observable . timer ( 20 , scheduler ) ; } ) ;
5555 } ) ;
5656
5757 res . messages . assertEqual (
@@ -67,7 +67,7 @@ test('Throttle_TimeSpan_AllPass_ErrorEnd', function () {
6767 ) ;
6868} ) ;
6969
70- test ( 'Throttle_TimeSpan_AllDrop ' , function ( ) {
70+ test ( 'Debounce_TimeSpan_AllDrop ' , function ( ) {
7171 var scheduler = new TestScheduler ( ) ;
7272
7373 var xs = scheduler . createHotObservable (
@@ -83,7 +83,7 @@ test('Throttle_TimeSpan_AllDrop', function () {
8383 ) ;
8484
8585 var res = scheduler . startWithCreate ( function ( ) {
86- return xs . throttleWithSelector ( function ( ) { return Observable . timer ( 40 , scheduler ) ; } ) ;
86+ return xs . debounceWithSelector ( function ( ) { return Observable . timer ( 40 , scheduler ) ; } ) ;
8787 } ) ;
8888
8989 res . messages . assertEqual (
@@ -96,7 +96,7 @@ test('Throttle_TimeSpan_AllDrop', function () {
9696 ) ;
9797} ) ;
9898
99- test ( 'Throttle_TimeSpan_AllDrop_ErrorEnd ' , function ( ) {
99+ test ( 'Debounce_TimeSpan_AllDrop_ErrorEnd ' , function ( ) {
100100 var ex = new Error ( ) ;
101101
102102 var scheduler = new TestScheduler ( ) ;
@@ -114,7 +114,7 @@ test('Throttle_TimeSpan_AllDrop_ErrorEnd', function () {
114114 ) ;
115115
116116 var res = scheduler . startWithCreate ( function ( ) {
117- return xs . throttle ( 40 , scheduler )
117+ return xs . debounce ( 40 , scheduler )
118118 } ) ;
119119
120120 res . messages . assertEqual (
@@ -126,7 +126,7 @@ test('Throttle_TimeSpan_AllDrop_ErrorEnd', function () {
126126 ) ;
127127} ) ;
128128
129- test ( 'Throttle_Duration_DelayBehavior ' , function ( ) {
129+ test ( 'Debounce_Duration_DelayBehavior ' , function ( ) {
130130 var results , scheduler , xs , ys ;
131131 scheduler = new TestScheduler ( ) ;
132132 xs = scheduler . createHotObservable (
@@ -147,7 +147,7 @@ test('Throttle_Duration_DelayBehavior', function () {
147147 ] ;
148148
149149 results = scheduler . startWithCreate ( function ( ) {
150- return xs . throttleWithSelector ( ( function ( x ) {
150+ return xs . debounceWithSelector ( ( function ( x ) {
151151 return ys [ x ] ;
152152 } ) ) ;
153153 } ) ;
@@ -168,13 +168,13 @@ test('Throttle_Duration_DelayBehavior', function () {
168168 ys [ 4 ] . subscriptions . assertEqual ( subscribe ( 400 , 400 + 20 ) ) ;
169169} ) ;
170170
171- test ( 'Throttle_Duration_ThrottleBehavior ' , function ( ) {
171+ test ( 'Debounce_Duration_DebounceBehavior ' , function ( ) {
172172 var results , scheduler , xs , ys ;
173173 scheduler = new TestScheduler ( ) ;
174174 xs = scheduler . createHotObservable ( onNext ( 150 , - 1 ) , onNext ( 250 , 0 ) , onNext ( 280 , 1 ) , onNext ( 310 , 2 ) , onNext ( 350 , 3 ) , onNext ( 400 , 4 ) , onCompleted ( 550 ) ) ;
175175 ys = [ scheduler . createColdObservable ( onNext ( 20 , 42 ) , onNext ( 25 , 99 ) ) , scheduler . createColdObservable ( onNext ( 40 , 42 ) , onNext ( 45 , 99 ) ) , scheduler . createColdObservable ( onNext ( 20 , 42 ) , onNext ( 25 , 99 ) ) , scheduler . createColdObservable ( onNext ( 60 , 42 ) , onNext ( 65 , 99 ) ) , scheduler . createColdObservable ( onNext ( 20 , 42 ) , onNext ( 25 , 99 ) ) ] ;
176176 results = scheduler . startWithCreate ( function ( ) {
177- return xs . throttleWithSelector ( function ( x ) {
177+ return xs . debounceWithSelector ( function ( x ) {
178178 return ys [ x ] ;
179179 } ) ;
180180 } ) ;
@@ -187,13 +187,13 @@ test('Throttle_Duration_ThrottleBehavior', function () {
187187 ys [ 4 ] . subscriptions . assertEqual ( subscribe ( 400 , 400 + 20 ) ) ;
188188} ) ;
189189
190- test ( 'Throttle_Duration_EarlyCompletion ' , function ( ) {
190+ test ( 'Debounce_Duration_EarlyCompletion ' , function ( ) {
191191 var results , scheduler , xs , ys ;
192192 scheduler = new TestScheduler ( ) ;
193193 xs = scheduler . createHotObservable ( onNext ( 150 , - 1 ) , onNext ( 250 , 0 ) , onNext ( 280 , 1 ) , onNext ( 310 , 2 ) , onNext ( 350 , 3 ) , onNext ( 400 , 4 ) , onCompleted ( 410 ) ) ;
194194 ys = [ scheduler . createColdObservable ( onNext ( 20 , 42 ) , onNext ( 25 , 99 ) ) , scheduler . createColdObservable ( onNext ( 40 , 42 ) , onNext ( 45 , 99 ) ) , scheduler . createColdObservable ( onNext ( 20 , 42 ) , onNext ( 25 , 99 ) ) , scheduler . createColdObservable ( onNext ( 60 , 42 ) , onNext ( 65 , 99 ) ) , scheduler . createColdObservable ( onNext ( 20 , 42 ) , onNext ( 25 , 99 ) ) ] ;
195195 results = scheduler . startWithCreate ( function ( ) {
196- return xs . throttleWithSelector ( function ( x ) {
196+ return xs . debounceWithSelector ( function ( x ) {
197197 return ys [ x ] ;
198198 } ) ;
199199 } ) ;
@@ -206,13 +206,13 @@ test('Throttle_Duration_EarlyCompletion', function () {
206206 ys [ 4 ] . subscriptions . assertEqual ( subscribe ( 400 , 410 ) ) ;
207207} ) ;
208208
209- test ( 'Throttle_Duration_InnerError ' , function ( ) {
209+ test ( 'Debounce_Duration_InnerError ' , function ( ) {
210210 var ex , results , scheduler , xs ;
211211 scheduler = new TestScheduler ( ) ;
212212 xs = scheduler . createHotObservable ( onNext ( 150 , 1 ) , onNext ( 250 , 2 ) , onNext ( 350 , 3 ) , onNext ( 450 , 4 ) , onCompleted ( 550 ) ) ;
213213 ex = 'ex' ;
214214 results = scheduler . startWithCreate ( function ( ) {
215- return xs . throttleWithSelector ( function ( x ) {
215+ return xs . debounceWithSelector ( function ( x ) {
216216 if ( x < 4 ) {
217217 return scheduler . createColdObservable ( onNext ( x * 10 , "Ignore" ) , onNext ( x * 10 + 5 , "Aargh!" ) ) ;
218218 } else {
@@ -224,27 +224,27 @@ test('Throttle_Duration_InnerError', function () {
224224 xs . subscriptions . assertEqual ( subscribe ( 200 , 490 ) ) ;
225225} ) ;
226226
227- test ( 'Throttle_Duration_OuterError ' , function ( ) {
227+ test ( 'Debounce_Duration_OuterError ' , function ( ) {
228228 var ex , results , scheduler , xs ;
229229 ex = 'ex' ;
230230 scheduler = new TestScheduler ( ) ;
231231 xs = scheduler . createHotObservable ( onNext ( 150 , 1 ) , onNext ( 250 , 2 ) , onNext ( 350 , 3 ) , onNext ( 450 , 4 ) , onError ( 460 , ex ) ) ;
232232 results = scheduler . startWithCreate ( function ( ) {
233- return xs . throttleWithSelector ( function ( x ) {
233+ return xs . debounceWithSelector ( function ( x ) {
234234 return scheduler . createColdObservable ( onNext ( x * 10 , "Ignore" ) , onNext ( x * 10 + 5 , "Aargh!" ) ) ;
235235 } ) ;
236236 } ) ;
237237 results . messages . assertEqual ( onNext ( 250 + 2 * 10 , 2 ) , onNext ( 350 + 3 * 10 , 3 ) , onError ( 460 , ex ) ) ;
238238 xs . subscriptions . assertEqual ( subscribe ( 200 , 460 ) ) ;
239239} ) ;
240240
241- test ( 'Throttle_Duration_SelectorThrows ' , function ( ) {
241+ test ( 'Debounce_Duration_SelectorThrows ' , function ( ) {
242242 var ex , results , scheduler , xs ;
243243 ex = 'ex' ;
244244 scheduler = new TestScheduler ( ) ;
245245 xs = scheduler . createHotObservable ( onNext ( 150 , 1 ) , onNext ( 250 , 2 ) , onNext ( 350 , 3 ) , onNext ( 450 , 4 ) , onCompleted ( 550 ) ) ;
246246 results = scheduler . startWithCreate ( function ( ) {
247- return xs . throttleWithSelector ( function ( x ) {
247+ return xs . debounceWithSelector ( function ( x ) {
248248 if ( x < 4 ) {
249249 return scheduler . createColdObservable ( onNext ( x * 10 , "Ignore" ) , onNext ( x * 10 + 5 , "Aargh!" ) ) ;
250250 } else {
@@ -256,25 +256,25 @@ test('Throttle_Duration_SelectorThrows', function () {
256256 xs . subscriptions . assertEqual ( subscribe ( 200 , 450 ) ) ;
257257} ) ;
258258
259- test ( 'Throttle_Duration_InnerDone_DelayBehavior ' , function ( ) {
259+ test ( 'Debounce_Duration_InnerDone_DelayBehavior ' , function ( ) {
260260 var results , scheduler , xs ;
261261 scheduler = new TestScheduler ( ) ;
262262 xs = scheduler . createHotObservable ( onNext ( 150 , 1 ) , onNext ( 250 , 2 ) , onNext ( 350 , 3 ) , onNext ( 450 , 4 ) , onCompleted ( 550 ) ) ;
263263 results = scheduler . startWithCreate ( function ( ) {
264- return xs . throttleWithSelector ( function ( x ) {
264+ return xs . debounceWithSelector ( function ( x ) {
265265 return scheduler . createColdObservable ( onCompleted ( x * 10 ) ) ;
266266 } ) ;
267267 } ) ;
268268 results . messages . assertEqual ( onNext ( 250 + 2 * 10 , 2 ) , onNext ( 350 + 3 * 10 , 3 ) , onNext ( 450 + 4 * 10 , 4 ) , onCompleted ( 550 ) ) ;
269269 xs . subscriptions . assertEqual ( subscribe ( 200 , 550 ) ) ;
270270} ) ;
271271
272- test ( 'Throttle_Duration_InnerDone_ThrottleBehavior ' , function ( ) {
272+ test ( 'Debounce_Duration_InnerDone_DebounceBehavior ' , function ( ) {
273273 var results , scheduler , xs ;
274274 scheduler = new TestScheduler ( ) ;
275275 xs = scheduler . createHotObservable ( onNext ( 150 , 1 ) , onNext ( 250 , 2 ) , onNext ( 280 , 3 ) , onNext ( 300 , 4 ) , onNext ( 400 , 5 ) , onNext ( 410 , 6 ) , onCompleted ( 550 ) ) ;
276276 results = scheduler . startWithCreate ( function ( ) {
277- return xs . throttleWithSelector ( function ( x ) {
277+ return xs . debounceWithSelector ( function ( x ) {
278278 return scheduler . createColdObservable ( onCompleted ( x * 10 ) ) ;
279279 } ) ;
280280 } ) ;
0 commit comments