937 B · text History 9c0fc16
defmodule LambentExWeb.BrightnessTest do
  use LambentExWeb.ConnCase

  import Phoenix.LiveViewTest

  @pubsub LambentEx.PubSub

  test "a place nobody has clamped yet still renders", %{conn: conn} do
    {:ok, live, _html} = live(conn, "/cfg/brightness")

    Phoenix.PubSub.broadcast(
      @pubsub,
      "scan-82667777",
      {:devices_pub,
       %{
         "8c:fd:49:10:7a:28" => %{
           "ip" => {172, 16, 15, 139},
           "place" => "Ballpit",
           "sox" => 2,
           "type" => "7777-flex"
         }
       }}
    )

    html = render(live)

    assert html =~ "Ballpit"
    # the row carries the default fade, not a missing key
    assert html =~ "TWOMINS"
  end

  test "the global clamp is always there, target slider and all", %{conn: conn} do
    {:ok, _live, html} = live(conn, "/cfg/brightness")

    assert html =~ "Global"
    assert html =~ ~s(name="rung")
    assert html =~ "disabled"
  end
end