Add status text to notifications (mentions and reposts)
[akkoma] / test / web / push / push_test.exs
1 defmodule Pleroma.Web.PushTest do
2 use Pleroma.DataCase
3
4 alias Pleroma.Web.Push
5
6 import Pleroma.Factory
7
8 test "renders body for create activity" do
9 assert Push.format_body(
10 %{
11 activity: %{
12 data: %{
13 "type" => "Create",
14 "object" => %{
15 "content" =>
16 "<span>Lorem ipsum dolor sit amet</span>, consectetur :bear: adipiscing elit. Fusce sagittis finibus turpis."
17 }
18 }
19 }
20 },
21 %{nickname: "Bob"}
22 ) ==
23 "@Bob: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce sagittis fini..."
24 end
25
26 test "renders body for follow activity" do
27 assert Push.format_body(%{activity: %{data: %{"type" => "Follow"}}}, %{nickname: "Bob"}) ==
28 "@Bob has followed you"
29 end
30
31 test "renders body for announce activity" do
32 user = insert(:user)
33
34 note =
35 insert(:note, %{
36 data: %{
37 "content" =>
38 "<span>Lorem ipsum dolor sit amet</span>, consectetur :bear: adipiscing elit. Fusce sagittis finibus turpis."
39 }
40 })
41
42 note_activity = insert(:note_activity, %{note: note})
43 announce_activity = insert(:announce_activity, %{user: user, note_activity: note_activity})
44
45 assert Push.format_body(%{activity: announce_activity}, user) ==
46 "@#{user.nickname} repeated: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce sagittis fini..."
47 end
48
49 test "renders body for like activity" do
50 assert Push.format_body(%{activity: %{data: %{"type" => "Like"}}}, %{nickname: "Bob"}) ==
51 "@Bob has favorited your post"
52 end
53 end