Skip to content

Commit

Permalink
Added tests for static templates.
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaddox5 committed Nov 19, 2024
1 parent 198c3fc commit fc2fda3
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
14 changes: 12 additions & 2 deletions test/fixtures/static_templates.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,23 @@
"title": "Bicycles (English)",
"visual_text": "To make space for other passengers, bicycles are not permitted on trains during rush hour, or at any time of day on the Green Line. For details visit mbta.com/bikes.",
"audio_text": "To make space for other passengers, bicycles are not permitted on trains during rush hour, or at any time of day on the Green Line. For details visit mbta.com/bikes.",
"type": "psa"
"type": "psa",
"archived": false
},
{
"id": 2,
"title": "Backpacks (English)",
"visual_text": "To make space for other passengers and speed up boarding, please take off your backpack before entering the train and hold it at your side.",
"audio_text": "To make space for other passengers and speed up boarding, please take off your backpack before entering the train and hold it at your side.",
"type": "psa"
"type": "psa",
"archived": false
},
{
"id": 3,
"title": "Track Fires (English)",
"visual_text": "Delays due to fires are often caused by trash on the tracks. Please help us keep our stations clean by throwing away or recycling unwanted items.",
"audio_text": "Delays due to fires are often caused by trash on the tracks. Please help us keep our stations clean by throwing away or recycling unwanted items.",
"type": "psa",
"archived": true
}
]
25 changes: 25 additions & 0 deletions test/screenplay/pa_messages/static_templates_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
defmodule Screenplay.PaMessages.StaticTemplatesTest do
use ScreenplayWeb.DataCase

alias Screenplay.PaMessages.StaticTemplates

describe "get_all/0" do
test "returns all active templates" do
assert {:ok, [%{"id" => 1}, %{"id" => 2}]} = StaticTemplates.get_all()
end
end

describe "get_template/1" do
test "returns active template" do
assert {:ok, %{"id" => 1}} = StaticTemplates.get_template(1)
end

test "returns nil for inactive templates" do
assert {:ok, nil} = StaticTemplates.get_template(3)
end

test "returns nil for templates that do not exist" do
assert {:ok, nil} = StaticTemplates.get_template(9999)
end
end
end

0 comments on commit fc2fda3

Please sign in to comment.