import assert from "node:assert/strict";
import { test } from "bun:test";

import { isScrollNearBottom, scrollFollowStateFromMetrics } from "./useScrollFollow";

test("workspace scroll follow detaches when the user scrolls away from bottom", () => {
  const detached = scrollFollowStateFromMetrics({ scrollTop: 300, clientHeight: 600, scrollHeight: 1200 });
  assert.equal(detached, false);
});

test("workspace scroll follow re-enters follow mode when the user reaches bottom", () => {
  const following = scrollFollowStateFromMetrics({ scrollTop: 568, clientHeight: 600, scrollHeight: 1200 });
  assert.equal(following, true);
});

test("workspace scroll follow treats short content as already pinned", () => {
  assert.equal(isScrollNearBottom({ scrollTop: 0, clientHeight: 900, scrollHeight: 720 }), true);
});
