Add the marker test the last commit claimed

4935db2 · Gabriel Morell · 2026-09-03 19:17

5 files +44 -0
Message
{commit_body(@commit)}

Files changed

added apps/room_sanctum/test/room_sanctum_web/plani_markers_test.exs
+44 −0
@@ -0,0 +1,44 @@
1 +defmodule RoomSanctumWeb.PlaniMarkersTest do
2 + use ExUnit.Case, async: true
3 +
4 + alias RoomSanctumWeb.PlaniLive.Show
5 +
6 + # Spin's dockless SF feed, as it appeared in the trace of the 500.
7 + defp bike do
8 + %{
9 + kind: :bike,
10 + lat: 37.788274,
11 + lon: -122.40765170000002,
12 + name: "36ff0ff0-9b8f-4384-87f7-3e75fb43c158",
13 + source_id: 10,
14 + source_name: "Spin (SF)"
15 + }
16 + end
17 +
18 + defp stop do
19 + %{kind: :stop, lat: 42.39, lon: -71.11, name: "Davis", source_id: 4, source_name: "MBTA"}
20 + end
21 +
22 + test "a marker carries its location under both keys the map layers use" do
23 + # A station layer reads `place` and a free bike layer reads `point`. A
24 + # marker does not know which one it is bound for, and dot access on the
25 + # missing one raised rather than reading nil -- which was a 500, not a
26 + # missing pin.
27 + [marker] = Show.markers(%{places: [bike()]}, :bikes)
28 +
29 + assert %Geo.Point{coordinates: {-122.40765170000002, 37.788274}} = marker.point
30 + assert marker.point == marker.place
31 + end
32 +
33 + test "bikes and everything else land on their own layers" do
34 + where = %{places: [bike(), stop()]}
35 +
36 + assert [%{name: "36ff0ff0-9b8f-4384-87f7-3e75fb43c158"}] = Show.markers(where, :bikes)
37 + assert [%{name: "Davis"}] = Show.markers(where, :stations)
38 + end
39 +
40 + test "a Plani that has not ticked yet has no markers" do
41 + assert Show.markers(nil, :bikes) == []
42 + assert Show.markers(%{}, :stations) == []
43 + end
44 +end

Parents: 47ac060