[Pleroma.Web.TwitterAPI.UserViewTest]: Add test for mastodon-fields
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Fri, 28 Sep 2018 09:17:33 +0000 (11:17 +0200)
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Fri, 28 Sep 2018 09:17:33 +0000 (11:17 +0200)
test/web/twitter_api/views/user_view_test.exs

index 383d7d34cf864fdbf14e5e0dfa38d0a9233c887f..2deb22fb14c9dc942f37b3a92efa406ad3b7cb65 100644 (file)
@@ -227,4 +227,30 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest 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