Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Meyer committed Dec 23, 2024
1 parent 4ccfd4d commit bcf6e58
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,15 @@ internal class SessionTimerImpl @Inject constructor(
if (timerJob?.isActive == true) return

_state.update { it.copy(mode = TimerMode.RUNNING) }
timerJob = timerScope.launch {
while (isActive) {
delay(frameRate)
updateProgress(frameRate)
.also {
timerJob = timerScope.launch {
while (isActive) {
delay(frameRate)
updateProgress(frameRate)
}
}
}
}

}

override fun pause() {
Expand Down Expand Up @@ -94,11 +97,7 @@ internal class SessionTimerImpl @Inject constructor(

private fun updateTimerStatus() = updateProgress(Duration.ZERO)

override fun getStatus() = _state.stateIn(
scope = timerScope,
started = SharingStarted.Eagerly,
initialValue = TimerState()
)
override fun getStatus() = _state

private fun cancelTimer() {
timerJob?.cancel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.test.advanceUntilIdle
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
import net.onefivefour.sessiontimer.core.test.StandardTestDispatcherRule
import net.onefivefour.sessiontimer.core.timer.api.model.TimerMode
Expand Down

0 comments on commit bcf6e58

Please sign in to comment.