mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-22 22:49:25 +00:00
54ed8760ff
Reviewed-on: https://akkoma.dev/AkkomaGang/akkoma/pulls/85
41 lines
1.3 KiB
Elixir
41 lines
1.3 KiB
Elixir
# 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
|