Skip to content
File

Blob: tests/client/log-viewer-scroll.test.ts

typescript39 lines
1import { describe, expect, it } from "vitest";
2 
3import { isLogViewerPinnedToLatest } from "@/client/components/log-viewer-scroll";
4 
5describe("LogViewer pinned-bottom detection", () => {
6 it("treats a near-bottom position as pinned with normal padding", () => {
7 expect(
8 isLogViewerPinnedToLatest({
9 scrollTop: 785,
10 clientHeight: 400,
11 scrollHeight: 1200,
12 paddingBottom: 16,
13 }),
14 ).toBe(true);
15 });
16 
17 it("treats the jump-button gutter as valid bottom space", () => {
18 expect(
19 isLogViewerPinnedToLatest({
20 scrollTop: 752,
21 clientHeight: 400,
22 scrollHeight: 1200,
23 paddingBottom: 48,
24 }),
25 ).toBe(true);
26 });
27 
28 it("does not treat a materially larger gap as pinned", () => {
29 expect(
30 isLogViewerPinnedToLatest({
31 scrollTop: 720,
32 clientHeight: 400,
33 scrollHeight: 1200,
34 paddingBottom: 48,
35 }),
36 ).toBe(false);
37 });
38});