diff options
author | Hubert Chathi <hubert@uhoreg.ca> | 2020-04-25 21:57:19 -0400 |
---|---|---|
committer | Hubert Chathi <hubert@uhoreg.ca> | 2020-04-25 21:57:19 -0400 |
commit | d186b7d7d799f4cb7e201077760904821298247f (patch) | |
tree | d700a48c027cc002f3890434a9bf825e985484a1 /test/polyjuice | |
parent | more unit tests (diff) |
test message streaming
Diffstat (limited to 'test/polyjuice')
-rw-r--r-- | test/polyjuice/client/room_test.exs | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/test/polyjuice/client/room_test.exs b/test/polyjuice/client/room_test.exs index afc2052..f5470bc 100644 --- a/test/polyjuice/client/room_test.exs +++ b/test/polyjuice/client/room_test.exs @@ -237,4 +237,56 @@ defmodule Polyjuice.Client.RoomTest do ) end end + + test "stream messages" do + with client = + DummyClient.MultiReq.create([ + { + %Polyjuice.Client.Endpoint.GetRoomsMessages{ + room: "!room", + from: "token1", + dir: :backward + }, + {:ok, + %{ + "start" => "token1", + "end" => "token2", + "chunk" => [ + "event1", + "event2" + ] + }} + }, + { + %Polyjuice.Client.Endpoint.GetRoomsMessages{ + room: "!room", + from: "token2", + dir: :backward + }, + {:ok, + %{ + "start" => "token2", + "end" => "token2", + "chunk" => [] + }} + } + ]) do + events = + Polyjuice.Client.Room.stream_messages(client, "!room", "token1", :backward) + |> Enum.to_list() + + assert events == [ + %{ + "start" => "token1", + "end" => "token2", + "chunk" => [ + "event1", + "event2" + ] + } + ] + + DummyClient.MultiReq.destroy(client) + end + end end |