diff --git a/test/screens/v2/candidate_generator/elevator/closures_test.exs b/test/screens/v2/candidate_generator/elevator/closures_test.exs index 9dd6582ed..962da0be7 100644 --- a/test/screens/v2/candidate_generator/elevator/closures_test.exs +++ b/test/screens/v2/candidate_generator/elevator/closures_test.exs @@ -18,7 +18,17 @@ defmodule Screens.V2.CandidateGenerator.Elevator.ClosuresTest do @stop injected(Stop) describe "elevator_status_instances/1" do - test "Only returns alerts with effect of :elevator_closure" do + setup do + %{ + config: %Elevator{ + elevator_id: "111", + accessible_path_direction_arrow: :n, + alternate_direction_text: "Test" + } + } + end + + test "Only returns alerts with effect of :elevator_closure", %{config: config} do expect(@facility, :fetch_stop_for_facility, fn "111" -> {:ok, %Stop{id: "place-test"}} end) expect(@stop, :fetch_parent_station_name_map, fn -> @@ -51,7 +61,7 @@ defmodule Screens.V2.CandidateGenerator.Elevator.ClosuresTest do [ %Screens.V2.WidgetInstance.ElevatorClosures{ - id: "111", + elevator_config: ^config, in_station_closures: [ %{ id: "1", @@ -65,11 +75,11 @@ defmodule Screens.V2.CandidateGenerator.Elevator.ClosuresTest do } ] = ElevatorClosures.elevator_status_instances( - struct(Screen, app_id: :elevator_v2, app_params: %Elevator{elevator_id: "111"}) + struct(Screen, app_id: :elevator_v2, app_params: config) ) end - test "Groups outside closures by station" do + test "Groups outside closures by station", %{config: config} do expect(@facility, :fetch_stop_for_facility, fn "111" -> {:ok, %Stop{id: "place-test"}} end) expect(@stop, :fetch_parent_station_name_map, fn -> @@ -107,7 +117,7 @@ defmodule Screens.V2.CandidateGenerator.Elevator.ClosuresTest do [ %Screens.V2.WidgetInstance.ElevatorClosures{ - id: "111", + elevator_config: ^config, in_station_closures: [], other_stations_with_closures: [ %{ @@ -135,11 +145,11 @@ defmodule Screens.V2.CandidateGenerator.Elevator.ClosuresTest do } ] = ElevatorClosures.elevator_status_instances( - struct(Screen, app_id: :elevator_v2, app_params: %Elevator{elevator_id: "111"}) + struct(Screen, app_id: :elevator_v2, app_params: config) ) end - test "Filters alerts with no facilities or more than one facility" do + test "Filters alerts with no facilities or more than one facility", %{config: config} do expect(@facility, :fetch_stop_for_facility, fn "111" -> {:ok, %Stop{id: "place-test"}} end) expect(@stop, :fetch_parent_station_name_map, fn -> @@ -172,17 +182,17 @@ defmodule Screens.V2.CandidateGenerator.Elevator.ClosuresTest do [ %Screens.V2.WidgetInstance.ElevatorClosures{ - id: "111", + elevator_config: ^config, in_station_closures: [], other_stations_with_closures: [] } ] = ElevatorClosures.elevator_status_instances( - struct(Screen, app_id: :elevator_v2, app_params: %Elevator{elevator_id: "111"}) + struct(Screen, app_id: :elevator_v2, app_params: config) ) end - test "Return empty routes on API error" do + test "Return empty routes on API error", %{config: config} do expect(@facility, :fetch_stop_for_facility, fn "111" -> {:ok, %Stop{id: "place-test"}} end) expect(@stop, :fetch_parent_station_name_map, fn -> @@ -209,7 +219,7 @@ defmodule Screens.V2.CandidateGenerator.Elevator.ClosuresTest do [ %Screens.V2.WidgetInstance.ElevatorClosures{ - id: "111", + elevator_config: ^config, in_station_closures: [ %{ id: "1", @@ -223,7 +233,7 @@ defmodule Screens.V2.CandidateGenerator.Elevator.ClosuresTest do } ] = ElevatorClosures.elevator_status_instances( - struct(Screen, app_id: :elevator_v2, app_params: %Elevator{elevator_id: "111"}) + struct(Screen, app_id: :elevator_v2, app_params: config) ) end end diff --git a/test/screens/v2/candidate_generator/elevator_test.exs b/test/screens/v2/candidate_generator/elevator_test.exs index 4053999b1..0e4180428 100644 --- a/test/screens/v2/candidate_generator/elevator_test.exs +++ b/test/screens/v2/candidate_generator/elevator_test.exs @@ -8,7 +8,9 @@ defmodule Screens.V2.CandidateGenerator.ElevatorTest do config = %Screen{ app_id: :elevator_v2, app_params: %V2.Elevator{ - elevator_id: "1" + elevator_id: "1", + alternate_direction_text: "Test", + accessible_path_direction_arrow: :n }, device_id: "TEST", name: "TEST", diff --git a/test/screens/v2/widget_instance/elevator_closures_test.exs b/test/screens/v2/widget_instance/elevator_closures_test.exs index 553ea625a..73ccea921 100644 --- a/test/screens/v2/widget_instance/elevator_closures_test.exs +++ b/test/screens/v2/widget_instance/elevator_closures_test.exs @@ -3,11 +3,17 @@ defmodule Screens.V2.WidgetInstance.ElevatorClosuresTest do alias Screens.V2.WidgetInstance alias Screens.V2.WidgetInstance.ElevatorClosures + alias ScreensConfig.V2.Elevator setup do %{ instance: %ElevatorClosures{ - id: "111", + elevator_config: + struct(Elevator, + elevator_id: "1", + alternate_direction_text: "Test", + accessible_path_direction_arrow: :n + ), in_station_closures: [ %ElevatorClosures.Closure{ description: "Test Alert Description", @@ -44,7 +50,17 @@ defmodule Screens.V2.WidgetInstance.ElevatorClosuresTest do describe "serialize/1" do test "returns map with id and closures", %{instance: instance} do - assert Map.from_struct(instance) == WidgetInstance.serialize(instance) + assert %{ + in_station_closures: instance.in_station_closures, + other_stations_with_closures: instance.other_stations_with_closures, + accessible_path_direction_arrow: + instance.elevator_config.accessible_path_direction_arrow, + accessible_path_image_here_coordinates: + instance.elevator_config.accessible_path_image_here_coordinates, + accessible_path_image_url: instance.elevator_config.accessible_path_image_url, + alternate_direction_text: instance.elevator_config.alternate_direction_text, + id: instance.elevator_config.elevator_id + } == WidgetInstance.serialize(instance) end end