Remove Twemoji stuff from MastoFE
[akkoma] / test / pleroma / web / shout_channel_test.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.ShoutChannelTest do
6 use Pleroma.Web.ChannelCase
7 alias Pleroma.Web.ShoutChannel
8 alias Pleroma.Web.UserSocket
9
10 import Pleroma.Factory
11
12 setup do
13 user = insert(:user)
14
15 {:ok, _, socket} =
16 socket(UserSocket, "", %{user_name: user.nickname})
17 |> subscribe_and_join(ShoutChannel, "shout:public")
18
19 {:ok, socket: socket}
20 end
21
22 test "it broadcasts a message", %{socket: socket} do
23 push(socket, "new_msg", %{"text" => "why is tenshi eating a corndog so cute?"})
24 assert_broadcast("new_msg", %{text: "why is tenshi eating a corndog so cute?"})
25 end
26
27 describe "message lengths" do
28 setup do: clear_config([:shout, :limit])
29
30 test "it ignores messages of length zero", %{socket: socket} do
31 push(socket, "new_msg", %{"text" => ""})
32 refute_broadcast("new_msg", %{text: ""})
33 end
34
35 test "it ignores messages above a certain length", %{socket: socket} do
36 clear_config([:shout, :limit], 2)
37 push(socket, "new_msg", %{"text" => "123"})
38 refute_broadcast("new_msg", %{text: "123"})
39 end
40 end
41 end