Attempt to resolve merge conflict
[akkoma] / test / web / common_api / common_api_utils_test.exs
1 defmodule Pleroma.Web.CommonAPI.UtilsTest do
2 alias Pleroma.Web.CommonAPI.Utils
3 alias Pleroma.Web.Endpoint
4 alias Pleroma.Builders.{UserBuilder}
5 use Pleroma.DataCase
6
7 test "it adds attachment links to a given text and attachment set" do
8 name =
9 "Sakura%20Mana%20%E2%80%93%20Turned%20on%20by%20a%20Senior%20OL%20with%20a%20Temptating%20Tight%20Skirt-s%20Full%20Hipline%20and%20Panty%20Shot-%20Beautiful%20Thick%20Thighs-%20and%20Erotic%20Ass-%20-2015-%20--%20Oppaitime%208-28-2017%206-50-33%20PM.png"
10
11 attachment = %{
12 "url" => [%{"href" => name}]
13 }
14
15 res = Utils.add_attachments("", [attachment])
16
17 assert res ==
18 "<br><a href=\"#{name}\" class='attachment'>Sakura Mana – Turned on by a Se…</a>"
19 end
20
21 describe "it confirms the password given is the current users password" do
22 test "incorrect password given" do
23 {:ok, user} = UserBuilder.insert()
24
25 assert Utils.confirm_current_password(user, "") == {:error, "Invalid password."}
26 end
27
28 test "correct password given" do
29 {:ok, user} = UserBuilder.insert()
30 assert Utils.confirm_current_password(user, "test") == {:ok, user}
31 end
32 end
33
34 test "parses emoji from name and bio" do
35 {:ok, user} = UserBuilder.insert(%{name: ":karjalanpiirakka:", bio: ":perkele:"})
36
37 expected = [
38 %{
39 "type" => "Emoji",
40 "icon" => %{"type" => "Image", "url" => "#{Endpoint.url()}/finmoji/128px/perkele-128.png"},
41 "name" => ":perkele:"
42 },
43 %{
44 "type" => "Emoji",
45 "icon" => %{
46 "type" => "Image",
47 "url" => "#{Endpoint.url()}/finmoji/128px/karjalanpiirakka-128.png"
48 },
49 "name" => ":karjalanpiirakka:"
50 }
51 ]
52
53 assert expected == Utils.emoji_from_profile(user)
54 end
55 end