pinchflat/test/pinchflat_web/controllers/sources/source_enable_toggle_test.exs
2024-12-12 16:07:23 -08:00

26 lines
820 B
Elixir

defmodule PinchflatWeb.Sources.SourceLive.SourceEnableToggleTest do
use PinchflatWeb.ConnCase
import Phoenix.LiveViewTest
alias PinchflatWeb.Sources.SourceLive.SourceEnableToggle
describe "initial rendering" do
test "renders a toggle in the on position if the source is enabled" do
source = %{id: 1, enabled: true}
html = render_component(SourceEnableToggle, %{id: :foo, source: source})
# This is checking the Alpine attrs which is a good-enough proxy for the toggle position
assert html =~ "{ enabled: true }"
end
test "renders a toggle in the off position if the source is disabled" do
source = %{id: 1, enabled: false}
html = render_component(SourceEnableToggle, %{id: :foo, source: source})
assert html =~ "{ enabled: false }"
end
end
end