Skip to content

Commit

Permalink
Fixed code style and some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
borichellow committed Dec 9, 2024
1 parent c79f7ef commit 15f3303
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class ConversationAudioMessagePlayerProvider
}
}

@Suppress("TooManyFunctions")
class ConversationAudioMessagePlayer
internal constructor(
private val context: Context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import io.mockk.verify
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.test.runTest
import okio.Path
import org.amshove.kluent.internal.assertEquals
import org.junit.jupiter.api.Test

@Suppress("LongMethod")
Expand Down Expand Up @@ -73,6 +74,11 @@ class ConversationAudioMessagePlayerTest {
assert(currentState != null)
assert(currentState!!.audioMediaPlayingState is AudioMediaPlayingState.SuccessfulFetching)
}
awaitAndAssertStateUpdate { state ->
val currentState = state[testAudioMessageId]
assert(currentState != null)
assertEquals(currentState!!.wavesMask, Arrangement.WAVES_MASK)
}
awaitAndAssertStateUpdate { state ->
val currentState = state[testAudioMessageId]
assert(currentState != null)
Expand Down Expand Up @@ -129,6 +135,11 @@ class ConversationAudioMessagePlayerTest {
assert(currentState != null)
assert(currentState!!.audioMediaPlayingState is AudioMediaPlayingState.SuccessfulFetching)
}
awaitAndAssertStateUpdate { state ->
val currentState = state[testAudioMessageId]
assert(currentState != null)
assertEquals(currentState!!.wavesMask, Arrangement.WAVES_MASK)
}
awaitAndAssertStateUpdate { state ->
val currentState = state[testAudioMessageId]
assert(currentState != null)
Expand Down Expand Up @@ -198,6 +209,11 @@ class ConversationAudioMessagePlayerTest {
assert(currentState != null)
assert(currentState!!.audioMediaPlayingState is AudioMediaPlayingState.SuccessfulFetching)
}
awaitAndAssertStateUpdate { state ->
val currentState = state[firstAudioMessageId]
assert(currentState != null)
assertEquals(currentState!!.wavesMask, Arrangement.WAVES_MASK)
}
awaitAndAssertStateUpdate { state ->
val currentState = state[firstAudioMessageId]
assert(currentState != null)
Expand Down Expand Up @@ -282,6 +298,11 @@ class ConversationAudioMessagePlayerTest {
assert(currentState != null)
assert(currentState!!.audioMediaPlayingState is AudioMediaPlayingState.SuccessfulFetching)
}
awaitAndAssertStateUpdate { state ->
val currentState = state[firstAudioMessageId]
assert(currentState != null)
assertEquals(currentState!!.wavesMask, Arrangement.WAVES_MASK)
}
awaitAndAssertStateUpdate { state ->
val currentState = state[firstAudioMessageId]
assert(currentState != null)
Expand Down Expand Up @@ -409,6 +430,11 @@ class ConversationAudioMessagePlayerTest {
assert(currentState != null)
assert(currentState!!.audioMediaPlayingState is AudioMediaPlayingState.SuccessfulFetching)
}
awaitAndAssertStateUpdate { state ->
val currentState = state[testAudioMessageId]
assert(currentState != null)
assertEquals(currentState!!.wavesMask, Arrangement.WAVES_MASK)
}
awaitAndAssertStateUpdate { state ->
val currentState = state[testAudioMessageId]
assert(currentState != null)
Expand Down Expand Up @@ -494,7 +520,7 @@ class Arrangement {
init {
MockKAnnotations.init(this, relaxed = true)

every { wavesMaskHelper.getWaveMask(any<Path>()) } returns listOf()
every { wavesMaskHelper.getWaveMask(any<Path>()) } returns WAVES_MASK
every { wavesMaskHelper.clear() } returns Unit
}

Expand Down Expand Up @@ -529,4 +555,8 @@ class Arrangement {
}

fun arrange() = this to conversationAudioMessagePlayer

companion object {
val WAVES_MASK = listOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 0)
}
}

0 comments on commit 15f3303

Please sign in to comment.