summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMaxim Filippov <colixer@gmail.com>2019-01-01 23:26:40 +0300
committerMaxim Filippov <colixer@gmail.com>2019-01-01 23:26:40 +0300
commit2aab4e03c3a2867abd4555dc776eebc8b0dba176 (patch)
treeddb3d4deda02ccae95c8177e3b0edebe966df896 /test
parent32bed664714c616d4a75579b450e52dcff5d8134 (diff)
downloadpleroma-2aab4e03c3a2867abd4555dc776eebc8b0dba176.tar.gz
pleroma-2aab4e03c3a2867abd4555dc776eebc8b0dba176.zip
Add OGP parser
Diffstat (limited to 'test')
-rw-r--r--test/fixtures/rich_media/ogp.html9
-rw-r--r--test/web/rich_media/parser_test.exs26
2 files changed, 35 insertions, 0 deletions
diff --git a/test/fixtures/rich_media/ogp.html b/test/fixtures/rich_media/ogp.html
new file mode 100644
index 000000000..c886b5871
--- /dev/null
+++ b/test/fixtures/rich_media/ogp.html
@@ -0,0 +1,9 @@
+<html prefix="og: http://ogp.me/ns#">
+ <head>
+ <title>The Rock (1996)</title>
+ <meta property="og:title" content="The Rock" />
+ <meta property="og:type" content="video.movie" />
+ <meta property="og:url" content="http://www.imdb.com/title/tt0117500/" />
+ <meta property="og:image" content="http://ia.media-imdb.com/images/rock.jpg" />
+ </head>
+</html>
diff --git a/test/web/rich_media/parser_test.exs b/test/web/rich_media/parser_test.exs
new file mode 100644
index 000000000..bb0d663e9
--- /dev/null
+++ b/test/web/rich_media/parser_test.exs
@@ -0,0 +1,26 @@
+defmodule Pleroma.Web.RichMedia.ParserTest do
+ use ExUnit.Case, async: true
+
+ setup do
+ Tesla.Mock.mock(fn
+ %{
+ method: :get,
+ url: "http://example.com/ogp"
+ } ->
+ %Tesla.Env{status: 200, body: File.read!("test/fixtures/rich_media/ogp.html")}
+ end)
+
+ :ok
+ end
+
+ test "parses ogp" do
+ assert Pleroma.Web.RichMedia.Parser.parse("http://example.com/ogp") ==
+ %Pleroma.Web.RichMedia.Data{
+ description: nil,
+ image: "http://ia.media-imdb.com/images/rock.jpg",
+ title: "The Rock",
+ type: "video.movie",
+ url: "http://www.imdb.com/title/tt0117500/"
+ }
+ end
+end