@@ -16,7 +16,7 @@ describe("PaginatorHttp", () => {
1616 it ( "sends a request" , async ( ) => {
1717 const paginator = new PaginatorHttp ( http , "/v1/api/timelines" , {
1818 foo : "bar" ,
19- } ) ;
19+ } ) . values ( ) ;
2020 await paginator . next ( ) ;
2121 expect ( http . request ) . toBeCalledWith ( {
2222 method : "GET" ,
@@ -43,7 +43,7 @@ describe("PaginatorHttp", () => {
4343 link : '<https://mastodon.social/api/v1/timelines/home?max_id=109382006402042919>; rel="next", <https://mastodon.social/api/v1/timelines/home?min_id=109382039876197520>; rel="prev"' ,
4444 } ) ,
4545 } ) ;
46- const paginator = new PaginatorHttp ( http , "/v1/api/timelines" ) ;
46+ const paginator = new PaginatorHttp ( http , "/v1/api/timelines" ) . values ( ) ;
4747 await paginator . next ( ) ;
4848 await paginator . next ( ) ;
4949 expect ( http . request ) . toBeCalledWith ( {
@@ -67,8 +67,9 @@ describe("PaginatorHttp", () => {
6767 paginator = paginator . setDirection ( "prev" ) ;
6868 expect ( paginator . getDirection ( ) ) . toBe ( "prev" ) ;
6969
70- await paginator . next ( ) ;
71- await paginator . next ( ) ;
70+ const pages = paginator . values ( ) ;
71+ await pages . next ( ) ;
72+ await pages . next ( ) ;
7273 expect ( http . request ) . toBeCalledWith ( {
7374 method : "GET" ,
7475 search : "min_id=109382039876197520" ,
@@ -82,7 +83,7 @@ describe("PaginatorHttp", () => {
8283 link : '<https://mastodon.social/api/v1/timelines/home?min_id=109382039876197520>; rel="prev", <https://mastodon.social/api/v1/timelines/home?max_id=109382006402042919>; rel="next"' ,
8384 } ) ,
8485 } ) ;
85- const paginator = new PaginatorHttp ( http , "/v1/api/timelines" ) ;
86+ const paginator = new PaginatorHttp ( http , "/v1/api/timelines" ) . values ( ) ;
8687 await paginator . next ( ) ;
8788 await paginator . next ( ) ;
8889 expect ( http . request ) . toBeCalledWith ( {
@@ -93,7 +94,7 @@ describe("PaginatorHttp", () => {
9394 } ) ;
9495
9596 it ( "returns done when next link does not exist" , async ( ) => {
96- const paginator = new PaginatorHttp ( http , "/v1/api/timelines" ) ;
97+ const paginator = new PaginatorHttp ( http , "/v1/api/timelines" ) . values ( ) ;
9798 await paginator . next ( ) ;
9899 const result = await paginator . next ( ) ;
99100 expect ( result ) . toEqual ( {
@@ -135,50 +136,6 @@ describe("PaginatorHttp", () => {
135136 } ) ;
136137 } ) ;
137138
138- it ( "clones itself" , async ( ) => {
139- const paginator1 = new PaginatorHttp ( http , "/some/api" , { query : "value" } ) ;
140- const paginator2 = paginator1 . clone ( ) ;
141-
142- await paginator1 . next ( ) ;
143- await paginator2 . next ( ) ;
144-
145- expect ( http . request ) . toBeCalledTimes ( 2 ) ;
146- expect ( http . request ) . nthCalledWith ( 1 , {
147- method : "GET" ,
148- search : { query : "value" } ,
149- path : "/some/api" ,
150- } ) ;
151- expect ( http . request ) . nthCalledWith ( 2 , {
152- method : "GET" ,
153- search : { query : "value" } ,
154- path : "/some/api" ,
155- } ) ;
156-
157- expect ( paginator1 ) . not . toBe ( paginator2 ) ;
158- } ) ;
159-
160- it ( "terminates pagination by return" , async ( ) => {
161- const paginator = new PaginatorHttp ( http , "/v1/api/timelines" ) ;
162- await paginator . return ( ) ;
163- const result = await paginator . next ( ) ;
164- expect ( result ) . toEqual ( {
165- done : true ,
166- value : undefined ,
167- } ) ;
168- } ) ;
169-
170- it ( "terminates pagination by throw" , async ( ) => {
171- const paginator = new PaginatorHttp ( http , "/v1/api/timelines" ) ;
172- await expect ( ( ) => paginator . throw ( "some error" ) ) . rejects . toBe (
173- "some error" ,
174- ) ;
175- const result = await paginator . next ( ) ;
176- expect ( result ) . toEqual ( {
177- done : true ,
178- value : undefined ,
179- } ) ;
180- } ) ;
181-
182139 it ( "parse array in url query string correctly" , async ( ) => {
183140 http . request . mockReturnValue ( {
184141 headers : new Headers ( {
@@ -187,7 +144,7 @@ describe("PaginatorHttp", () => {
187144 } ) ;
188145 const paginator = new PaginatorHttp ( http , "/v1/api/notifications" , {
189146 types : [ "mention" ] ,
190- } ) ;
147+ } ) . values ( ) ;
191148 await paginator . next ( ) ;
192149 await paginator . next ( ) ;
193150 expect ( http . request ) . toBeCalledWith ( {
0 commit comments