chat_message_reference_test.exs (852B)
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 5 defmodule Pleroma.ChatMessageReferenceTest do 6 use Pleroma.DataCase, async: true 7 8 alias Pleroma.Chat 9 alias Pleroma.ChatMessageReference 10 alias Pleroma.Web.CommonAPI 11 12 import Pleroma.Factory 13 14 describe "messages" do 15 test "it returns the last message in a chat" do 16 user = insert(:user) 17 recipient = insert(:user) 18 19 {:ok, _message_1} = CommonAPI.post_chat_message(user, recipient, "hey") 20 {:ok, _message_2} = CommonAPI.post_chat_message(recipient, user, "ho") 21 22 {:ok, chat} = Chat.get_or_create(user.id, recipient.ap_id) 23 24 message = ChatMessageReference.last_message_for_chat(chat) 25 26 assert message.object.data["content"] == "ho" 27 end 28 end 29 end