d40455c89d279e50f69a0adb917ffded55767e44
[akkoma] / test / web / twitter_api / representers / activity_representer_test.exs
1 defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
2 use Pleroma.DataCase
3 alias Pleroma.{User, Activity}
4 alias Pleroma.Web.TwitterAPI.Representers.{UserRepresenter, ActivityRepresenter}
5 alias Pleroma.Builders.UserBuilder
6
7 test "an activity" do
8 {:ok, user} = UserBuilder.insert
9 {:ok, follower} = UserBuilder.insert(%{following: [User.ap_followers(user)]})
10
11 content = "Some content"
12 date = DateTime.utc_now() |> DateTime.to_iso8601
13
14 activity = %Activity{
15 id: 1,
16 data: %{
17 "type" => "Create",
18 "to" => [
19 User.ap_followers(user),
20 "https://www.w3.org/ns/activitystreams#Public"
21 ],
22 "actor" => User.ap_id(user),
23 "object" => %{
24 "published" => date,
25 "type" => "Note",
26 "content" => content
27 },
28 "published" => date
29 }
30 }
31
32
33 expected_status = %{
34 "id" => activity.id,
35 "user" => UserRepresenter.to_map(user, %{for: follower}),
36 "is_local" => true,
37 "attentions" => [],
38 "statusnet_html" => content,
39 "text" => content,
40 "is_post_verb" => true,
41 "created_at" => date
42 }
43
44 assert ActivityRepresenter.to_map(activity, %{user: user, for: follower}) == expected_status
45 end
46 end