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

import { resolveBottomFollowingAfterScroll } from "./useBottomFollowScroll";

test("content growth before alignment does not cancel bottom following", () => {
  assert.equal(resolveBottomFollowingAfterScroll({
    following: true,
    previousScrollTop: 400,
    currentScrollTop: 400,
    distanceToBottom: 180,
    threshold: 24
  }), true);
});

test("an actual upward scroll pauses following until the user returns to bottom", () => {
  const paused = resolveBottomFollowingAfterScroll({
    following: true,
    previousScrollTop: 580,
    currentScrollTop: 300,
    distanceToBottom: 280,
    threshold: 24
  });
  assert.equal(paused, false);
  assert.equal(resolveBottomFollowingAfterScroll({
    following: paused,
    previousScrollTop: 300,
    currentScrollTop: 556,
    distanceToBottom: 24,
    threshold: 24
  }), true);
});
