Extract LiveTestHelpers.escape/1

This commit is contained in:
Claudio Ortolina
2025-01-19 16:14:59 +00:00
parent ed9fb25ece
commit 53d82e661a
6 changed files with 8 additions and 24 deletions
@@ -9,12 +9,6 @@ defmodule MusicLibraryWeb.ArtistLive.ShowTest do
setup :verify_on_exit!
defp escape(string) do
string
|> Phoenix.HTML.html_escape()
|> Phoenix.HTML.safe_to_string()
end
defp fill_collection(_config) do
collection_record =
record_with_artist("Steven Wilson", %{
@@ -22,12 +22,6 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do
%{wishlist: records}
end
defp escape(string) do
string
|> Phoenix.HTML.html_escape()
|> Phoenix.HTML.safe_to_string()
end
describe "Collection" do
setup [:fill_collection, :fill_wishlist]
@@ -4,12 +4,6 @@ defmodule MusicLibraryWeb.CollectionLive.ShowTest do
import MusicLibrary.RecordsFixtures
alias MusicLibrary.Records.Record
defp escape(string) do
string
|> Phoenix.HTML.html_escape()
|> Phoenix.HTML.safe_to_string()
end
describe "Edit record from show page" do
test "can navigate to the record edit form", %{conn: conn} do
record = record()
@@ -20,12 +20,6 @@ defmodule MusicLibraryWeb.StatsLive.IndexTest do
%{wishlist: records}
end
defp escape(string) do
string
|> Phoenix.HTML.html_escape()
|> Phoenix.HTML.safe_to_string()
end
describe "Stats home page" do
setup [:fill_collection, :fill_wishlist]
+1
View File
@@ -30,6 +30,7 @@ defmodule MusicLibraryWeb.ConnCase do
import MusicLibraryWeb.ConnCase
import PhoenixTest
import Phoenix.LiveViewTest, only: [render: 1, render_async: 1]
import MusicLibraryWeb.LiveTestHelpers
end
end
+7
View File
@@ -0,0 +1,7 @@
defmodule MusicLibraryWeb.LiveTestHelpers do
def escape(string) do
string
|> Phoenix.HTML.html_escape()
|> Phoenix.HTML.safe_to_string()
end
end