mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-27 08:16:16 +00:00
30 lines
851 B
Elixir
30 lines
851 B
Elixir
|
# Pleroma: A lightweight social networking server
|
||
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||
|
|
||
|
defmodule Pleroma.ChatMessageReferencTest do
|
||
|
use Pleroma.DataCase, async: true
|
||
|
|
||
|
alias Pleroma.Chat
|
||
|
alias Pleroma.ChatMessageReference
|
||
|
alias Pleroma.Web.CommonAPI
|
||
|
|
||
|
import Pleroma.Factory
|
||
|
|
||
|
describe "messages" do
|
||
|
test "it returns the last message in a chat" do
|
||
|
user = insert(:user)
|
||
|
recipient = insert(:user)
|
||
|
|
||
|
{:ok, _message_1} = CommonAPI.post_chat_message(user, recipient, "hey")
|
||
|
{:ok, _message_2} = CommonAPI.post_chat_message(recipient, user, "ho")
|
||
|
|
||
|
{:ok, chat} = Chat.get_or_create(user.id, recipient.ap_id)
|
||
|
|
||
|
message = ChatMessageReference.last_message_for_chat(chat)
|
||
|
|
||
|
assert message.object.data["content"] == "ho"
|
||
|
end
|
||
|
end
|
||
|
end
|