logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

rel_me_test.exs (1645B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Web.RelMeTest do
  5. use Pleroma.DataCase
  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 {:ok, %Tesla.Env{status: 404}} =
  14. Pleroma.Web.RelMe.parse("http://example.com/rel_me/error")
  15. assert Pleroma.Web.RelMe.parse("http://example.com/rel_me/link") == {:ok, hrefs}
  16. assert Pleroma.Web.RelMe.parse("http://example.com/rel_me/anchor") == {:ok, hrefs}
  17. assert Pleroma.Web.RelMe.parse("http://example.com/rel_me/anchor_nofollow") == {:ok, hrefs}
  18. end
  19. test "maybe_put_rel_me/2" do
  20. profile_urls = ["https://social.example.org/users/lain"]
  21. attr = "me"
  22. fallback = nil
  23. assert Pleroma.Web.RelMe.maybe_put_rel_me("http://example.com/rel_me/null", profile_urls) ==
  24. fallback
  25. assert Pleroma.Web.RelMe.maybe_put_rel_me("http://example.com/rel_me/error", profile_urls) ==
  26. fallback
  27. assert Pleroma.Web.RelMe.maybe_put_rel_me("http://example.com/rel_me/anchor", profile_urls) ==
  28. attr
  29. assert Pleroma.Web.RelMe.maybe_put_rel_me(
  30. "http://example.com/rel_me/anchor_nofollow",
  31. profile_urls
  32. ) == attr
  33. assert Pleroma.Web.RelMe.maybe_put_rel_me("http://example.com/rel_me/link", profile_urls) ==
  34. attr
  35. end
  36. end