Merge branch 'feature/jobs' into 'develop'
[akkoma] / test / web / common_api / common_api_test.exs
index a7d9e61613b6f94785e3cf3298dcc5e4de4cc1e2..870648fb54aa3591751879931d2dc7f69d116eee 100644 (file)
@@ -2,7 +2,7 @@
 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
-defmodule Pleroma.Web.CommonAPI.Test do
+defmodule Pleroma.Web.CommonAPITest do
   use Pleroma.DataCase
   alias Pleroma.Web.CommonAPI
   alias Pleroma.User
@@ -164,4 +164,30 @@ defmodule Pleroma.Web.CommonAPI.Test do
       assert %User{info: %{pinned_activities: []}} = user
     end
   end
+
+  describe "mute tests" do
+    setup do
+      user = insert(:user)
+
+      activity = insert(:note_activity)
+
+      [user: user, activity: activity]
+    end
+
+    test "add mute", %{user: user, activity: activity} do
+      {:ok, _} = CommonAPI.add_mute(user, activity)
+      assert CommonAPI.thread_muted?(user, activity)
+    end
+
+    test "remove mute", %{user: user, activity: activity} do
+      CommonAPI.add_mute(user, activity)
+      {:ok, _} = CommonAPI.remove_mute(user, activity)
+      refute CommonAPI.thread_muted?(user, activity)
+    end
+
+    test "check that mutes can't be duplicate", %{user: user, activity: activity} do
+      CommonAPI.add_mute(user, activity)
+      {:error, _} = CommonAPI.add_mute(user, activity)
+    end
+  end
 end