X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;ds=sidebyside;f=test%2Flist_test.exs;h=ba79251da76070c990ccd2b2bbfef18cf8c9462a;hb=92d08d4113c4de09cd8d736ed1a0349745866eef;hp=1909c0cd9e664771e7e425eab8542c5e7d8e8a2a;hpb=3c08d229db423052d0dd88b8a36fb39b0ae81ead;p=akkoma
diff --git a/test/list_test.exs b/test/list_test.exs
index 1909c0cd9..ba79251da 100644
--- a/test/list_test.exs
+++ b/test/list_test.exs
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2018 Pleroma Authors
+# Copyright © 2017-2019 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.ListTest do
@@ -15,6 +15,13 @@ defmodule Pleroma.ListTest do
assert title == "title"
end
+ test "validates title" do
+ user = insert(:user)
+
+ assert {:error, changeset} = Pleroma.List.create("", user)
+ assert changeset.errors == [title: {"can't be blank", [validation: :required]}]
+ end
+
test "getting a list not belonging to the user" do
user = insert(:user)
other_user = insert(:user)
@@ -113,4 +120,30 @@ defmodule Pleroma.ListTest do
assert owned_list in lists_2
refute not_owned_list in lists_2
end
+
+ test "get by ap_id" do
+ user = insert(:user)
+ {:ok, list} = Pleroma.List.create("foo", user)
+ assert Pleroma.List.get_by_ap_id(list.ap_id) == list
+ end
+
+ test "memberships" do
+ user = insert(:user)
+ member = insert(:user)
+ {:ok, list} = Pleroma.List.create("foo", user)
+ {:ok, list} = Pleroma.List.follow(list, member)
+
+ assert Pleroma.List.memberships(member) == [list.ap_id]
+ end
+
+ test "member?" do
+ user = insert(:user)
+ member = insert(:user)
+
+ {:ok, list} = Pleroma.List.create("foo", user)
+ {:ok, list} = Pleroma.List.follow(list, member)
+
+ assert Pleroma.List.member?(list, member)
+ refute Pleroma.List.member?(list, user)
+ end
end