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

commonTest.subscription.TestSubscriptionValue.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
import com.algolia.instantsearch.core.subscription.SubscriptionValue
import kotlin.test.Test

class TestSubscriptionValue {

    private val value = "value"

    @Test
    fun setAndGetShouldWork() {
        val item: SubscriptionValue = SubscriptionValue(null)

        item.value = value
        item.value shouldEqual value
    }

    @Test
    fun initShouldSetDefaultValue() {
        val item: SubscriptionValue = SubscriptionValue(value)

        item.value shouldEqual value
    }

    @Test
    fun setValueShouldCallSubscriptions() {
        var expected: String? = null
        val item: SubscriptionValue = SubscriptionValue(null)

        item.subscribe { expected = it }
        item.value = value
        expected shouldEqual value
    }

    @Test
    fun subscribePastShouldCallSubscriptions() {
        var expected: String? = null
        val item: SubscriptionValue = SubscriptionValue(value)

        item.subscribePast { expected = value }
        expected shouldEqual value
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy