Skip to content
Source
Sign inSign up

pullRequestTabScroll.test.ts

19 lines986 Bytes

1import { describe, expect, it } from "vite-plus/test";
2import { pullRequestTabOffset } from "./pullRequestTabScroll";
3​
4describe("pull request tab scroll", () => {
5 it("keeps the header fixed while switching, even if the destination was scrolled deeply", () => {
6 expect(pullRequestTabOffset(-100, 900, 200)).toBe(-100);
7 expect(pullRequestTabOffset(75, 900, 200)).toBe(75);
8 });
9 it("resumes the destination body only when the shared header is already collapsed", () => {
10 expect(pullRequestTabOffset(600, 900, 200)).toBe(900);
11 expect(pullRequestTabOffset(600, 50, 200)).toBe(200);
12 expect(pullRequestTabOffset(600, undefined, 200)).toBe(200);
13 });
14 it("retains the saved body offset when native scrolling rounds the collapsed header", () => {
15 const headerEnd = 213.6666717529297 - 116;
16 expect(pullRequestTabOffset(97.66666666666667, 800, headerEnd)).toBe(800);
17 expect(pullRequestTabOffset(headerEnd - 1, 800, headerEnd)).toBe(headerEnd - 1);
18 });
19});