1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.RelMeTest do
6 use ExUnit.Case, async: true
12 url: "http://example.com/rel_me/anchor"
14 %Tesla.Env{status: 200, body: File.read!("test/fixtures/rel_me_anchor.html")}
18 url: "http://example.com/rel_me/anchor_nofollow"
20 %Tesla.Env{status: 200, body: File.read!("test/fixtures/rel_me_anchor_nofollow.html")}
24 url: "http://example.com/rel_me/link"
26 %Tesla.Env{status: 200, body: File.read!("test/fixtures/rel_me_link.html")}
30 url: "http://example.com/rel_me/null"
32 %Tesla.Env{status: 200, body: File.read!("test/fixtures/rel_me_null.html")}
39 hrefs = ["https://social.example.org/users/lain"]
41 assert Pleroma.Web.RelMe.parse("http://example.com/rel_me/null") == {:ok, []}
42 assert {:error, _} = Pleroma.Web.RelMe.parse("http://example.com/rel_me/error")
44 assert Pleroma.Web.RelMe.parse("http://example.com/rel_me/link") == {:ok, hrefs}
45 assert Pleroma.Web.RelMe.parse("http://example.com/rel_me/anchor") == {:ok, hrefs}
46 assert Pleroma.Web.RelMe.parse("http://example.com/rel_me/anchor_nofollow") == {:ok, hrefs}
49 test "maybe_put_rel_me/2" do
50 profile_urls = ["https://social.example.org/users/lain"]
54 assert Pleroma.Web.RelMe.maybe_put_rel_me("http://example.com/rel_me/null", profile_urls) ==
57 assert Pleroma.Web.RelMe.maybe_put_rel_me("http://example.com/rel_me/error", profile_urls) ==
60 assert Pleroma.Web.RelMe.maybe_put_rel_me("http://example.com/rel_me/anchor", profile_urls) ==
63 assert Pleroma.Web.RelMe.maybe_put_rel_me(
64 "http://example.com/rel_me/anchor_nofollow",
68 assert Pleroma.Web.RelMe.maybe_put_rel_me("http://example.com/rel_me/link", profile_urls) ==