mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 10:46:53 -04:00
Update the disposabe and improve test methods
This commit is contained in:
parent
9401b688bc
commit
f837a45d21
@ -110,7 +110,7 @@ class ZimManageViewModel @Inject constructor(
|
||||
val requestFiltering = BehaviorProcessor.createDefault<String>("")
|
||||
val currentPage = PublishProcessor.create<Int>()
|
||||
|
||||
val libraryTabIsVisible = currentPage.filter { it == 1 }
|
||||
val libraryTabIsVisible = currentPage.map { it == 1 }.filter { it }
|
||||
|
||||
private val compositeDisposable = CompositeDisposable()
|
||||
|
||||
|
@ -115,7 +115,7 @@ class ZimFileSelectFragment : BaseFragment() {
|
||||
disposable.add(zimManageViewModel.libraryTabIsVisible.subscribe { finishActionMode() })
|
||||
}
|
||||
|
||||
fun finishActionMode() {
|
||||
private fun finishActionMode() {
|
||||
actionMode?.finish()
|
||||
}
|
||||
|
||||
|
@ -519,14 +519,14 @@ class ZimManageViewModelTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `finish actionMode on tab change to online section`() {
|
||||
fun `libraryTabIsVisible emits when currentPage is 1`() {
|
||||
viewModel.libraryTabIsVisible.test()
|
||||
.also { viewModel.currentPage.offer(1) }
|
||||
.assertValue(1)
|
||||
.assertValue(true)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `no change in actionMode`() {
|
||||
fun `libraryTabIsVisible does not emit when currentPage is 0`() {
|
||||
viewModel.libraryTabIsVisible.test()
|
||||
.also { viewModel.currentPage.offer(0) }
|
||||
.assertEmpty()
|
||||
|
Loading…
x
Reference in New Issue
Block a user