Skip to content

Commit

Permalink
fix(detekt): shorten test method by extracting conversation object cr…
Browse files Browse the repository at this point in the history
…eation

Signed-off-by: Andy Scherzinger <[email protected]>
  • Loading branch information
AndyScherzinger committed Dec 2, 2024
1 parent 720fdda commit 5011649
Showing 1 changed file with 28 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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())
}
}

0 comments on commit 5011649

Please sign in to comment.