diff options
| author | link0ff <juri@linkov.net> | 2019-03-03 18:29:37 +0200 |
|---|---|---|
| committer | link0ff <juri@linkov.net> | 2019-03-03 18:29:37 +0200 |
| commit | 19e2b852473ea4d371fb3d77e9344025e0499428 (patch) | |
| tree | dcd43e823f7687767651e6eb0877b5b4aca53882 /test/web/rel_me_test.exs | |
| parent | e278d470232f4e8081bbbe358137400074673e75 (diff) | |
| parent | ace4231628ad1af08c8696fb7fe6983549f62631 (diff) | |
| download | pleroma-19e2b852473ea4d371fb3d77e9344025e0499428.tar.gz pleroma-19e2b852473ea4d371fb3d77e9344025e0499428.zip | |
Merge remote-tracking branch 'upstream/develop' into feature/openldap-support
Diffstat (limited to 'test/web/rel_me_test.exs')
| -rw-r--r-- | test/web/rel_me_test.exs | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/test/web/rel_me_test.exs b/test/web/rel_me_test.exs new file mode 100644 index 000000000..ba8038e69 --- /dev/null +++ b/test/web/rel_me_test.exs @@ -0,0 +1,55 @@ +defmodule Pleroma.Web.RelMeTest do + use ExUnit.Case, async: true + + setup do + Tesla.Mock.mock(fn + %{ + method: :get, + url: "http://example.com/rel_me/anchor" + } -> + %Tesla.Env{status: 200, body: File.read!("test/fixtures/rel_me_anchor.html")} + + %{ + method: :get, + url: "http://example.com/rel_me/link" + } -> + %Tesla.Env{status: 200, body: File.read!("test/fixtures/rel_me_link.html")} + + %{ + method: :get, + url: "http://example.com/rel_me/null" + } -> + %Tesla.Env{status: 200, body: File.read!("test/fixtures/rel_me_null.html")} + end) + + :ok + end + + test "parse/1" do + hrefs = ["https://social.example.org/users/lain"] + + assert Pleroma.Web.RelMe.parse("http://example.com/rel_me/null") == {:ok, []} + assert {:error, _} = Pleroma.Web.RelMe.parse("http://example.com/rel_me/error") + + assert Pleroma.Web.RelMe.parse("http://example.com/rel_me/link") == {:ok, hrefs} + assert Pleroma.Web.RelMe.parse("http://example.com/rel_me/anchor") == {:ok, hrefs} + end + + test "maybe_put_rel_me/2" do + profile_urls = ["https://social.example.org/users/lain"] + attr = "me" + fallback = nil + + assert Pleroma.Web.RelMe.maybe_put_rel_me("http://example.com/rel_me/null", profile_urls) == + fallback + + assert Pleroma.Web.RelMe.maybe_put_rel_me("http://example.com/rel_me/error", profile_urls) == + fallback + + assert Pleroma.Web.RelMe.maybe_put_rel_me("http://example.com/rel_me/anchor", profile_urls) == + attr + + assert Pleroma.Web.RelMe.maybe_put_rel_me("http://example.com/rel_me/link", profile_urls) == + attr + end +end |
