Skip to content

Commit

Permalink
Update test dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
yasinkacmaz committed Sep 15, 2024
1 parent 8d2e45c commit 04892f7
Show file tree
Hide file tree
Showing 12 changed files with 13 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,13 @@ class SettingsDialogTest {
}
}

private fun ComposeUiTest.showSettingsDialog(
uiState: SettingsViewModel.UiState,
selectedLanguage: Language,
) = setTestContent {
SettingsDialog(
uiState = uiState,
selectedLanguage = selectedLanguage,
onLanguageSelected = {},
onDialogDismissed = {},
)
}
private fun ComposeUiTest.showSettingsDialog(uiState: SettingsViewModel.UiState, selectedLanguage: Language) =
setTestContent {
SettingsDialog(
uiState = uiState,
selectedLanguage = selectedLanguage,
onLanguageSelected = {},
onDialogDismissed = {},
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ import com.yasinkacmaz.jetflix.ui.filter.option.SortBy
import com.yasinkacmaz.jetflix.util.CoroutineTestRule
import com.yasinkacmaz.jetflix.util.FakeStringDataStore
import com.yasinkacmaz.jetflix.util.json
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.test.runTest
import org.junit.Rule
import org.junit.Test
import strikt.api.expectThat
import strikt.assertions.isEqualTo

@ExperimentalCoroutinesApi
class FilterDataStoreTest {
@get:Rule
val coroutineTestRule = CoroutineTestRule()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@ import com.yasinkacmaz.jetflix.util.json
import com.yasinkacmaz.jetflix.util.test
import com.yasinkacmaz.jetflix.util.testDispatchers
import java.io.IOException
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.test.runTest
import org.junit.Rule
import org.junit.Test
import strikt.api.expectThat
import strikt.assertions.isEqualTo

@ExperimentalCoroutinesApi
class FilterViewModelTest {
@get:Rule
val coroutineTestRule = CoroutineTestRule()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ import com.yasinkacmaz.jetflix.util.CoroutineTestRule
import com.yasinkacmaz.jetflix.util.client.FakeMovieClient
import com.yasinkacmaz.jetflix.util.test
import java.io.IOException
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
import org.junit.Rule
import org.junit.Test
import strikt.api.expectThat
import strikt.assertions.isA
import strikt.assertions.isEqualTo

@ExperimentalCoroutinesApi
class MovieDetailViewModelTest {
@get:Rule
val coroutineTestRule = CoroutineTestRule()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ import com.yasinkacmaz.jetflix.ui.filter.MovieRequestOptionsMapper
import com.yasinkacmaz.jetflix.ui.movies.movie.MovieMapper
import com.yasinkacmaz.jetflix.util.CoroutineTestRule
import com.yasinkacmaz.jetflix.util.client.FakeMovieClient
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
import org.junit.Rule
import org.junit.Test
import strikt.api.expectThat
import strikt.assertions.isEqualTo

@ExperimentalCoroutinesApi
class MoviesPagingSourceTest {
@get:Rule
val coroutineTestRule = CoroutineTestRule()
Expand All @@ -25,7 +23,7 @@ class MoviesPagingSourceTest {
private val filterState = FilterState()
private val loadParams = PagingSource.LoadParams.Refresh(1, 1, true)

lateinit var moviesPagingSource: MoviesPagingSource
private lateinit var moviesPagingSource: MoviesPagingSource

@Test
fun `should call movies endpoint when query is empty`() = runTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ import com.yasinkacmaz.jetflix.util.FakeStringDataStore
import com.yasinkacmaz.jetflix.util.client.FakeMovieClient
import com.yasinkacmaz.jetflix.util.json
import com.yasinkacmaz.jetflix.util.test
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
import org.junit.Rule
import org.junit.Test
import strikt.api.expectThat
import strikt.assertions.isEmpty
import strikt.assertions.isEqualTo

@ExperimentalCoroutinesApi
class MoviesViewModelTest {
@get:Rule
val coroutineTestRule = CoroutineTestRule()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.yasinkacmaz.jetflix.util.CoroutineTestRule
import com.yasinkacmaz.jetflix.util.client.FakePersonClient
import com.yasinkacmaz.jetflix.util.test
import java.io.IOException
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
import org.junit.Rule
import org.junit.Test
Expand All @@ -13,7 +12,6 @@ import strikt.assertions.isA
import strikt.assertions.isEqualTo
import strikt.assertions.isNull

@ExperimentalCoroutinesApi
class ProfileViewModelTest {
@get:Rule
val coroutineTestRule = CoroutineTestRule()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ package com.yasinkacmaz.jetflix.ui.settings
import com.yasinkacmaz.jetflix.util.CoroutineTestRule
import com.yasinkacmaz.jetflix.util.FakeStringDataStore
import com.yasinkacmaz.jetflix.util.json
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.test.runTest
import org.junit.Rule
import org.junit.Test
import strikt.api.expectThat
import strikt.assertions.isEqualTo

@ExperimentalCoroutinesApi
class LanguageDataStoreTest {
@get:Rule
val coroutineTestRule = CoroutineTestRule()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ import com.yasinkacmaz.jetflix.util.json
import com.yasinkacmaz.jetflix.util.test
import com.yasinkacmaz.jetflix.util.testDispatchers
import java.io.IOException
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
import org.junit.Test
import strikt.api.expectThat
import strikt.assertions.isEqualTo

@ExperimentalCoroutinesApi
class SettingsViewModelTest {

private val configurationService = FakeConfigurationClient()
Expand Down
4 changes: 0 additions & 4 deletions app/src/test/java/com/yasinkacmaz/jetflix/util/FlowTest.kt
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
package com.yasinkacmaz.jetflix.util

import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.test.TestScope

context(TestScope)
@OptIn(ExperimentalCoroutinesApi::class)
fun <T> Flow<T>.test(): List<T> {
val values = mutableListOf<T>()
this
Expand Down
3 changes: 1 addition & 2 deletions app/src/test/java/com/yasinkacmaz/jetflix/util/Json.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.yasinkacmaz.jetflix.util

import java.io.Reader
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.json.Json
import java.io.Reader

val json = Json {
isLenient = true
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ compose_navigation = { module = "androidx.navigation:navigation-compose", versio
compose_constraintLayout = { module = "androidx.constraintlayout:constraintlayout-compose", version = "1.1.0-beta01" }
compose_testManifest = { module = "androidx.compose.ui:ui-test-manifest", version = "1.8.0-alpha01" }
junit = { module = "junit:junit", version = "4.13.2" }
strikt = { module = "io.strikt:strikt-core", version = "0.34.1" }
coroutinesTest = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version = "1.8.0-RC" }
strikt = { module = "io.strikt:strikt-core", version = "0.35.1" }
coroutinesTest = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version = "1.9.0" }

[bundles]
androidX = ["androidX_palette", "androidX_browser", "androidX_datastore", "androidX-splashscreen"]
Expand Down

0 comments on commit 04892f7

Please sign in to comment.