logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma

message_reference_test.exs (850B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Chat.MessageReferenceTest do
  5. use Pleroma.DataCase, async: true
  6. alias Pleroma.Chat
  7. alias Pleroma.Chat.MessageReference
  8. alias Pleroma.Web.CommonAPI
  9. import Pleroma.Factory
  10. describe "messages" do
  11. test "it returns the last message in a chat" do
  12. user = insert(:user)
  13. recipient = insert(:user)
  14. {:ok, _message_1} = CommonAPI.post_chat_message(user, recipient, "hey")
  15. {:ok, _message_2} = CommonAPI.post_chat_message(recipient, user, "ho")
  16. {:ok, chat} = Chat.get_or_create(user.id, recipient.ap_id)
  17. message = MessageReference.last_message_for_chat(chat)
  18. assert message.object.data["content"] == "ho"
  19. end
  20. end
  21. end