test: RelationshipTest.ktを追加

This commit is contained in:
usbharu 2024-09-18 23:54:25 +09:00
parent 22084ee4be
commit b52839192c
Signed by: usbharu
GPG Key ID: 95CBCF7046307B77
2 changed files with 43 additions and 31 deletions

View File

@ -28,24 +28,6 @@ class RelationshipTest {
assertContainsEvent(relationship, RelationshipEvent.UNFOLLOW_REQUEST.eventName)
}
@Test
fun block_unfollowされblockが発生する() {
val relationship = Relationship(
actorId = ActorId(1),
targetActorId = ActorId(2),
following = true,
blocking = false,
muting = false,
followRequesting = false,
mutingFollowRequest = false
)
relationship.block()
assertTrue(relationship.blocking)
assertContainsEvent(relationship, RelationshipEvent.BLOCK.eventName)
}
@Test
fun mute_MUTEが発生する() {
val relationship = Relationship(
@ -116,25 +98,55 @@ class RelationshipTest {
assertFalse(relationship.mutingFollowRequest)
}
@Test
fun followRequest_followRequestingがtrueになりFOLLOW_REQUESTが発生する() {
}
@Test
fun followRequest_ブロックしている場合はフォローリクエストを送れない() {
}
@Test
fun unfollowRequest_followRequestingがfalseになりUNFOLLOW_REQUESTが発生する() {
val relationship = Relationship(
ActorId(1),
targetActorId = ActorId(2),
following = false,
blocking = false,
muting = false,
followRequesting = true,
mutingFollowRequest = false
)
relationship.unfollowRequest()
assertFalse(relationship.followRequesting)
assertContainsEvent(relationship, RelationshipEvent.UNFOLLOW_REQUEST.eventName)
}
@Test
fun acceptFollowRequest_followingがtrueにfollowRequestingがfalseになりaccept_followが発生する() {
val relationship = Relationship(
actorId = ActorId(1),
targetActorId = ActorId(2),
following = false,
blocking = false,
muting = false,
followRequesting = true,
mutingFollowRequest = true
)
relationship.acceptFollowRequest()
assertTrue(relationship.following)
assertContainsEvent(relationship, RelationshipEvent.ACCEPT_FOLLOW.eventName)
}
@Test
fun rejectFollowRequest_followRequestingがfalseになりREJECT_FOLLOWが発生する() {
val relationship = Relationship(
actorId = ActorId(1),
targetActorId = ActorId(2),
following = false,
blocking = false,
muting = false,
followRequesting = true,
mutingFollowRequest = false
)
relationship.rejectFollowRequest()
assertFalse(relationship.followRequesting)
assertContainsEvent(relationship, RelationshipEvent.REJECT_FOLLOW.eventName)
}
}

View File

@ -464,7 +464,7 @@ class ExposedRelationshipRepositoryTest : AbstractRepositoryTest(Relationships)
mutingFollowRequest = false,
)
relationship.block()
relationship.mute()
repository.save(relationship)
@ -492,7 +492,7 @@ class ExposedRelationshipRepositoryTest : AbstractRepositoryTest(Relationships)
followRequesting = false,
mutingFollowRequest = false,
)
relationship.block()
relationship.mute()
repository.delete(relationship)