fix(detekt): shorten test method by extracting conversation object creation

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2024-12-02 15:25:15 +01:00
parent 720fdda005
commit 5011649499
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B

View file

@ -21,7 +21,34 @@ class ParticipantPermissionsTest : TestCase() {
@Test
fun test_areFlagsSet() {
val spreedCapability = SpreedCapability()
val conversation = Conversation(
val conversation = createConversation()
conversation.permissions = ParticipantPermissions.PUBLISH_SCREEN or
ParticipantPermissions.JOIN_CALL or
ParticipantPermissions.DEFAULT
val user = User()
user.id = 1
val attendeePermissions =
ParticipantPermissions(
spreedCapability,
ConversationModel.mapToConversationModel(conversation, user)
)
assert(attendeePermissions.canPublishScreen)
assert(attendeePermissions.canJoinCall)
assert(attendeePermissions.isDefault)
assertFalse(attendeePermissions.isCustom)
assertFalse(attendeePermissions.canStartCall())
assertFalse(attendeePermissions.canIgnoreLobby())
assertTrue(attendeePermissions.canPublishAudio())
assertTrue(attendeePermissions.canPublishVideo())
}
private fun createConversation(): Conversation {
return Conversation(
token = "test",
name = "test",
displayName = "test",
@ -67,28 +94,5 @@ class ParticipantPermissionsTest : TestCase() {
remoteServer = "",
remoteToken = ""
)
conversation.permissions = ParticipantPermissions.PUBLISH_SCREEN or
ParticipantPermissions.JOIN_CALL or
ParticipantPermissions.DEFAULT
val user = User()
user.id = 1
val attendeePermissions =
ParticipantPermissions(
spreedCapability,
ConversationModel.mapToConversationModel(conversation, user)
)
assert(attendeePermissions.canPublishScreen)
assert(attendeePermissions.canJoinCall)
assert(attendeePermissions.isDefault)
assertFalse(attendeePermissions.isCustom)
assertFalse(attendeePermissions.canStartCall())
assertFalse(attendeePermissions.canIgnoreLobby())
assertTrue(attendeePermissions.canPublishAudio())
assertTrue(attendeePermissions.canPublishVideo())
}
}