[MastoAPI][GlitchAPI] Add bookmarks
[akkoma] / test / user_test.exs
index a0657c7b63736d6d047fc18c17b1f0f84f76ead6..b33398ff6fcb25a8a780b4b9347e3dd96368bc06 100644 (file)
@@ -945,4 +945,31 @@ defmodule Pleroma.UserTest do
       assert expected_text == User.parse_bio(bio, user)
     end
   end
+
+  test "bookmarks" do
+    user = insert(:user)
+
+    {:ok, activity1} =
+      CommonAPI.post(user, %{
+        "status" => "heweoo!"
+      })
+
+    id1 = activity1.data["object"]["id"]
+
+    {:ok, activity2} =
+      CommonAPI.post(user, %{
+        "status" => "heweoo!"
+      })
+
+    id2 = activity2.data["object"]["id"]
+
+    assert {:ok, user_state1} = User.bookmark(user, id1)
+    assert user_state1.bookmarks == [id1]
+
+    assert {:ok, user_state2} = User.unbookmark(user, id1)
+    assert user_state2.bookmarks == []
+
+    assert {:ok, user_state3} = User.bookmark(user, id2)
+    assert user_state3.bookmarks == [id2]
+  end
 end