Skip to content

Commit

Permalink
fix: test imports and reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
sds100 committed Jun 15, 2024
1 parent 71ba2c4 commit 3a7a8ba
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.launch
import kotlinx.coroutines.test.DelayController
import kotlinx.coroutines.test.TestCoroutineDispatcher
import kotlinx.coroutines.test.TestCoroutineExceptionHandler
import kotlinx.coroutines.test.createTestCoroutineScope
Expand All @@ -26,6 +27,7 @@ import org.mockito.kotlin.mock
import org.mockito.kotlin.times
import org.mockito.kotlin.verify
import org.mockito.kotlin.whenever
import kotlin.coroutines.ContinuationInterceptor

/**
* Created by sds100 on 25/04/2021.
Expand Down Expand Up @@ -89,14 +91,14 @@ class NotificationControllerTest {
coroutineScope.runBlockingTest {
// WHEN

pauseDispatcher()
(coroutineContext[ContinuationInterceptor]!! as DelayController).pauseDispatcher()
launch {
onActionClick.emit(NotificationController.ACTION_ON_SETUP_CHOSEN_DEVICES_AGAIN)
}

// THEN
assertThat(controller.openApp.toListWithTimeout().size, `is`(1))
resumeDispatcher()
(coroutineContext[ContinuationInterceptor]!! as DelayController).resumeDispatcher()

assertThat(fakeOnboarding.approvedSetupChosenDevicesAgainNotification, `is`(true))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,18 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.test.TestCoroutineDispatcher
import kotlinx.coroutines.test.TestCoroutineExceptionHandler
import kotlinx.coroutines.test.advanceUntilIdle
import kotlinx.coroutines.test.createTestCoroutineScope
import kotlinx.coroutines.test.runBlockingTest
import org.junit.After
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.kotlin.atLeast
import org.mockito.kotlin.doReturn
import org.mockito.kotlin.mock
import org.mockito.kotlin.times
import org.mockito.kotlin.verify

/**
* Created by sds100 on 15/05/2021.
Expand Down Expand Up @@ -159,7 +165,10 @@ class SimpleMappingControllerTest {

// WHEN
controller.onDetected("id", FakeMapping(actionList = listOf(action)))
advanceTimeBy(200)
testScheduler.apply {
advanceTimeBy(200)
runCurrent()
}
controller.onDetected("id", FakeMapping(actionList = listOf(action)))

// THEN
Expand All @@ -182,7 +191,10 @@ class SimpleMappingControllerTest {

// WHEN
controller.onDetected("id", FakeMapping(actionList = listOf(action)))
advanceTimeBy(5000)
testScheduler.apply {
advanceTimeBy(5000)
runCurrent()
}
controller.onDetected("id", FakeMapping(actionList = listOf(action)))

// THEN
Expand Down
Loading

0 comments on commit 3a7a8ba

Please sign in to comment.