-
Notifications
You must be signed in to change notification settings - Fork 690
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(hasMorePages): add tests for hasMorePages
- Loading branch information
Showing
2 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { hasMorePages } from "../cfetch"; | ||
|
||
/** | ||
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. | ||
*/ | ||
|
||
describe("hasMorePages", () => { | ||
it("should handle result_info not having enough results to paginate", () => { | ||
expect( | ||
hasMorePages({ | ||
page: 1, | ||
per_page: 10, | ||
count: 5, | ||
total_count: 5, | ||
}) | ||
).toBe(false); | ||
}); | ||
it("should return true if the current page is less than the total number of pages", () => { | ||
expect( | ||
hasMorePages({ | ||
page: 1, | ||
per_page: 10, | ||
count: 10, | ||
total_count: 100, | ||
}) | ||
).toBe(true); | ||
}); | ||
it("should return false if we are on the last page of results", () => { | ||
expect( | ||
hasMorePages({ | ||
page: 10, | ||
per_page: 10, | ||
count: 10, | ||
total_count: 100, | ||
}) | ||
).toBe(false); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters