X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;ds=sidebyside;f=test%2Fpleroma%2Fweb%2Fcommon_api%2Futils_test.exs;h=a88d7681afa82f62724ef034e8c7286d2540b75a;hb=62e179f446ac7bfada965fac47e9613ce60091b4;hp=b0e567ff0b250acf99905623d62847414cc50758;hpb=0de6716f066ca1822967a612a51c25f96aeb60b1;p=akkoma diff --git a/test/pleroma/web/common_api/utils_test.exs b/test/pleroma/web/common_api/utils_test.exs index b0e567ff0..a88d7681a 100644 --- a/test/pleroma/web/common_api/utils_test.exs +++ b/test/pleroma/web/common_api/utils_test.exs @@ -4,7 +4,6 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do alias Pleroma.Builders.UserBuilder - alias Pleroma.Object alias Pleroma.Web.CommonAPI alias Pleroma.Web.CommonAPI.ActivityDraft alias Pleroma.Web.CommonAPI.Utils @@ -160,11 +159,7 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do {output, _, _} = Utils.format_input(text, "text/markdown") assert output == - ~s(

hello world

another @user__test and @user__test google.com paragraph

) + ~s(

hello world

another @user__test and @user__test google.com paragraph

) end end @@ -201,11 +196,7 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do {result, _, []} = Utils.format_input(code, "text/markdown") assert result == - ~s[

@mario @luigi yo what’s up?

] + ~s[

@mario @luigi yo what’s up?

] end test "remote mentions" do @@ -216,11 +207,7 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do {result, _, []} = Utils.format_input(code, "text/markdown") assert result == - ~s[

@mario @luigi yo what’s up?

] + ~s[

@mario @luigi yo what’s up?

] end test "raw HTML" do @@ -285,22 +272,6 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do end end - describe "context_to_conversation_id" do - test "creates a mapping object" do - conversation_id = Utils.context_to_conversation_id("random context") - object = Object.get_by_ap_id("random context") - - assert conversation_id == object.id - end - - test "returns an existing mapping for an existing object" do - {:ok, object} = Object.context_mapping("random context") |> Repo.insert() - conversation_id = Utils.context_to_conversation_id("random context") - - assert conversation_id == object.id - end - end - describe "formats date to asctime" do test "when date is in ISO 8601 format" do date = DateTime.utc_now() |> DateTime.to_iso8601() @@ -321,7 +292,7 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do assert capture_log(fn -> assert Utils.date_to_asctime(date) == expected - end) =~ "[warn] Date #{date} in wrong format, must be ISO 8601" + end) =~ "[warning] Date #{date} in wrong format, must be ISO 8601" end test "when date is a Unix timestamp" do @@ -331,7 +302,7 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do assert capture_log(fn -> assert Utils.date_to_asctime(date) == expected - end) =~ "[warn] Date #{date} in wrong format, must be ISO 8601" + end) =~ "[warning] Date #{date} in wrong format, must be ISO 8601" end test "when date is nil" do @@ -339,13 +310,13 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do assert capture_log(fn -> assert Utils.date_to_asctime(nil) == expected - end) =~ "[warn] Date in wrong format, must be ISO 8601" + end) =~ "[warning] Date in wrong format, must be ISO 8601" end test "when date is a random string" do assert capture_log(fn -> assert Utils.date_to_asctime("foo") == "" - end) =~ "[warn] Date foo in wrong format, must be ISO 8601" + end) =~ "[warning] Date foo in wrong format, must be ISO 8601" end end @@ -529,17 +500,6 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do end end - describe "conversation_id_to_context/1" do - test "returns id" do - object = insert(:note) - assert Utils.conversation_id_to_context(object.id) == object.data["id"] - end - - test "returns error if object not found" do - assert Utils.conversation_id_to_context("123") == {:error, "No such conversation"} - end - end - describe "maybe_notify_mentioned_recipients/2" do test "returns recipients when activity is not `Create`" do activity = insert(:like_activity) @@ -681,41 +641,6 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do end end - describe "make_note_data/1" do - test "returns note data" do - user = insert(:user) - note = insert(:note) - user2 = insert(:user) - user3 = insert(:user) - - draft = %ActivityDraft{ - user: user, - to: [user2.ap_id], - context: "2hu", - content_html: "

This is :moominmamma: note

", - in_reply_to: note.id, - tags: [name: "jimm"], - summary: "test summary", - cc: [user3.ap_id], - extra: %{"custom_tag" => "test"} - } - - assert Utils.make_note_data(draft) == %{ - "actor" => user.ap_id, - "attachment" => [], - "cc" => [user3.ap_id], - "content" => "

This is :moominmamma: note

", - "context" => "2hu", - "sensitive" => false, - "summary" => "test summary", - "tag" => ["jimm"], - "to" => [user2.ap_id], - "type" => "Note", - "custom_tag" => "test" - } - end - end - describe "maybe_add_attachments/3" do test "returns parsed results when attachment_links is false" do assert Utils.maybe_add_attachments(