logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://anongit.hacktivis.me/git/pleroma.git/

shout_channel_test.exs (1244B)


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