1
0
Fork 1
mirror of https://akkoma.dev/AkkomaGang/akkoma.git synced 2024-11-17 18:49:15 +00:00
akkoma/test/pleroma/announcement_read_relationship_test.exs

41 lines
1.3 KiB
Elixir
Raw Normal View History

# Pleroma: A lightweight social networking server
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.AnnouncementReadRelationshipTest do
alias Pleroma.AnnouncementReadRelationship
use Pleroma.DataCase, async: true
import Pleroma.Factory
setup do
{:ok, user: insert(:user), announcement: insert(:announcement)}
end
describe "mark_read/2" do
test "should insert relationship", %{user: user, announcement: announcement} do
{:ok, _} = AnnouncementReadRelationship.mark_read(user, announcement)
assert AnnouncementReadRelationship.exists?(user, announcement)
end
end
describe "mark_unread/2" do
test "should delete relationship", %{user: user, announcement: announcement} do
{:ok, _} = AnnouncementReadRelationship.mark_read(user, announcement)
assert :ok = AnnouncementReadRelationship.mark_unread(user, announcement)
refute AnnouncementReadRelationship.exists?(user, announcement)
end
test "should not fail if relationship does not exist", %{
user: user,
announcement: announcement
} do
assert :ok = AnnouncementReadRelationship.mark_unread(user, announcement)
refute AnnouncementReadRelationship.exists?(user, announcement)
end
end
end