Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.6KB

  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Web.RelMeTest do
  5. use ExUnit.Case, async: true
  6. setup_all do
  7. Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
  8. :ok
  9. end
  10. test "parse/1" do
  11. hrefs = ["https://social.example.org/users/lain"]
  12. assert Pleroma.Web.RelMe.parse("http://example.com/rel_me/null") == {:ok, []}
  13. assert {:error, _} = Pleroma.Web.RelMe.parse("http://example.com/rel_me/error")
  14. assert Pleroma.Web.RelMe.parse("http://example.com/rel_me/link") == {:ok, hrefs}
  15. assert Pleroma.Web.RelMe.parse("http://example.com/rel_me/anchor") == {:ok, hrefs}
  16. assert Pleroma.Web.RelMe.parse("http://example.com/rel_me/anchor_nofollow") == {:ok, hrefs}
  17. end
  18. test "maybe_put_rel_me/2" do
  19. profile_urls = ["https://social.example.org/users/lain"]
  20. attr = "me"
  21. fallback = nil
  22. assert Pleroma.Web.RelMe.maybe_put_rel_me("http://example.com/rel_me/null", profile_urls) ==
  23. fallback
  24. assert Pleroma.Web.RelMe.maybe_put_rel_me("http://example.com/rel_me/error", profile_urls) ==
  25. fallback
  26. assert Pleroma.Web.RelMe.maybe_put_rel_me("http://example.com/rel_me/anchor", profile_urls) ==
  27. attr
  28. assert Pleroma.Web.RelMe.maybe_put_rel_me(
  29. "http://example.com/rel_me/anchor_nofollow",
  30. profile_urls
  31. ) == attr
  32. assert Pleroma.Web.RelMe.maybe_put_rel_me("http://example.com/rel_me/link", profile_urls) ==
  33. attr
  34. end
  35. end