1import { describe, expect, it } from "vite-plus/test";
2
3import { resolveCenteredFileLineScrollTop } from "./fileLineReveal";
4
5describe("resolveCenteredFileLineScrollTop", () => {
6 it("centers an estimated virtualized line position", () => {
7 expect(
8 resolveCenteredFileLineScrollTop({
9 scrollTop: 0,
10 scrollHeight: 2_000,
11 viewportTop: 100,
12 viewportHeight: 400,
13 fileTop: 20,
14 estimatedLine: { top: 1_000, height: 20 },
15 }),
16 ).toBe(830);
17 });
18
19 it("corrects a stale estimate from the rendered line geometry", () => {
20 expect(
21 resolveCenteredFileLineScrollTop({
22 scrollTop: 830,
23 scrollHeight: 2_000,
24 viewportTop: 100,
25 viewportHeight: 400,
26 fileTop: 20,
27 estimatedLine: { top: 1_000, height: 20 },
28 renderedLine: { top: 620, height: 20 },
29 }),
30 ).toBe(1_160);
31 });
32});