summaryrefslogtreecommitdiff
path: root/test/web/chat_channel_test.exs
diff options
context:
space:
mode:
authorMark Felder <feld@FreeBSD.org>2019-12-11 15:02:53 -0600
committerMark Felder <feld@FreeBSD.org>2019-12-11 15:02:53 -0600
commit9ef912aecfbeef670db0614ec2014321c37f3b7a (patch)
tree69eb0b5e11ca321e1ba8ca794171bf0cb425d16d /test/web/chat_channel_test.exs
parente21afdb7c76c9773aeb51e37ff3bc2874e7a74f7 (diff)
parent92b4a1aa1bc750bb077ae45c422967f9712e247d (diff)
downloadpleroma-9ef912aecfbeef670db0614ec2014321c37f3b7a.tar.gz
pleroma-9ef912aecfbeef670db0614ec2014321c37f3b7a.zip
Merge branch 'develop' into issue/1411
Diffstat (limited to 'test/web/chat_channel_test.exs')
-rw-r--r--test/web/chat_channel_test.exs37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/web/chat_channel_test.exs b/test/web/chat_channel_test.exs
new file mode 100644
index 000000000..68c24a9f9
--- /dev/null
+++ b/test/web/chat_channel_test.exs
@@ -0,0 +1,37 @@
+defmodule Pleroma.Web.ChatChannelTest do
+ use Pleroma.Web.ChannelCase
+ alias Pleroma.Web.ChatChannel
+ alias Pleroma.Web.UserSocket
+
+ import Pleroma.Factory
+
+ setup do
+ user = insert(:user)
+
+ {:ok, _, socket} =
+ socket(UserSocket, "", %{user_name: user.nickname})
+ |> subscribe_and_join(ChatChannel, "chat:public")
+
+ {:ok, socket: socket}
+ end
+
+ test "it broadcasts a message", %{socket: socket} do
+ push(socket, "new_msg", %{"text" => "why is tenshi eating a corndog so cute?"})
+ assert_broadcast("new_msg", %{text: "why is tenshi eating a corndog so cute?"})
+ end
+
+ describe "message lengths" do
+ clear_config([:instance, :chat_limit])
+
+ test "it ignores messages of length zero", %{socket: socket} do
+ push(socket, "new_msg", %{"text" => ""})
+ refute_broadcast("new_msg", %{text: ""})
+ end
+
+ test "it ignores messages above a certain length", %{socket: socket} do
+ Pleroma.Config.put([:instance, :chat_limit], 2)
+ push(socket, "new_msg", %{"text" => "123"})
+ refute_broadcast("new_msg", %{text: "123"})
+ end
+ end
+end