Fix tests that used finmoji

This commit is contained in:
Ekaterina Vaartis 2019-04-18 22:04:37 +03:00
parent 52ed287e87
commit aef3a3ca46
7 changed files with 23 additions and 24 deletions

View file

@ -245,10 +245,10 @@ defmodule Pleroma.FormatterTest do
end end
test "it adds cool emoji" do test "it adds cool emoji" do
text = "I love :moominmamma:" text = "I love :firefox:"
expected_result = expected_result =
"I love <img height=\"32px\" width=\"32px\" alt=\"moominmamma\" title=\"moominmamma\" src=\"/finmoji/128px/moominmamma-128.png\" />" "I love <img height=\"32px\" width=\"32px\" alt=\"firefox\" title=\"firefox\" src=\"/emoji/Firefox.gif\" />"
assert Formatter.emojify(text) == expected_result assert Formatter.emojify(text) == expected_result
end end
@ -269,10 +269,10 @@ defmodule Pleroma.FormatterTest do
end end
test "it returns the emoji used in the text" do test "it returns the emoji used in the text" do
text = "I love :moominmamma:" text = "I love :firefox:"
assert Formatter.get_emoji(text) == [ assert Formatter.get_emoji(text) == [
{"moominmamma", "/finmoji/128px/moominmamma-128.png", "Finmoji"} {"firefox", "/emoji/Firefox.gif", ["Gif", "Fun"]}
] ]
end end

View file

@ -946,7 +946,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
test "it strips internal fields" do test "it strips internal fields" do
user = insert(:user) user = insert(:user)
{:ok, activity} = CommonAPI.post(user, %{"status" => "#2hu :moominmamma:"}) {:ok, activity} = CommonAPI.post(user, %{"status" => "#2hu :firefox:"})
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data) {:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)

View file

@ -40,19 +40,19 @@ defmodule Pleroma.Web.CommonAPITest do
test "it adds emoji in the object" do test "it adds emoji in the object" do
user = insert(:user) user = insert(:user)
{:ok, activity} = CommonAPI.post(user, %{"status" => ":moominmamma:"}) {:ok, activity} = CommonAPI.post(user, %{"status" => ":firefox:"})
assert Object.normalize(activity).data["emoji"]["moominmamma"] assert Object.normalize(activity).data["emoji"]["firefox"]
end end
test "it adds emoji when updating profiles" do test "it adds emoji when updating profiles" do
user = insert(:user, %{name: ":karjalanpiirakka:"}) user = insert(:user, %{name: ":firefox:"})
CommonAPI.update(user) CommonAPI.update(user)
user = User.get_cached_by_ap_id(user.ap_id) user = User.get_cached_by_ap_id(user.ap_id)
[karjalanpiirakka] = user.info.source_data["tag"] [firefox] = user.info.source_data["tag"]
assert karjalanpiirakka["name"] == ":karjalanpiirakka:" assert firefox["name"] == ":firefox:"
end end
describe "posting" do describe "posting" do

View file

@ -37,21 +37,21 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do
end end
test "parses emoji from name and bio" do test "parses emoji from name and bio" do
{:ok, user} = UserBuilder.insert(%{name: ":karjalanpiirakka:", bio: ":perkele:"}) {:ok, user} = UserBuilder.insert(%{name: ":blank:", bio: ":firefox:"})
expected = [ expected = [
%{ %{
"type" => "Emoji", "type" => "Emoji",
"icon" => %{"type" => "Image", "url" => "#{Endpoint.url()}/finmoji/128px/perkele-128.png"}, "icon" => %{"type" => "Image", "url" => "#{Endpoint.url()}/emoji/Firefox.gif"},
"name" => ":perkele:" "name" => ":firefox:"
}, },
%{ %{
"type" => "Emoji", "type" => "Emoji",
"icon" => %{ "icon" => %{
"type" => "Image", "type" => "Image",
"url" => "#{Endpoint.url()}/finmoji/128px/karjalanpiirakka-128.png" "url" => "#{Endpoint.url()}/emoji/blank.png"
}, },
"name" => ":karjalanpiirakka:" "name" => ":blank:"
} }
] ]

View file

