1 defmodule Pleroma.Web.ChatChannelTest do
2 use Pleroma.Web.ChannelCase
3 alias Pleroma.Web.ChatChannel
4 alias Pleroma.Web.UserSocket
12 socket(UserSocket, "", %{user_name: user.nickname})
13 |> subscribe_and_join(ChatChannel, "chat:public")
18 test "it broadcasts a message", %{socket: socket} do
19 push(socket, "new_msg", %{"text" => "why is tenshi eating a corndog so cute?"})
20 assert_broadcast("new_msg", %{text: "why is tenshi eating a corndog so cute?"})
23 describe "message lengths" do
24 setup do: clear_config([:instance, :chat_limit])
26 test "it ignores messages of length zero", %{socket: socket} do
27 push(socket, "new_msg", %{"text" => ""})
28 refute_broadcast("new_msg", %{text: ""})
31 test "it ignores messages above a certain length", %{socket: socket} do
32 Pleroma.Config.put([:instance, :chat_limit], 2)
33 push(socket, "new_msg", %{"text" => "123"})
34 refute_broadcast("new_msg", %{text: "123"})