Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.1KB

  1. defmodule Pleroma.Web.ChatChannelTest do
  2. use Pleroma.Web.ChannelCase
  3. alias Pleroma.Web.ChatChannel
  4. alias Pleroma.Web.UserSocket
  5. import Pleroma.Factory
  6. setup do
  7. user = insert(:user)
  8. {:ok, _, socket} =
  9. socket(UserSocket, "", %{user_name: user.nickname})
  10. |> subscribe_and_join(ChatChannel, "chat:public")
  11. {:ok, socket: socket}
  12. end
  13. test "it broadcasts a message", %{socket: socket} do
  14. push(socket, "new_msg", %{"text" => "why is tenshi eating a corndog so cute?"})
  15. assert_broadcast("new_msg", %{text: "why is tenshi eating a corndog so cute?"})
  16. end
  17. describe "message lengths" do
  18. setup do: clear_config([:instance, :chat_limit])
  19. test "it ignores messages of length zero", %{socket: socket} do
  20. push(socket, "new_msg", %{"text" => ""})
  21. refute_broadcast("new_msg", %{text: ""})
  22. end
  23. test "it ignores messages above a certain length", %{socket: socket} do
  24. Pleroma.Config.put([:instance, :chat_limit], 2)
  25. push(socket, "new_msg", %{"text" => "123"})
  26. refute_broadcast("new_msg", %{text: "123"})
  27. end
  28. end
  29. end