File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ class Resource {
1212 this . signatureFactory = signatureFactory ;
1313 this . config = config ;
1414 this . str = '' ;
15+ this . queryParams = { } ;
1516 }
1617
1718 handleOnData ( newJsonString ) {
@@ -27,7 +28,10 @@ class Resource {
2728 this . _results = this . _results . concat ( this . answer . items ) ;
2829
2930 if ( this . answer . hasMore && this . config . iterator ) {
30- this . _query = Object . assign ( this . _query , { params : { since : this . answer . lastTimestamp } } ) ;
31+ // Delete since to be replaced by since of new answer
32+ delete this . queryParams . since ;
33+ const params = Object . assign ( { } , { since : this . answer . lastTimestamp } , this . queryParams ) ;
34+ this . _query = Object . assign ( this . _query , { params} ) ;
3135 this . get ( this . _query , this . _results ) . then ( ( results ) => {
3236 resolve ( results ) ;
3337 } ) ;
@@ -62,6 +66,7 @@ class Resource {
6266 get ( query , results ) {
6367 this . _query = query || { } ;
6468 this . _results = results || [ ] ;
69+ this . queryParams = this . _query . params || { } ;
6570
6671 this . signatureFactory . setUrl ( this . url ) ;
6772 this . signatureFactory . setHeaders ( Resource . getDefaultHeaders ( packageJson . version ) ) ;
Original file line number Diff line number Diff line change @@ -67,15 +67,20 @@ describe('Resource', function() {
6767 it ( 'calls get with query and updated results if hasMore and iterator is true' , function ( ) {
6868 this . resource . _results = [ { id : 'foo' } ] ;
6969 this . resource . _query = {
70- baz : 'bax'
70+ id : 'foo' ,
71+ params : {
72+ limit : 10 ,
73+ }
7174 } ;
75+ this . resource . queryParams = { limit : 10 } ;
7276 this . resource . config . iterator = true ;
7377 this . resource . str = '{"items": [{"id": "bar"}], "hasMore": true, "lastTimestamp": 1}' ;
7478 spyOn ( this . resource , 'get' ) . and . returnValue ( Promise . resolve ( ) ) ;
7579 this . resource . handleOnEnd ( this . spies . resolve , this . spies . reject ) ;
7680 expect ( this . resource . get ) . toHaveBeenCalledWith ( {
77- baz : 'bax ' ,
81+ id : 'foo ' ,
7882 params : {
83+ limit : 10 ,
7984 since : 1
8085 }
8186 } , [ { id : 'foo' } , { id : 'bar' } ] ) ;
You can’t perform that action at this time.
0 commit comments