Fixed the JvmMockKGateway error in mock deps.

* Fixed the SearchStateTest test which sometimes failing.
This commit is contained in:
MohitMaliFtechiz 2024-08-16 13:16:33 +05:30 committed by Kelson
parent 0fe6dd4dbc
commit bcb4a46315
2 changed files with 12 additions and 11 deletions

View File

@ -38,7 +38,7 @@ object Versions {
const val io_objectbox: String = "3.5.0"
const val io_mockk: String = "1.13.12"
const val io_mockk: String = "1.13.7"
const val android_arch_lifecycle_extensions: String = "1.1.1"

View File

@ -109,7 +109,7 @@ internal class SearchStateTest {
val searchIteratorWrapper: SuggestionIteratorWrapper = mockk()
val entryWrapper: SuggestionItemWrapper = mockk()
every { suggestionSearchWrapper.estimatedMatches } returns 500
every { suggestionSearchWrapper.estimatedMatches } returns 100
every { searchIteratorWrapper.hasNext() } returnsMany listOf(true, false)
every { searchIteratorWrapper.next() } returns entryWrapper
every { entryWrapper.title } returns "Result"
@ -125,14 +125,14 @@ internal class SearchStateTest {
}
job.cancelAndJoin()
val job1 = launch(Dispatchers.IO) {
list1 = searchState.getVisibleResults(0)
}
// test the coroutine job is cancelled properly
assertThat(job.isCancelled).isTrue
assertThat(list?.size).isEqualTo(0)
val job1 = launch(Dispatchers.IO) {
list1 = searchState.getVisibleResults(0)
}
job1.invokeOnCompletion {
// test the second job is successfully return the data
assertThat(job1.isCompleted).isTrue
assertThat(list1?.size).isEqualTo(1)
@ -140,3 +140,4 @@ internal class SearchStateTest {
assertThat(list1?.get(0)?.value).isEqualTo("Result")
}
}
}