You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR adds a fetch handler that uses `page`, assuming `result_info` provided by the endpoint contains `page`, `per_page`, and `total`
6
+
7
+
This is needed as the existing `fetchListResult` handler for fetching potentially paginated results doesn't work for endpoints that don't implement `cursor`.
hasMorePages is a function that returns a boolean based on the result_info object returned from the cloudflare v4 API - if the current page is less than the total number of pages, it returns true, otherwise false.
5
+
*/
6
+
7
+
describe("hasMorePages",()=>{
8
+
it("should handle result_info not having enough results to paginate",()=>{
9
+
expect(
10
+
hasMorePages({
11
+
page: 1,
12
+
per_page: 10,
13
+
count: 5,
14
+
total_count: 5,
15
+
})
16
+
).toBe(false);
17
+
});
18
+
it("should return true if the current page is less than the total number of pages",()=>{
19
+
expect(
20
+
hasMorePages({
21
+
page: 1,
22
+
per_page: 10,
23
+
count: 10,
24
+
total_count: 100,
25
+
})
26
+
).toBe(true);
27
+
});
28
+
it("should return false if we are on the last page of results",()=>{
0 commit comments