@ -107,7 +107,7 @@ defmodule Pleroma.Web.Push.ImplTest do
"type" => "Create", "type" => "Create",
"object" => %{ "object" => %{
"content" => "content" =>
"<span>Lorem ipsum dolor sit amet</span>, consectetur :bear: adipiscing elit. Fusce sagittis finibus turpis." "<span>Lorem ipsum dolor sit amet</span>, consectetur :firefox: adipiscing elit. Fusce sagittis finibus turpis."
} }
} }
} }
@ -129,7 +129,7 @@ defmodule Pleroma.Web.Push.ImplTest do
insert(:note, %{ insert(:note, %{
data: %{ data: %{
"content" => "content" =>
"<span>Lorem ipsum dolor sit amet</span>, consectetur :bear: adipiscing elit. Fusce sagittis finibus turpis." "<span>Lorem ipsum dolor sit amet</span>, consectetur :firefox: adipiscing elit. Fusce sagittis finibus turpis."
} }
}) })

View file

@ -41,7 +41,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
input = %{ input = %{
"status" => "status" =>
"Hello again, @shp.<script></script>\nThis is on another :moominmamma: line. #2hu #epic #phantasmagoric", "Hello again, @shp.<script></script>\nThis is on another :firefox: line. #2hu #epic #phantasmagoric",
"media_ids" => [object.id] "media_ids" => [object.id]
} }
@ -49,7 +49,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
object = Object.normalize(activity.data["object"]) object = Object.normalize(activity.data["object"])
expected_text = expected_text =
"Hello again, <span class='h-card'><a data-user='#{mentioned_user.id}' class='u-url mention' href='shp'>@<span>shp</span></a></span>.&lt;script&gt;&lt;/script&gt;<br>This is on another :moominmamma: line. <a class='hashtag' data-tag='2hu' href='http://localhost:4001/tag/2hu' rel='tag'>#2hu</a> <a class='hashtag' data-tag='epic' href='http://localhost:4001/tag/epic' rel='tag'>#epic</a> <a class='hashtag' data-tag='phantasmagoric' href='http://localhost:4001/tag/phantasmagoric' rel='tag'>#phantasmagoric</a><br><a href=\"http://example.org/image.jpg\" class='attachment'>image.jpg</a>" "Hello again, <span class='h-card'><a data-user='#{mentioned_user.id}' class='u-url mention' href='shp'>@<span>shp</span></a></span>.&lt;script&gt;&lt;/script&gt;<br>This is on another :firefox: line. <a class='hashtag' data-tag='2hu' href='http://localhost:4001/tag/2hu' rel='tag'>#2hu</a> <a class='hashtag' data-tag='epic' href='http://localhost:4001/tag/epic' rel='tag'>#epic</a> <a class='hashtag' data-tag='phantasmagoric' href='http://localhost:4001/tag/phantasmagoric' rel='tag'>#phantasmagoric</a><br><a href=\"http://example.org/image.jpg\" class='attachment'>image.jpg</a>"
assert get_in(object.data, ["content"]) == expected_text assert get_in(object.data, ["content"]) == expected_text
assert get_in(object.data, ["type"]) == "Note" assert get_in(object.data, ["type"]) == "Note"
@ -65,8 +65,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
assert Enum.member?(get_in(activity.data, ["to"]), "shp") assert Enum.member?(get_in(activity.data, ["to"]), "shp")
assert activity.local == true assert activity.local == true
assert %{"moominmamma" => "http://localhost:4001/finmoji/128px/moominmamma-128.png"} = assert %{"firefox" => "http://localhost:4001/emoji/Firefox.gif"} = object.data["emoji"]
object.data["emoji"]
# hashtags # hashtags
assert object.data["tag"] == ["2hu", "epic", "phantasmagoric"] assert object.data["tag"] == ["2hu", "epic", "phantasmagoric"]

View file

@ -91,16 +91,16 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
test "a create activity with a summary containing emoji" do test "a create activity with a summary containing emoji" do
{:ok, activity} = {:ok, activity} =
CommonAPI.post(insert(:user), %{ CommonAPI.post(insert(:user), %{
"spoiler_text" => ":woollysocks: meow", "spoiler_text" => ":firefox: meow",
"status" => "." "status" => "."
}) })
result = ActivityView.render("activity.json", activity: activity) result = ActivityView.render("activity.json", activity: activity)
expected = ":woollysocks: meow" expected = ":firefox: meow"
expected_html = expected_html =
"<img height=\"32px\" width=\"32px\" alt=\"woollysocks\" title=\"woollysocks\" src=\"http://localhost:4001/finmoji/128px/woollysocks-128.png\" /> meow" "<img height=\"32px\" width=\"32px\" alt=\"firefox\" title=\"firefox\" src=\"http://localhost:4001/emoji/Firefox.gif\" /> meow"
assert result["summary"] == expected assert result["summary"] == expected
assert result["summary_html"] == expected_html assert result["summary_html"] == expected_html