Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,42 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import Constants from "~/application/Constants";
|
||||
import { getPaginationFromCurrentUrl } from "./RowPaginationHelper";
|
||||
|
||||
function paginationFor(query: string) {
|
||||
return getPaginationFromCurrentUrl(new URLSearchParams(query));
|
||||
}
|
||||
|
||||
describe("RowPaginationHelper", () => {
|
||||
it("defaults invalid pagination params before they reach database queries", () => {
|
||||
expect(paginationFor("page=abc&pageSize=abc")).toMatchObject({
|
||||
page: 1,
|
||||
pageSize: Constants.DEFAULT_PAGE_SIZE,
|
||||
});
|
||||
expect(paginationFor("page=NaN&pageSize=Infinity")).toMatchObject({
|
||||
page: 1,
|
||||
pageSize: Constants.DEFAULT_PAGE_SIZE,
|
||||
});
|
||||
});
|
||||
|
||||
it("rejects decimal, zero, and negative pagination params", () => {
|
||||
expect(paginationFor("page=1.5&pageSize=25.5")).toMatchObject({
|
||||
page: 1,
|
||||
pageSize: Constants.DEFAULT_PAGE_SIZE,
|
||||
});
|
||||
expect(paginationFor("page=0&pageSize=0")).toMatchObject({
|
||||
page: 1,
|
||||
pageSize: Constants.DEFAULT_PAGE_SIZE,
|
||||
});
|
||||
expect(paginationFor("page=-3&pageSize=-20")).toMatchObject({
|
||||
page: 1,
|
||||
pageSize: Constants.DEFAULT_PAGE_SIZE,
|
||||
});
|
||||
});
|
||||
|
||||
it("caps oversized page sizes while preserving valid page numbers", () => {
|
||||
expect(paginationFor(`page=3&pageSize=${Constants.MAX_PAGE_SIZE + 1}`)).toMatchObject({
|
||||
page: 3,
|
||||
pageSize: Constants.MAX_PAGE_SIZE,
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user