- Rename 132 *.vitest.mjs -> *.vitest.ts - Rename vitest.setup.mjs -> vitest.setup.ts - Rename helpers/vitestEnvironment.mjs -> vitestEnvironment.ts - Delete settings_store.test.mjs (Node test runner, superseded by .vitest.ts) - Fix .mjs imports in vitest.setup.ts and grid_loader_adaptive_paging.vitest.ts Config updates: - vitest.config.mjs: setupFiles, include, coverage.include -> .ts - tsconfig.test.json: new dedicated config for test files (strict:false) - knip.json: update project pattern for tests - package.json: add typecheck:tests script (audit-only)
27 lines
918 B
TypeScript
27 lines
918 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import {
|
|
buildStaticGridRows,
|
|
getGridRowItems,
|
|
} from "../vue/grid/useGridVirtualRows.js";
|
|
|
|
describe("useGridVirtualRows helpers", () => {
|
|
it("builds fixed-width rows from an item list", () => {
|
|
expect(buildStaticGridRows([1, 2, 3, 4, 5], 2)).toEqual([
|
|
{ index: 0, items: [1, 2] },
|
|
{ index: 1, items: [3, 4] },
|
|
{ index: 2, items: [5] },
|
|
]);
|
|
});
|
|
|
|
it("returns items for a virtual row index", () => {
|
|
expect(getGridRowItems(["a", "b", "c", "d"], 1, 3)).toEqual(["d"]);
|
|
expect(getGridRowItems(["a", "b", "c", "d"], 0, 3)).toEqual(["a", "b", "c"]);
|
|
});
|
|
|
|
it("guards invalid column counts", () => {
|
|
expect(buildStaticGridRows([1, 2], 0)).toEqual([{ index: 0, items: [1] }, { index: 1, items: [2] }]);
|
|
expect(getGridRowItems([1, 2], 1, 0)).toEqual([2]);
|
|
});
|
|
});
|