Update view model tests

This commit is contained in:
Yash Khare 2020-04-17 16:45:40 +05:30
parent 15a0d9aae2
commit 9401b688bc
3 changed files with 20 additions and 2 deletions

View File

@ -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()

View File

@ -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(

View File

@ -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()
}
}