Packages
Write pipeable, fast, and easy-to-read feature tests for your Phoenix apps in a unified way -- regardless of whether you're testing LiveView pages or static pages.
Current section
Files
Jump to
Current section
Files
lib/phoenix_test/utils.ex
defmodule PhoenixTest.Utils do
@moduledoc false
def name_to_map(name, value) do
parts = Regex.scan(~r/[\w|-]+/, name)
parts
|> List.flatten()
|> Enum.reverse()
|> Enum.reduce(value, fn key, acc ->
%{key => acc}
end)
end
def present?(term), do: !blank?(term)
def blank?(term), do: term == nil || term == ""
def stringify_keys_and_values(map) do
Map.new(map, fn {k, v} -> {to_string(k), to_string(v)} end)
end
end