diff options
author | Egor Kislitsyn <egor@kislitsyn.com> | 2019-12-10 00:16:43 +0700 |
---|---|---|
committer | Egor Kislitsyn <egor@kislitsyn.com> | 2019-12-10 00:16:43 +0700 |
commit | c098dec47344303bc00456bfbfc0d769abd8f199 (patch) | |
tree | 709963edcda2d85a5d77ebce4a200ae04fff89cd /test/web/chat_channel_test.exs | |
parent | 78299ab18205b0bbaf521640e188a862ca27aa61 (diff) | |
parent | 0d2c13a119302d0d217a7cb61c28a01c620b1b61 (diff) | |
download | pleroma-c098dec47344303bc00456bfbfc0d769abd8f199.tar.gz pleroma-c098dec47344303bc00456bfbfc0d769abd8f199.zip |
Merge branch 'develop' into feature/custom-runtime-modules
Diffstat (limited to 'test/web/chat_channel_test.exs')
-rw-r--r-- | test/web/chat_channel_test.exs | 37 |
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 |