Skip to content
Source
Sign inSign up

scrollAnchor.test.ts

17 lines636 Bytes

1import { describe, expect, it } from "vite-plus/test";
2​
3import { resolveWorkGroupScrollAnchor } from "./scrollAnchor.js";
4​
5describe("tool-group scroll anchors", () => {
6 const data = Array.from({ length: 18 }, (_, index) => ({ id: `call-${index}` }));
7 const state = { data, positionAtIndex: (index: number) => index * 33 };
8​
9 it("returns to the top after a fast flick even when the cached start is five rows behind", () => {
10 const snapshot = { ...state, scroll: 0, start: 5 };
11 expect(resolveWorkGroupScrollAnchor(snapshot)).toEqual({
12 rowId: "call-0",
13 offsetWithinRow: 0,
14 scrollOffset: 0,
15 });
16 });
17});