mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 10:46:53 -04:00
Fixed the JvmMockKGateway
error in mock deps.
* Fixed the SearchStateTest test which sometimes failing.
This commit is contained in:
parent
0fe6dd4dbc
commit
bcb4a46315
@ -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"
|
||||
|
||||
|
@ -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,18 +125,19 @@ 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)
|
||||
assertThat(list1?.get(0)?.url).isEqualTo("path")
|
||||
assertThat(list1?.get(0)?.value).isEqualTo("Result")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user