I have a driver channel that passes their location to the provider channel.
defmodule MyApp.DriverChannel do
def handle_in("transmit", payload, socket) do
MyApp.Endpoint.broadcast! "vendors:lobby", "track", payload
{:noreply, socket}
end
end
defmodule MyApp.DriverChannelTest do
test "location broadcasts to vendors:lobby", %{socket: socket} do
push socket, "transmit", %{"hello" => "all"}
assert_broadcast "track", %{"hello" => "all"}
end
end
This statement will fail, because it only checks the broadcast with DriverChannel
, how to claim the translation made in VendorChannel
, I was looking at the source code, it seems that there is no way to transfer channel_name
to assert_broadcast
.
[Another note] I also broadcast the broadcast from the controllers, if I know the answer to this question, I can approve these broadcasts too! :)
source
share