Skip to content

Commit

Permalink
create video_channel_test.exs p.294 #1
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonic committed Aug 11, 2019
1 parent ee8e23d commit d4824f9
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions apps/rumbl_web/test/channels/video_channel_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
defmodule RumblWeb.Channels.VideoChannelTest do
use RumblWeb.ChannelCase
import RumblWeb.TestHelpers

setup do
user = insert_user(name: "Gary")
video = insert_video(user, title: "Testing")
token = Phoenix.Token.sign(@endpoint, "user socket", user.id)
{:ok, socket} = connect(RumblWeb.UserSocket, %{"token" => token})

{:ok, socket: socket, user: user, video: video}
end

test "join replies with video annotations",
%{socket: socket, video: vid, user: user} do
for body <- ~w(one two) do
Rumbl.Multimedia.annotate_video(user, vid.id, %{body: body, at: 0})
end
{:ok, reply socket} = subscribe_and_join(socket, "videos:#{vid.id}", %{})

assert socket.assigns.video_id == vid.id
assert %{annotations: [%{body: "one"}, %{body: "two"}]} = reply
end
end

0 comments on commit d4824f9

Please sign in to comment.