import { describe, expect, test } from "vitest";

import { visualViewportStyle } from "./use-visual-viewport";

describe("Workspace visual viewport", () => {
  test("shrinks the application surface to the keyboard-visible height", () => {
    expect(visualViewportStyle({ height: 500, offsetTop: 0 })).toEqual({
      height: "500px",
      transform: undefined,
    });
  });

  test("tracks a panned visual viewport without scrolling the document", () => {
    expect(visualViewportStyle({ height: 500, offsetTop: 44 })).toEqual({
      height: "500px",
      transform: "translateY(44px)",
    });
  });

  test("uses a dynamic viewport fallback before browser measurement", () => {
    expect(visualViewportStyle()).toEqual({
      height: "100dvh",
      transform: undefined,
    });
  });
});
