Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stringify lists in the ChannelTest module #5576

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/phoenix/test/channel_test.ex
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,8 @@ defmodule Phoenix.ChannelTest do
do: struct
def __stringify__(%{} = params),
do: Enum.into(params, %{}, &stringify_kv/1)
def __stringify__(params) when is_list(params),
do: Enum.map(params, &__stringify__/1)
def __stringify__(other),
do: other

Expand Down
6 changes: 6 additions & 0 deletions test/phoenix/test/channel_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,12 @@ defmodule Phoenix.Test.ChannelTest do
assert_reply ref, :ok, %{"resp" => "foo"}
end

test "works with list data structures" do
{:ok, _, socket} = join(socket(UserSocket), Channel, "foo:ok")
ref = push(socket, "reply", %{req: [%{bar: "baz"}, %{bar: "foo"}]})
assert_reply ref, :ok, %{"resp" => [%{"bar" => "baz"}, %{"bar" => "foo"}]}
end

test "receives async replies" do
{:ok, _, socket} = join(socket(UserSocket), Channel, "foo:ok")

Expand Down