mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 10:46:53 -04:00
Update view model tests
This commit is contained in:
parent
15a0d9aae2
commit
9401b688bc
@ -110,7 +110,7 @@ class ZimManageViewModel @Inject constructor(
|
||||
val requestFiltering = BehaviorProcessor.createDefault<String>("")
|
||||
val currentPage = PublishProcessor.create<Int>()
|
||||
|
||||
val libraryFragmentIsVisible = currentPage.filter { it == 1 }
|
||||
val libraryTabIsVisible = currentPage.filter { it == 1 }
|
||||
|
||||
private val compositeDisposable = CompositeDisposable()
|
||||
|
||||
|
@ -112,7 +112,11 @@ class ZimFileSelectFragment : BaseFragment() {
|
||||
zimManageViewModel.fileSelectActions.offer(FileSelectActions.RestartActionMode)
|
||||
}
|
||||
|
||||
disposable.add(zimManageViewModel.libraryFragmentIsVisible.subscribe { actionMode?.finish() })
|
||||
disposable.add(zimManageViewModel.libraryTabIsVisible.subscribe { finishActionMode() })
|
||||
}
|
||||
|
||||
fun finishActionMode() {
|
||||
actionMode?.finish()
|
||||
}
|
||||
|
||||
private fun sideEffects() = zimManageViewModel.sideEffects.subscribe(
|
||||
|
@ -517,4 +517,18 @@ class ZimManageViewModelTest {
|
||||
.assertValues(StartMultiSelection(viewModel.fileSelectActions))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `finish actionMode on tab change to online section`() {
|
||||
viewModel.libraryTabIsVisible.test()
|
||||
.also { viewModel.currentPage.offer(1) }
|
||||
.assertValue(1)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `no change in actionMode`() {
|
||||
viewModel.libraryTabIsVisible.test()
|
||||
.also { viewModel.currentPage.offer(0) }
|
||||
.assertEmpty()
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user