X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fweb%2Fmastodon_api%2Fstatus_view_test.exs;h=0dc9c538cb5b255cfa624e315feabda0c2a1db42;hb=833161b5d21f85e2276cd0cee3e148ecbe6e1f05;hp=f957fedac6bd8d1e6bbdd039dc0d8dd1f515a42c;hpb=364cf5369b711e15b9ec60c768dadc280969a962;p=akkoma diff --git a/test/web/mastodon_api/status_view_test.exs b/test/web/mastodon_api/status_view_test.exs index f957fedac..0dc9c538c 100644 --- a/test/web/mastodon_api/status_view_test.exs +++ b/test/web/mastodon_api/status_view_test.exs @@ -5,7 +5,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do use Pleroma.DataCase - alias Pleroma.Web.MastodonAPI.{StatusView, AccountView} + alias Pleroma.Web.MastodonAPI.AccountView + alias Pleroma.Web.MastodonAPI.StatusView alias Pleroma.User alias Pleroma.Web.OStatus alias Pleroma.Web.CommonAPI @@ -92,6 +93,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do replies_count: 0, favourites_count: 0, reblogged: false, + bookmarked: false, favourited: false, muted: false, pinned: false, @@ -234,4 +236,59 @@ 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 + + test "a rich media card with all relevant data renders correctly" do + page_url = "http://example.com" + + card = %{ + url: page_url, + site_name: "Example site name", + title: "Example website", + image: page_url <> "/example.jpg", + description: "Example description" + } + + %{provider_name: "Example site name"} = + StatusView.render("card.json", %{page_url: page_url, rich_media: card}) + end + end end