| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- import { describe, expect, it } from "vitest";
- import {
- resolveMarkdownTableStickyScrollbarMode,
- resolveMarkdownTableStickyScrollbarOffset,
- } from "@/components/ai-elements/markdown-table.js";
- describe("resolveMarkdownTableStickyScrollbarMode", () => {
- it("enables sticky markdown table scrollbars for tall content", () => {
- expect(
- resolveMarkdownTableStickyScrollbarMode({
- stickyScrollbarDisabled: false,
- viewportHeight: 800,
- dockHeight: 200,
- tableHeight: 500,
- }),
- ).toBe(true);
- });
- it("disables sticky markdown table scrollbars for opted-out subagent content", () => {
- expect(
- resolveMarkdownTableStickyScrollbarMode({
- stickyScrollbarDisabled: true,
- viewportHeight: 256,
- dockHeight: 200,
- tableHeight: 220,
- }),
- ).toBe(false);
- });
- });
- describe("resolveMarkdownTableStickyScrollbarOffset", () => {
- it("pins a long table scrollbar to the visible timeline bottom", () => {
- expect(
- resolveMarkdownTableStickyScrollbarOffset({
- frameTop: -87,
- frameBottom: 1211,
- scrollbarHeight: 26,
- viewportBottom: 921,
- }),
- ).toBe(-290);
- });
- it("keeps the scrollbar inside the current table boundaries", () => {
- expect(
- resolveMarkdownTableStickyScrollbarOffset({
- frameTop: 950,
- frameBottom: 2248,
- scrollbarHeight: 26,
- viewportBottom: 921,
- }),
- ).toBe(-1272);
- expect(
- resolveMarkdownTableStickyScrollbarOffset({
- frameTop: -1400,
- frameBottom: -102,
- scrollbarHeight: 26,
- viewportBottom: 921,
- }),
- ).toBe(0);
- });
- });
|