diff --git a/test/aprsme/postgres_notifier_test.exs b/test/aprsme/postgres_notifier_test.exs new file mode 100644 index 0000000..bea6c96 --- /dev/null +++ b/test/aprsme/postgres_notifier_test.exs @@ -0,0 +1,24 @@ +defmodule Aprsme.PostgresNotifierTest do + use ExUnit.Case, async: true + + alias Aprsme.PostgresNotifier + + describe "handle_info/2 notification forwarding" do + test "broadcasts the payload on Aprsme.PubSub for aprs_events channel" do + :ok = Phoenix.PubSub.subscribe(Aprsme.PubSub, "postgres:aprsme_events") + + msg = {:notification, :conn_stub, :from_pid, "aprs_events", "payload-content"} + + assert {:noreply, state} = PostgresNotifier.handle_info(msg, %{conn: :stub}) + assert state.conn == :stub + + assert_receive {:postgres_notify, "payload-content"}, 500 + end + + test "ignores unrelated messages" do + state = %{conn: :stub} + assert {:noreply, ^state} = PostgresNotifier.handle_info(:random_message, state) + assert {:noreply, ^state} = PostgresNotifier.handle_info({:other_tuple, "data"}, state) + end + end +end diff --git a/test/aprsme_web/components/core_components_test.exs b/test/aprsme_web/components/core_components_test.exs index 9305ec8..c084aa3 100644 --- a/test/aprsme_web/components/core_components_test.exs +++ b/test/aprsme_web/components/core_components_test.exs @@ -145,6 +145,122 @@ defmodule AprsmeWeb.CoreComponentsTest do # Checkbox is pre-checked when value matches "true". assert html =~ "checked" end + + test "checkbox is unchecked when value is not 'true'" do + html = + render_component(&CoreComponents.input/1, %{ + id: "flag", + name: "flag", + type: "checkbox", + value: "false", + errors: [] + }) + + refute html =~ " checked " + end + end + + describe "input/1 select" do + test "renders a select with options" do + html = + render_component(&CoreComponents.input/1, %{ + id: "color", + name: "color", + type: "select", + label: "Color", + value: "red", + errors: [], + options: [{"Red", "red"}, {"Blue", "blue"}], + multiple: false, + prompt: nil + }) + + assert html =~ "