logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma

user_representer_test.exs (1223B)


      1 # Pleroma: A lightweight social networking server
      2 # Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
      3 # SPDX-License-Identifier: AGPL-3.0-only
      4 
      5 defmodule Pleroma.Web.OStatus.UserRepresenterTest do
      6   use Pleroma.DataCase
      7   alias Pleroma.Web.OStatus.UserRepresenter
      8 
      9   import Pleroma.Factory
     10   alias Pleroma.User
     11 
     12   test "returns a user with id, uri, name and link" do
     13     user = insert(:user, %{nickname: "レイン"})
     14     tuple = UserRepresenter.to_simple_form(user)
     15 
     16     res = :xmerl.export_simple_content(tuple, :xmerl_xml) |> to_string
     17 
     18     expected = """
     19     <id>#{user.ap_id}</id>
     20     <activity:object>http://activitystrea.ms/schema/1.0/person</activity:object>
     21     <uri>#{user.ap_id}</uri>
     22     <poco:preferredUsername>#{user.nickname}</poco:preferredUsername>
     23     <poco:displayName>#{user.name}</poco:displayName>
     24     <poco:note>#{user.bio}</poco:note>
     25     <summary>#{user.bio}</summary>
     26     <name>#{user.nickname}</name>
     27     <link rel="avatar" href="#{User.avatar_url(user)}" />
     28     <link rel="header" href="#{User.banner_url(user)}" />
     29     <ap_enabled>true</ap_enabled>
     30     """
     31 
     32     assert clean(res) == clean(expected)
     33   end
     34 
     35   defp clean(string) do
     36     String.replace(string, ~r/\s/, "")
     37   end
     38 end