Notification test

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2022-08-21 23:23:19 +02:00
parent d90d00d77c
commit b8e44cb231

View file

@ -128,6 +128,47 @@ test "does not create a notification for subscribed users if status is a reply"
subscriber_notifications = Notification.for_user(subscriber)
assert Enum.empty?(subscriber_notifications)
end
test "creates notification for event join request" do
user = insert(:user)
other_user = insert(:user)
{:ok, activity} = CommonAPI.event(user, %{name: "test event", status: "", join_mode: "restricted"})
CommonAPI.join(other_user, activity.id)
user_notifications = Notification.for_user(user)
assert length(user_notifications) == 1
end
test "creates notification for event join approval" do
user = insert(:user)
other_user = insert(:user)
{:ok, activity} = CommonAPI.event(user, %{name: "test event", status: "", join_mode: "restricted"})
CommonAPI.join(other_user, activity.id)
CommonAPI.accept_join_request(user, other_user, activity.data["object"])
user_notifications = Notification.for_user(other_user)
assert length(user_notifications) == 1
end
test "doesn't create notification for events without participation approval" do
user = insert(:user)
other_user = insert(:user)
{:ok, activity} = CommonAPI.event(user, %{name: "test event", status: "", join_mode: "free"})
CommonAPI.join(other_user, activity.id)
user_notifications = Notification.for_user(user)
assert length(user_notifications) == 0
user_notifications = Notification.for_user(other_user)
assert length(user_notifications) == 0
end
end
test "create_poll_notifications/1" do