diff --git a/lib/screens/v2/widget_instance/elevator_closures.ex b/lib/screens/v2/widget_instance/elevator_closures.ex index 0b05c4f87..e08abf23f 100644 --- a/lib/screens/v2/widget_instance/elevator_closures.ex +++ b/lib/screens/v2/widget_instance/elevator_closures.ex @@ -1,7 +1,9 @@ defmodule Screens.V2.WidgetInstance.ElevatorClosures do + @moduledoc false + + alias Screens.Alerts.Alert alias ScreensConfig.Screen alias ScreensConfig.V2.Elevator - alias Screens.Alerts.Alert defstruct screen: nil, alerts: nil, diff --git a/test/screens/v2/widget_instance/elevator_closures_test.exs b/test/screens/v2/widget_instance/elevator_closures_test.exs new file mode 100644 index 000000000..bd12183a6 --- /dev/null +++ b/test/screens/v2/widget_instance/elevator_closures_test.exs @@ -0,0 +1,71 @@ +defmodule Screens.V2.WidgetInstance.ElevatorClosuresTest do + use ExUnit.Case, async: true + + alias Screens.V2.WidgetInstance + alias Screens.V2.WidgetInstance.ElevatorClosures + alias ScreensConfig.Screen + alias ScreensConfig.V2.Elevator + + setup do + %{ + instance: %ElevatorClosures{ + screen: struct(Screen, %{app_params: %Elevator{elevator_id: "111"}}), + time: ~U[2024-10-16T09:00:00Z], + alerts: [] + } + } + end + + describe "priority/1" do + test "returns 1", %{instance: instance} do + assert [1] == WidgetInstance.priority(instance) + end + end + + describe "serialize/1" do + test "returns map with id, alerts, and time", %{instance: instance} do + assert %{ + id: "111", + time: DateTime.to_iso8601(~U[2024-10-16T09:00:00Z]), + in_station_alerts: [], + outside_alerts: [] + } == WidgetInstance.serialize(instance) + end + end + + describe "slot_names/1" do + test "returns main_content", %{instance: instance} do + assert [:main_content] == WidgetInstance.slot_names(instance) + end + end + + describe "widget_type/1" do + test "returns elevator_closures", %{instance: instance} do + assert :elevator_closures == WidgetInstance.widget_type(instance) + end + end + + describe "audio_serialize/1" do + test "returns empty map", %{instance: instance} do + assert %{} == WidgetInstance.audio_serialize(instance) + end + end + + describe "audio_sort_key/1" do + test "returns [0]", %{instance: instance} do + assert [0] == WidgetInstance.audio_sort_key(instance) + end + end + + describe "audio_valid_candidate?/1" do + test "returns false", %{instance: instance} do + refute WidgetInstance.audio_valid_candidate?(instance) + end + end + + describe "audio_view/1" do + test "returns ElevatorClosuresView", %{instance: instance} do + assert ScreensWeb.V2.Audio.ElevatorClosuresView == WidgetInstance.audio_view(instance) + end + end +end