All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonTest.selectable.list.TestSelectableListViewModel.kt Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 3.3.1
Show newest version
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