fix case when tags is invalid
[akkoma] / test / web / mastodon_api / status_view_test.exs
index d10d59d6c75cdbb6ee0d501135372c6d103ee952..b7ac92760a35a6f23c9c9e1fd80a71e32ee795e1 100644 (file)
@@ -62,7 +62,12 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
       visibility: "public",
       media_attachments: [],
       mentions: [],
-      tags: note.data["object"]["tag"],
+      tags: [
+        %{
+          name: "#{note.data["object"]["tag"]}",
+          url: "/tag/#{note.data["object"]["tag"]}"
+        }
+      ],
       application: %{
         name: "Web",
         website: nil
@@ -151,4 +156,25 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
     assert represented[:reblog][:id] == to_string(activity.id)
     assert represented[:emojis] == []
   end
+
+  describe "build_tags/1" do
+    test "it returns a a dictionary tags" do
+      object_tags = [
+        "fediverse",
+        "mastodon",
+        "nextcloud",
+        %{
+          "href" => "https://kawen.space/users/lain",
+          "name" => "@lain@kawen.space",
+          "type" => "Mention"
+        }
+      ]
+
+      assert StatusView.build_tags(object_tags) == [
+               %{name: "fediverse", url: "/tag/fediverse"},
+               %{name: "mastodon", url: "/tag/mastodon"},
+               %{name: "nextcloud", url: "/tag/nextcloud"}
+             ]
+    end
+  end
 end