From 0b8d70296052252947ad3d3086c4007531271374 Mon Sep 17 00:00:00 2001 From: Nik Clayton Date: Wed, 27 Sep 2023 17:53:24 +0200 Subject: [PATCH] refactor: Remove duplicate `MainCoroutineRule` (#129) --- .../NotificationsViewModelTestBase.kt | 22 +------------------ 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/app/src/test/java/app/pachli/components/notifications/NotificationsViewModelTestBase.kt b/app/src/test/java/app/pachli/components/notifications/NotificationsViewModelTestBase.kt index ebd0d5c17..2c722e204 100644 --- a/app/src/test/java/app/pachli/components/notifications/NotificationsViewModelTestBase.kt +++ b/app/src/test/java/app/pachli/components/notifications/NotificationsViewModelTestBase.kt @@ -22,23 +22,16 @@ import android.os.Looper import androidx.test.ext.junit.runners.AndroidJUnit4 import app.pachli.appstore.EventHub import app.pachli.components.timeline.FiltersRepository +import app.pachli.components.timeline.MainCoroutineRule import app.pachli.db.AccountEntity import app.pachli.db.AccountManager import app.pachli.network.FilterModel import app.pachli.settings.PrefKeys import app.pachli.usecase.TimelineCases -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.test.TestDispatcher -import kotlinx.coroutines.test.UnconfinedTestDispatcher -import kotlinx.coroutines.test.resetMain -import kotlinx.coroutines.test.setMain import okhttp3.ResponseBody import okhttp3.ResponseBody.Companion.toResponseBody import org.junit.Before import org.junit.Rule -import org.junit.rules.TestWatcher -import org.junit.runner.Description import org.junit.runner.RunWith import org.mockito.kotlin.any import org.mockito.kotlin.doAnswer @@ -49,19 +42,6 @@ import org.robolectric.annotation.Config import retrofit2.HttpException import retrofit2.Response -@OptIn(ExperimentalCoroutinesApi::class) -class MainCoroutineRule(private val dispatcher: TestDispatcher = UnconfinedTestDispatcher()) : TestWatcher() { - override fun starting(description: Description) { - super.starting(description) - Dispatchers.setMain(dispatcher) - } - - override fun finished(description: Description) { - super.finished(description) - Dispatchers.resetMain() - } -} - @Config(sdk = [28]) @RunWith(AndroidJUnit4::class) abstract class NotificationsViewModelTestBase {