Skip to content

Commit

Permalink
Test casting a page param to a non-existing atom
Browse files Browse the repository at this point in the history
  • Loading branch information
bartblast committed Jan 27, 2025
1 parent a18c7bc commit cc26448
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion test/elixir/hologram/page_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,20 @@ defmodule Hologram.PageTest do
assert cast_params(Module6, %{a: :test}) == %{a: :test}
end

test "string -> atom" do
test "to existing atom" do
assert cast_params(Module6, %{a: "test"}) == %{a: :test}
end

test "to non-existing atom" do
random_string = random_string()

assert_raise Hologram.ParamError,
~s/can't cast param "a" with value "#{random_string}" to atom, because it's not an already existing atom/,
fn ->
cast_params(Module6, %{a: random_string})
end
end

test "map -> atom" do
assert_raise Hologram.ParamError,
~s/can't cast param "a" with value %{x: 1, y: 2} to atom, because it's of invalid type/,
Expand Down

0 comments on commit cc26448

Please sign in to comment.