summaryrefslogtreecommitdiff
path: root/test/polyjuice
diff options
context:
space:
mode:
Diffstat (limited to 'test/polyjuice')
-rw-r--r--test/polyjuice/client/room_test.exs (renamed from test/polyjuice/client_test.exs)34
1 files changed, 21 insertions, 13 deletions
diff --git a/test/polyjuice/client_test.exs b/test/polyjuice/client/room_test.exs
index 7c25bc4..36d80cb 100644
--- a/test/polyjuice/client_test.exs
+++ b/test/polyjuice/client/room_test.exs
@@ -12,9 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-defmodule Polyjuice.ClientTest do
+defmodule Polyjuice.Client.RoomTest do
use ExUnit.Case
- doctest Polyjuice.Client
+ doctest Polyjuice.Client.Room
test "send message" do
with client = %DummyClient{
@@ -31,7 +31,7 @@ defmodule Polyjuice.ClientTest do
{:ok, "$foo1"}
}
} do
- {:ok, event_id} = Polyjuice.Client.send_message(client, "foo", "!bar")
+ {:ok, event_id} = Polyjuice.Client.Room.send_message(client, "!bar", "foo")
assert event_id == "$foo1"
end
@@ -51,7 +51,7 @@ defmodule Polyjuice.ClientTest do
{:ok, "$foo2"}
}
} do
- {:ok, event_id} = Polyjuice.Client.send_message(client, {"foo", "<i>foo</i>"}, "!bar")
+ {:ok, event_id} = Polyjuice.Client.Room.send_message(client, "!bar", {"foo", "<i>foo</i>"})
assert event_id == "$foo2"
end
@@ -70,16 +70,24 @@ defmodule Polyjuice.ClientTest do
}
} do
{:ok, event_id} =
- Polyjuice.Client.send_message(client, %{"msgtype" => "m.notice", "body" => "foo"}, "!bar")
+ Polyjuice.Client.Room.send_message(client, "!bar", %{
+ "msgtype" => "m.notice",
+ "body" => "foo"
+ })
assert event_id == "$foo3"
# trying to send a non-msgdata should error
- assert_raise ArgumentError, fn -> Polyjuice.Client.send_message(client, 1, "!bar") end
- assert_raise ArgumentError, fn -> Polyjuice.Client.send_message(client, client, "!bar") end
+ assert_raise ArgumentError, fn ->
+ Polyjuice.Client.Room.send_message(client, "!bar", 1)
+ end
+
+ assert_raise ArgumentError, fn ->
+ Polyjuice.Client.Room.send_message(client, "!bar", client)
+ end
assert_raise FunctionClauseError, fn ->
- Polyjuice.Client.send_message(client, {"a"}, "!bar")
+ Polyjuice.Client.Room.send_message(client, "!bar", {"a"})
end
end
end
@@ -100,11 +108,11 @@ defmodule Polyjuice.ClientTest do
}
} do
{:ok, event_id} =
- Polyjuice.Client.send_event(
+ Polyjuice.Client.Room.send_event(
client,
+ "!bar",
"m.room.message",
- %{"msgtype" => "m.text", "body" => "foo"},
- "!bar"
+ %{"msgtype" => "m.text", "body" => "foo"}
)
assert event_id == "$foo1"
@@ -122,8 +130,8 @@ defmodule Polyjuice.ClientTest do
{:ok}
}
} do
- {:ok} = Polyjuice.Client.update_read_receipt(client, "!room", "$event", "m.read")
- {:ok} = Polyjuice.Client.update_read_receipt(client, "!room", "$event")
+ {:ok} = Polyjuice.Client.Room.update_read_receipt(client, "!room", "$event", "m.read")
+ {:ok} = Polyjuice.Client.Room.update_read_receipt(client, "!room", "$event")
end
end
end