Files
dbx/packages/app-tests/dataGridPagination.test.ts
T
t8y2 fabf2172e4 chore: migrate test runner from node:test/tsx to vitest
155 files, 1091 tests, 4.3s (2x faster than previous 9.1s).
2026-06-08 01:17:27 +08:00

46 lines
1.1 KiB
TypeScript

import { strict as assert } from "node:assert";
import { test } from "vitest";
import { canGoNextDataGridPage } from "../../apps/desktop/src/lib/dataGridPagination.ts";
test("known total disables next page at the last exact page", () => {
assert.equal(
canGoNextDataGridPage({
rowCount: 1,
pageSize: 1,
pageOffset: 8,
totalRowCount: 9,
}),
false,
);
});
test("known total allows next page before the last page", () => {
assert.equal(
canGoNextDataGridPage({
rowCount: 1,
pageSize: 1,
pageOffset: 7,
totalRowCount: 9,
}),
true,
);
});
test("backend hasMore takes precedence over a stale known total", () => {
assert.equal(
canGoNextDataGridPage({
hasMore: true,
rowCount: 1,
pageSize: 1,
pageOffset: 8,
totalRowCount: 9,
}),
true,
);
});
test("unknown total falls back to full-page heuristic", () => {
assert.equal(canGoNextDataGridPage({ rowCount: 1, pageSize: 1 }), true);
assert.equal(canGoNextDataGridPage({ rowCount: 0, pageSize: 1 }), false);
});