test: add some regression tests for the rich media card rendering
authorWilliam Pitcock <nenolod@dereferenced.org>
Wed, 6 Feb 2019 18:12:26 +0000 (18:12 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Wed, 6 Feb 2019 18:12:26 +0000 (18:12 +0000)
test/web/mastodon_api/status_view_test.exs

index c6a5783c6a4cae3e983c5e885a19927c48ebf2be..f0c4468cf04ecbcd737ee35cc1f02f10e9d31745 100644 (file)
@@ -235,4 +235,44 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
              ]
     end
   end
+
+  describe "rich media cards" do
+    test "a rich media card without a site name renders correctly" do
+      page_url = "http://example.com"
+
+      card = %{
+        url: page_url,
+        image: page_url <> "/example.jpg",
+        title: "Example website"
+      }
+
+      %{provider_name: "example.com"} =
+        StatusView.render("card.json", %{page_url: page_url, rich_media: card})
+    end
+
+    test "a rich media card without a site name or image renders correctly" do
+      page_url = "http://example.com"
+
+      card = %{
+        url: page_url,
+        title: "Example website"
+      }
+
+      %{provider_name: "example.com"} =
+        StatusView.render("card.json", %{page_url: page_url, rich_media: card})
+    end
+
+    test "a rich media card without an image renders correctly" do
+      page_url = "http://example.com"
+
+      card = %{
+        url: page_url,
+        site_name: "Example site name",
+        title: "Example website"
+      }
+
+      %{provider_name: "Example site name"} =
+        StatusView.render("card.json", %{page_url: page_url, rich_media: card})
+    end
+  end
 end