aboutsummaryrefslogtreecommitdiff
path: root/test/web/rich_media
diff options
context:
space:
mode:
Diffstat (limited to 'test/web/rich_media')
-rw-r--r--test/web/rich_media/parser_test.exs75
-rw-r--r--test/web/rich_media/parsers/twitter_card_test.exs60
2 files changed, 68 insertions, 67 deletions
diff --git a/test/web/rich_media/parser_test.exs b/test/web/rich_media/parser_test.exs
index e54a13bc8..420a612c6 100644
--- a/test/web/rich_media/parser_test.exs
+++ b/test/web/rich_media/parser_test.exs
@@ -60,19 +60,19 @@ defmodule Pleroma.Web.RichMedia.ParserTest do
test "doesn't just add a title" do
assert Pleroma.Web.RichMedia.Parser.parse("http://example.com/non-ogp") ==
{:error,
- "Found metadata was invalid or incomplete: %{url: \"http://example.com/non-ogp\"}"}
+ "Found metadata was invalid or incomplete: %{\"url\" => \"http://example.com/non-ogp\"}"}
end
test "parses ogp" do
assert Pleroma.Web.RichMedia.Parser.parse("http://example.com/ogp") ==
{:ok,
%{
- image: "http://ia.media-imdb.com/images/rock.jpg",
- title: "The Rock",
- description:
+ "image" => "http://ia.media-imdb.com/images/rock.jpg",
+ "title" => "The Rock",
+ "description" =>
"Directed by Michael Bay. With Sean Connery, Nicolas Cage, Ed Harris, John Spencer.",
- type: "video.movie",
- url: "http://example.com/ogp"
+ "type" => "video.movie",
+ "url" => "http://example.com/ogp"
}}
end
@@ -80,12 +80,12 @@ defmodule Pleroma.Web.RichMedia.ParserTest do
assert Pleroma.Web.RichMedia.Parser.parse("http://example.com/ogp-missing-title") ==
{:ok,
%{
- image: "http://ia.media-imdb.com/images/rock.jpg",
- title: "The Rock (1996)",
- description:
+ "image" => "http://ia.media-imdb.com/images/rock.jpg",
+ "title" => "The Rock (1996)",
+ "description" =>
"Directed by Michael Bay. With Sean Connery, Nicolas Cage, Ed Harris, John Spencer.",
- type: "video.movie",
- url: "http://example.com/ogp-missing-title"
+ "type" => "video.movie",
+ "url" => "http://example.com/ogp-missing-title"
}}
end
@@ -93,12 +93,12 @@ defmodule Pleroma.Web.RichMedia.ParserTest do
assert Pleroma.Web.RichMedia.Parser.parse("http://example.com/twitter-card") ==
{:ok,
%{
- card: "summary",
- site: "@flickr",
- image: "https://farm6.staticflickr.com/5510/14338202952_93595258ff_z.jpg",
- title: "Small Island Developing States Photo Submission",
- description: "View the album on Flickr.",
- url: "http://example.com/twitter-card"
+ "card" => "summary",
+ "site" => "@flickr",
+ "image" => "https://farm6.staticflickr.com/5510/14338202952_93595258ff_z.jpg",
+ "title" => "Small Island Developing States Photo Submission",
+ "description" => "View the album on Flickr.",
+ "url" => "http://example.com/twitter-card"
}}
end
@@ -106,27 +106,28 @@ defmodule Pleroma.Web.RichMedia.ParserTest do
assert Pleroma.Web.RichMedia.Parser.parse("http://example.com/oembed") ==
{:ok,
%{
- author_name: "‮‭‬bees‬",
- author_url: "https://www.flickr.com/photos/bees/",
- cache_age: 3600,
- flickr_type: "photo",
- height: "768",
- html:
+ "author_name" => "‮‭‬bees‬",
+ "author_url" => "https://www.flickr.com/photos/bees/",
+ "cache_age" => 3600,
+ "flickr_type" => "photo",
+ "height" => "768",
+ "html" =>
"<a data-flickr-embed=\"true\" href=\"https://www.flickr.com/photos/bees/2362225867/\" title=\"Bacon Lollys by ‮‭‬bees‬, on Flickr\"><img src=\"https://farm4.staticflickr.com/3040/2362225867_4a87ab8baf_b.jpg\" width=\"1024\" height=\"768\" alt=\"Bacon Lollys\"></a><script async src=\"https://embedr.flickr.com/assets/client-code.js\" charset=\"utf-8\"></script>",
- license: "All Rights Reserved",
- license_id: 0,
- provider_name: "Flickr",
- provider_url: "https://www.flickr.com/",
- thumbnail_height: 150,
- thumbnail_url: "https://farm4.staticflickr.com/3040/2362225867_4a87ab8baf_q.jpg",
- thumbnail_width: 150,
- title: "Bacon Lollys",
- type: "photo",
- url: "http://example.com/oembed",
- version: "1.0",
- web_page: "https://www.flickr.com/photos/bees/2362225867/",
- web_page_short_url: "https://flic.kr/p/4AK2sc",
- width: "1024"
+ "license" => "All Rights Reserved",
+ "license_id" => 0,
+ "provider_name" => "Flickr",
+ "provider_url" => "https://www.flickr.com/",
+ "thumbnail_height" => 150,
+ "thumbnail_url" =>
+ "https://farm4.staticflickr.com/3040/2362225867_4a87ab8baf_q.jpg",
+ "thumbnail_width" => 150,
+ "title" => "Bacon Lollys",
+ "type" => "photo",
+ "url" => "http://example.com/oembed",
+ "version" => "1.0",
+ "web_page" => "https://www.flickr.com/photos/bees/2362225867/",
+ "web_page_short_url" => "https://flic.kr/p/4AK2sc",
+ "width" => "1024"
}}
end
diff --git a/test/web/rich_media/parsers/twitter_card_test.exs b/test/web/rich_media/parsers/twitter_card_test.exs
index 87c767c15..847623535 100644
--- a/test/web/rich_media/parsers/twitter_card_test.exs
+++ b/test/web/rich_media/parsers/twitter_card_test.exs
@@ -19,11 +19,11 @@ defmodule Pleroma.Web.RichMedia.Parsers.TwitterCardTest do
assert TwitterCard.parse(html, %{}) ==
{:ok,
%{
- "app:id:googleplay": "com.nytimes.android",
- "app:name:googleplay": "NYTimes",
- "app:url:googleplay": "nytimes://reader/id/100000006583622",
- site: nil,
- title:
+ "app:id:googleplay" => "com.nytimes.android",
+ "app:name:googleplay" => "NYTimes",
+ "app:url:googleplay" => "nytimes://reader/id/100000006583622",
+ "site" => nil,
+ "title" =>
"She Was Arrested at 14. Then Her Photo Went to a Facial Recognition Database. - The New York Times"
}}
end
@@ -36,15 +36,15 @@ defmodule Pleroma.Web.RichMedia.Parsers.TwitterCardTest do
assert TwitterCard.parse(html, %{}) ==
{:ok,
%{
- card: "summary_large_image",
- description:
+ "card" => "summary_large_image",
+ "description" =>
"With little oversight, the N.Y.P.D. has been using powerful surveillance technology on photos of children and teenagers.",
- image:
+ "image" =>
"https://static01.nyt.com/images/2019/08/01/nyregion/01nypd-juveniles-promo/01nypd-juveniles-promo-videoSixteenByNineJumbo1600.jpg",
- "image:alt": "",
- title:
+ "image:alt" => "",
+ "title" =>
"She Was Arrested at 14. Then Her Photo Went to a Facial Recognition Database.",
- url:
+ "url" =>
"https://www.nytimes.com/2019/08/01/nyregion/nypd-facial-recognition-children-teenagers.html"
}}
end
@@ -57,19 +57,19 @@ defmodule Pleroma.Web.RichMedia.Parsers.TwitterCardTest do
assert TwitterCard.parse(html, %{}) ==
{:ok,
%{
- "app:id:googleplay": "com.nytimes.android",
- "app:name:googleplay": "NYTimes",
- "app:url:googleplay": "nytimes://reader/id/100000006583622",
- card: "summary_large_image",
- description:
+ "app:id:googleplay" => "com.nytimes.android",
+ "app:name:googleplay" => "NYTimes",
+ "app:url:googleplay" => "nytimes://reader/id/100000006583622",
+ "card" => "summary_large_image",
+ "description" =>
"With little oversight, the N.Y.P.D. has been using powerful surveillance technology on photos of children and teenagers.",
- image:
+ "image" =>
"https://static01.nyt.com/images/2019/08/01/nyregion/01nypd-juveniles-promo/01nypd-juveniles-promo-videoSixteenByNineJumbo1600.jpg",
- "image:alt": "",
- site: nil,
- title:
+ "image:alt" => "",
+ "site" => nil,
+ "title" =>
"She Was Arrested at 14. Then Her Photo Went to a Facial Recognition Database.",
- url:
+ "url" =>
"https://www.nytimes.com/2019/08/01/nyregion/nypd-facial-recognition-children-teenagers.html"
}}
end
@@ -86,11 +86,11 @@ defmodule Pleroma.Web.RichMedia.Parsers.TwitterCardTest do
assert TwitterCard.parse(html, %{}) ==
{:ok,
%{
- site: "@atlasobscura",
- title:
+ "site" => "@atlasobscura",
+ "title" =>
"The Missing Grave of Margaret Corbin, Revolutionary War Veteran - Atlas Obscura",
- card: "summary_large_image",
- image: image_path
+ "card" => "summary_large_image",
+ "image" => image_path
}}
end
@@ -102,12 +102,12 @@ defmodule Pleroma.Web.RichMedia.Parsers.TwitterCardTest do
assert TwitterCard.parse(html, %{}) ==
{:ok,
%{
- site: nil,
- title:
+ "site" => nil,
+ "title" =>
"She Was Arrested at 14. Then Her Photo Went to a Facial Recognition Database. - The New York Times",
- "app:id:googleplay": "com.nytimes.android",
- "app:name:googleplay": "NYTimes",
- "app:url:googleplay": "nytimes://reader/id/100000006583622"
+ "app:id:googleplay" => "com.nytimes.android",
+ "app:name:googleplay" => "NYTimes",
+ "app:url:googleplay" => "nytimes://reader/id/100000006583622"
}}
end
end