// E31 (the owner's pick): the channel page's tall header folds to one row once the grid scrolls. The header // is fixed, so folding gives the scroller its height back — these are the rules that keep that from // flickering on a page barely taller than the window. import { describe, expect, it } from "vitest"; import { FOLD_AT, nextFolded } from "./scrollFold"; const SAVING = 200; describe("nextFolded", () => { it("folds once the content scrolls past the fold point", () => { expect(nextFolded(false, { top: FOLD_AT + 1, room: 5000 }, SAVING)).toBe(true); expect(nextFolded(false, { top: FOLD_AT, room: 5000 }, SAVING)).toBe(false); }); it("does not fold a page that could not stay scrolled once the header gave its height back", () => { expect(nextFolded(false, { top: 100, room: SAVING + FOLD_AT }, SAVING)).toBe(false); expect(nextFolded(false, { top: 100, room: SAVING + FOLD_AT + 1 }, SAVING)).toBe(true); }); it("stays folded until the very top, not back at the fold point", () => { expect(nextFolded(true, { top: 1, room: 5000 }, SAVING)).toBe(true); expect(nextFolded(true, { top: 0, room: 5000 }, SAVING)).toBe(false); }); });