f39472ee33b1dc309423fc2a8a10dcd6fab04fca
[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.Builders.{UserBuilder}
4 use Pleroma.DataCase
5
6 test "it adds attachment links to a given text and attachment set" do
7 name =
8 "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"
9
10 attachment = %{
11 "url" => [%{"href" => name}]
12 }
13
14 res = Utils.add_attachments("", [attachment])
15
16 assert res ==
17 "<br><a href=\"#{name}\" class='attachment'>Sakura Mana – Turned on by a Se…</a>"
18 end
19
20 describe "it confirms the password given is the current users password" do
21 test "incorrect password given" do
22 {:ok, user} = UserBuilder.insert()
23
24 assert Utils.confirm_current_password(user, "") == {:error, "Invalid password."}
25 end
26
27 test "correct password given" do
28 {:ok, user} = UserBuilder.insert()
29 assert Utils.confirm_current_password(user, "test") == {:ok, user}
30 end
31 end
32 end