From a74daabfae5ed149942b5afc64982d3e2ca95b11 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Fri, 28 Sep 2018 11:17:33 +0200 Subject: [PATCH] [Pleroma.Web.TwitterAPI.UserViewTest]: Add test for mastodon-fields --- test/web/twitter_api/views/user_view_test.exs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/web/twitter_api/views/user_view_test.exs b/test/web/twitter_api/views/user_view_test.exs index 383d7d34c..2deb22fb1 100644 --- a/test/web/twitter_api/views/user_view_test.exs +++ b/test/web/twitter_api/views/user_view_test.exs @@ -227,4 +227,30 @@ test "A blocked user for the blocker" do blocker = Repo.get(User, blocker.id) assert represented == UserView.render("show.json", %{user: user, for: blocker}) end + + test "a user with mastodon fields" do + fields = [ + %{ + "name" => "Pronouns", + "value" => "she/her" + }, + %{ + "name" => "Website", + "value" => "https://example.org/" + } + ] + + user = + insert(:user, %{ + info: %{ + "source_data" => %{ + "attachment" => + Enum.map(fields, fn field -> Map.put(field, "type", "PropertyValue") end) + } + } + }) + + userview = UserView.render("show.json", %{user: user}) + assert userview["fields"] == fields + end end