Transmogrifier: test fix_attachments/1
authorAlex Gleason <alex@alexgleason.me>
Tue, 7 Dec 2021 06:10:47 +0000 (01:10 -0500)
committerAlex Gleason <alex@alexgleason.me>
Tue, 7 Dec 2021 06:10:47 +0000 (01:10 -0500)
test/pleroma/web/activity_pub/transmogrifier_test.exs

index 5a3b57acb84d1923ac2d950f1c022105a93d2ffb..4616f8090b1a0353d662568fa2ebf4b94af5cba5 100644 (file)
@@ -524,4 +524,44 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
                )
     end
   end
+
+  describe "fix_attachments/1" do
+    test "transforms dimensions into a url" do
+      object = %{
+        "attachment" => [
+          %{
+            "type" => "Document",
+            "name" => "Hello world",
+            "url" => "https://media.example.tld/1.jpg",
+            "width" => 880,
+            "height" => 960,
+            "mediaType" => "image/jpeg",
+            "blurhash" => "eTKL26+HDjcEIBVl;ds+K6t301W.t7nit7y1E,R:v}ai4nXSt7V@of"
+          }
+        ]
+      }
+
+      expected = %{
+        "attachment" => [
+          %{
+            "type" => "Document",
+            "name" => "Hello world",
+            "url" => [
+              %{
+                "type" => "Link",
+                "mediaType" => "image/jpeg",
+                "href" => "https://media.example.tld/1.jpg",
+                "width" => 880,
+                "height" => 960
+              }
+            ],
+            "mediaType" => "image/jpeg",
+            "blurhash" => "eTKL26+HDjcEIBVl;ds+K6t301W.t7nit7y1E,R:v}ai4nXSt7V@of"
+          }
+        ]
+      }
+
+      assert Transmogrifier.fix_attachments(object) == expected
+    end
+  end
 end