From f9d13558c8198bf2a25035dfb3c112aaa2be4cbf Mon Sep 17 00:00:00 2001 From: eal Date: Sun, 12 Aug 2018 22:24:10 +0300 Subject: CommonAPI: add emoji to user source data on update --- test/web/common_api/common_api_utils_test.exs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test/web/common_api/common_api_utils_test.exs') diff --git a/test/web/common_api/common_api_utils_test.exs b/test/web/common_api/common_api_utils_test.exs index f39472ee3..cf97b2bfd 100644 --- a/test/web/common_api/common_api_utils_test.exs +++ b/test/web/common_api/common_api_utils_test.exs @@ -1,5 +1,6 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do alias Pleroma.Web.CommonAPI.Utils + alias Pleroma.Web.Endpoint alias Pleroma.Builders.{UserBuilder} use Pleroma.DataCase @@ -29,4 +30,23 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do assert Utils.confirm_current_password(user, "test") == {:ok, user} end end + + test "parses emoji from name and bio" do + {:ok, user} = UserBuilder.insert(%{name: ":karjalanpiirakka:", bio: ":perkele:"}) + + expected = [ + %{ + "type" => "Emoji", + "icon" => %{"url" => "#{Endpoint.url()}/finmoji/128px/perkele-128.png"}, + "name" => ":perkele:" + }, + %{ + "type" => "Emoji", + "icon" => %{"url" => "#{Endpoint.url()}/finmoji/128px/karjalanpiirakka-128.png"}, + "name" => ":karjalanpiirakka:" + } + ] + + assert expected == Utils.emoji_from_profile(user) + end end -- cgit v1.2.3 From 92caa2632ba559961ebceccc9c0b44fbb8af05ed Mon Sep 17 00:00:00 2001 From: eal Date: Mon, 13 Aug 2018 16:21:18 +0300 Subject: Use Image type for emoji icons. --- test/web/common_api/common_api_utils_test.exs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/web/common_api/common_api_utils_test.exs') diff --git a/test/web/common_api/common_api_utils_test.exs b/test/web/common_api/common_api_utils_test.exs index cf97b2bfd..f7d614582 100644 --- a/test/web/common_api/common_api_utils_test.exs +++ b/test/web/common_api/common_api_utils_test.exs @@ -37,12 +37,12 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do expected = [ %{ "type" => "Emoji", - "icon" => %{"url" => "#{Endpoint.url()}/finmoji/128px/perkele-128.png"}, + "icon" => %{"type" => "Image", "url" => "#{Endpoint.url()}/finmoji/128px/perkele-128.png"}, "name" => ":perkele:" }, %{ "type" => "Emoji", - "icon" => %{"url" => "#{Endpoint.url()}/finmoji/128px/karjalanpiirakka-128.png"}, + "icon" => %{"type" => "Image", "url" => "#{Endpoint.url()}/finmoji/128px/karjalanpiirakka-128.png"}, "name" => ":karjalanpiirakka:" } ] -- cgit v1.2.3 From 86dca3964084c3c1b1a9c0d051ac5e214ff03c94 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sun, 26 Aug 2018 23:19:45 +0000 Subject: tests: fix formatting --- test/web/common_api/common_api_utils_test.exs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'test/web/common_api/common_api_utils_test.exs') diff --git a/test/web/common_api/common_api_utils_test.exs b/test/web/common_api/common_api_utils_test.exs index f7d614582..b01ce04f8 100644 --- a/test/web/common_api/common_api_utils_test.exs +++ b/test/web/common_api/common_api_utils_test.exs @@ -42,7 +42,10 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do }, %{ "type" => "Emoji", - "icon" => %{"type" => "Image", "url" => "#{Endpoint.url()}/finmoji/128px/karjalanpiirakka-128.png"}, + "icon" => %{ + "type" => "Image", + "url" => "#{Endpoint.url()}/finmoji/128px/karjalanpiirakka-128.png" + }, "name" => ":karjalanpiirakka:" } ] -- cgit v1.2.3