aboutsummaryrefslogtreecommitdiff
path: root/shardweb/test/shard_web/channels/room_channel_test.exs
diff options
context:
space:
mode:
Diffstat (limited to 'shardweb/test/shard_web/channels/room_channel_test.exs')
-rw-r--r--shardweb/test/shard_web/channels/room_channel_test.exs28
1 files changed, 28 insertions, 0 deletions
diff --git a/shardweb/test/shard_web/channels/room_channel_test.exs b/shardweb/test/shard_web/channels/room_channel_test.exs
new file mode 100644
index 0000000..f6241d8
--- /dev/null
+++ b/shardweb/test/shard_web/channels/room_channel_test.exs
@@ -0,0 +1,28 @@
+defmodule ShardWeb.RoomChannelTest do
+ use ShardWeb.ChannelCase
+
+ alias ShardWeb.RoomChannel
+
+ setup do
+ {:ok, _, socket} =
+ socket("user_id", %{some: :assign})
+ |> subscribe_and_join(RoomChannel, "room:lobby")
+
+ {:ok, socket: socket}
+ end
+
+ test "ping replies with status ok", %{socket: socket} do
+ ref = push socket, "ping", %{"hello" => "there"}
+ assert_reply ref, :ok, %{"hello" => "there"}
+ end
+
+ test "shout broadcasts to room:lobby", %{socket: socket} do
+ push socket, "shout", %{"hello" => "all"}
+ assert_broadcast "shout", %{"hello" => "all"}
+ end
+
+ test "broadcasts are pushed to the client", %{socket: socket} do
+ broadcast_from! socket, "broadcast", %{"some" => "data"}
+ assert_push "broadcast", %{"some" => "data"}
+ end
+end