defmodule MicrowavepropWeb.LiveTableFooterTest do
  use ExUnit.Case, async: true

  alias MicrowavepropWeb.LiveTableFooter

  describe "page_items/2" do
    test "page 1 with next page shows 1 and 2" do
      assert LiveTableFooter.page_items(1, true) == [1, 2]
    end

    test "page 1 without next page shows only 1" do
      assert LiveTableFooter.page_items(1, false) == [1]
    end

    test "page 3 with next page shows contiguous window without ellipsis" do
      assert LiveTableFooter.page_items(3, true) == [1, 2, 3, 4]
    end

    test "page 4 with next page still contiguous (window_start == 2)" do
      assert LiveTableFooter.page_items(4, true) == [1, 2, 3, 4, 5]
    end

    test "page 5 with next page collapses with ellipsis" do
      assert LiveTableFooter.page_items(5, true) == [1, :ellipsis, 3, 4, 5, 6]
    end

    test "page 10 without next page omits trailing page" do
      assert LiveTableFooter.page_items(10, false) == [1, :ellipsis, 8, 9, 10]
    end

    test "page 2 with next page shows 1, 2, 3" do
      assert LiveTableFooter.page_items(2, true) == [1, 2, 3]
    end
  end
end
