OStatus: Add user bio as summary field
[akkoma] / test / web / ostatus / user_representer_test.exs
1 defmodule Pleroma.Web.OStatus.UserRepresenterTest do
2 use Pleroma.DataCase
3 alias Pleroma.Web.OStatus.UserRepresenter
4
5 import Pleroma.Factory
6 alias Pleroma.User
7
8 test "returns a user with id, uri, name and link" do
9 user = build(:user, nickname: "レイン")
10 tuple = UserRepresenter.to_simple_form(user)
11
12 res = :xmerl.export_simple_content(tuple, :xmerl_xml) |> to_string
13
14 expected = """
15 <id>#{user.ap_id}</id>
16 <activity:object>http://activitystrea.ms/schema/1.0/person</activity:object>
17 <uri>#{user.ap_id}</uri>
18 <poco:preferredUsername>#{user.nickname}</poco:preferredUsername>
19 <poco:displayName>#{user.name}</poco:displayName>
20 <poco:note>#{user.bio}</poco:note>
21 <summary>#{user.bio}</summary>
22 <name>#{user.nickname}</name>
23 <link rel="avatar" href="#{User.avatar_url(user)}" />
24 """
25
26 assert clean(res) == clean(expected)
27 end
28
29 defp clean(string) do
30 String.replace(string, ~r/\s/, "")
31 end
32 end