commonTest.selectable.list.TestSelectableListViewModel.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of instantsearch-core Show documentation
Show all versions of instantsearch-core Show documentation
InstantSearch Android is a library providing widgets and helpers to help you build the best instant-search experience on Android with Algolia. It is built on top of Algolia's Kotlin API Client to provide you a high-level solution to quickly build various search interfaces.
package selectable.list
import com.algolia.instantsearch.core.selectable.list.SelectableListViewModel
import com.algolia.instantsearch.core.selectable.list.SelectionMode
import shouldEqual
import kotlin.test.Test
class TestSelectableListViewModel {
private val valueA = "valueA"
private val valueB = "valueB"
@Test
fun singleChoice() {
SelectableListViewModel(selectionMode = SelectionMode.Single).apply {
items.value = listOf(valueA, valueB)
eventSelection.subscribe { selections.value = it }
select(valueA)
selections.value shouldEqual setOf(valueA)
select(valueB)
selections.value shouldEqual setOf(valueB)
select(valueB)
selections.value shouldEqual setOf()
}
}
@Test
fun multipleChoice() {
SelectableListViewModel(selectionMode = SelectionMode.Multiple).apply {
items.value = listOf(valueA, valueB)
eventSelection.subscribe { selections.value = it }
select(valueA)
selections.value shouldEqual setOf(valueA)
select(valueB)
selections.value shouldEqual setOf(valueA, valueB)
select(valueB)
selections.value shouldEqual setOf(valueA)
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy