diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/emoji/formatter_test.exs | 24 | ||||
| -rw-r--r-- | test/web/activity_pub/transmogrifier_test.exs | 14 | ||||
| -rw-r--r-- | test/web/activity_pub/views/user_view_test.exs | 2 | ||||
| -rw-r--r-- | test/web/common_api/common_api_test.exs | 12 | ||||
| -rw-r--r-- | test/web/common_api/common_api_utils_test.exs | 23 | ||||
| -rw-r--r-- | test/web/mastodon_api/views/account_view_test.exs | 16 | 
6 files changed, 23 insertions, 68 deletions
| diff --git a/test/emoji/formatter_test.exs b/test/emoji/formatter_test.exs index 3bfee9420..12af6cd8b 100644 --- a/test/emoji/formatter_test.exs +++ b/test/emoji/formatter_test.exs @@ -3,7 +3,6 @@  # SPDX-License-Identifier: AGPL-3.0-only  defmodule Pleroma.Emoji.FormatterTest do -  alias Pleroma.Emoji    alias Pleroma.Emoji.Formatter    use Pleroma.DataCase @@ -32,30 +31,19 @@ defmodule Pleroma.Emoji.FormatterTest do      end    end -  describe "get_emoji" do +  describe "get_emoji_map" do      test "it returns the emoji used in the text" do -      text = "I love :firefox:" - -      assert Formatter.get_emoji(text) == [ -               {"firefox", -                %Emoji{ -                  code: "firefox", -                  file: "/emoji/Firefox.gif", -                  tags: ["Gif", "Fun"], -                  safe_code: "firefox", -                  safe_file: "/emoji/Firefox.gif" -                }} -             ] +      assert Formatter.get_emoji_map("I love :firefox:") == %{ +               "firefox" => "http://localhost:4001/emoji/Firefox.gif" +             }      end      test "it returns a nice empty result when no emojis are present" do -      text = "I love moominamma" -      assert Formatter.get_emoji(text) == [] +      assert Formatter.get_emoji_map("I love moominamma") == %{}      end      test "it doesn't die when text is absent" do -      text = nil -      assert Formatter.get_emoji(text) == [] +      assert Formatter.get_emoji_map(nil) == %{}      end    end  end diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index 6dfd823f7..d7f11d1d7 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -2182,4 +2182,18 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do                 Transmogrifier.set_replies(object.data)["replies"]      end    end + +  test "take_emoji_tags/1" do +    user = insert(:user, %{emoji: %{"firefox" => "https://example.org/firefox.png"}}) + +    assert Transmogrifier.take_emoji_tags(user) == [ +             %{ +               "icon" => %{"type" => "Image", "url" => "https://example.org/firefox.png"}, +               "id" => "https://example.org/firefox.png", +               "name" => ":firefox:", +               "type" => "Emoji", +               "updated" => "1970-01-01T00:00:00Z" +             } +           ] +  end  end diff --git a/test/web/activity_pub/views/user_view_test.exs b/test/web/activity_pub/views/user_view_test.exs index ecb2dc386..20578161b 100644 --- a/test/web/activity_pub/views/user_view_test.exs +++ b/test/web/activity_pub/views/user_view_test.exs @@ -38,7 +38,7 @@ defmodule Pleroma.Web.ActivityPub.UserViewTest do    end    test "Renders with emoji tags" do -    user = insert(:user, emoji: [%{"bib" => "/test"}]) +    user = insert(:user, emoji: %{"bib" => "/test"})      assert %{               "tag" => [ diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs index f46ad0272..5e78c5758 100644 --- a/test/web/common_api/common_api_test.exs +++ b/test/web/common_api/common_api_test.exs @@ -97,18 +97,6 @@ defmodule Pleroma.Web.CommonAPITest do      assert Object.normalize(activity).data["emoji"]["firefox"]    end -  test "it adds emoji when updating profiles" do -    user = insert(:user, %{name: ":firefox:"}) - -    {:ok, activity} = CommonAPI.update(user) -    user = User.get_cached_by_ap_id(user.ap_id) -    [firefox] = user.source_data["tag"] - -    assert firefox["name"] == ":firefox:" - -    assert Pleroma.Constants.as_public() in activity.recipients -  end -    describe "posting" do      test "it supports explicit addressing" do        user = insert(:user) diff --git a/test/web/common_api/common_api_utils_test.exs b/test/web/common_api/common_api_utils_test.exs index 98cf02d49..b21445fe9 100644 --- a/test/web/common_api/common_api_utils_test.exs +++ b/test/web/common_api/common_api_utils_test.exs @@ -7,7 +7,6 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do    alias Pleroma.Object    alias Pleroma.Web.CommonAPI    alias Pleroma.Web.CommonAPI.Utils -  alias Pleroma.Web.Endpoint    use Pleroma.DataCase    import ExUnit.CaptureLog @@ -42,28 +41,6 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do      end    end -  test "parses emoji from name and bio" do -    {:ok, user} = UserBuilder.insert(%{name: ":blank:", bio: ":firefox:"}) - -    expected = [ -      %{ -        "type" => "Emoji", -        "icon" => %{"type" => "Image", "url" => "#{Endpoint.url()}/emoji/Firefox.gif"}, -        "name" => ":firefox:" -      }, -      %{ -        "type" => "Emoji", -        "icon" => %{ -          "type" => "Image", -          "url" => "#{Endpoint.url()}/emoji/blank.png" -        }, -        "name" => ":blank:" -      } -    ] - -    assert expected == Utils.emoji_from_profile(user) -  end -    describe "format_input/3" do      test "works for bare text/plain" do        text = "hello world!" diff --git a/test/web/mastodon_api/views/account_view_test.exs b/test/web/mastodon_api/views/account_view_test.exs index 4435f69ff..85fa4f6a2 100644 --- a/test/web/mastodon_api/views/account_view_test.exs +++ b/test/web/mastodon_api/views/account_view_test.exs @@ -19,16 +19,6 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do    end    test "Represent a user account" do -    source_data = %{ -      "tag" => [ -        %{ -          "type" => "Emoji", -          "icon" => %{"url" => "/file.png"}, -          "name" => ":karjalanpiirakka:" -        } -      ] -    } -      background_image = %{        "url" => [%{"href" => "https://example.com/images/asuka_hospital.png"}]      } @@ -37,13 +27,13 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do        insert(:user, %{          follower_count: 3,          note_count: 5, -        source_data: source_data,          background: background_image,          nickname: "shp@shitposter.club",          name: ":karjalanpiirakka: shp",          bio:            "<script src=\"invalid-html\"></script><span>valid html</span>. a<br>b<br/>c<br >d<br />f", -        inserted_at: ~N[2017-08-15 15:47:06.597036] +        inserted_at: ~N[2017-08-15 15:47:06.597036], +        emoji: %{"karjalanpiirakka" => "/file.png"}        })      expected = %{ @@ -117,7 +107,6 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do        insert(:user, %{          follower_count: 3,          note_count: 5, -        source_data: %{},          actor_type: "Service",          nickname: "shp@shitposter.club",          inserted_at: ~N[2017-08-15 15:47:06.597036] @@ -311,7 +300,6 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do        insert(:user, %{          follower_count: 0,          note_count: 5, -        source_data: %{},          actor_type: "Service",          nickname: "shp@shitposter.club",          inserted_at: ~N[2017-08-15 15:47:06.597036] | 
