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

commonTest.subscription.TestSubscription.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 subscription

import com.algolia.instantsearch.core.subscription.SubscriptionEvent
import shouldEqual
import kotlin.test.Test

class TestSubscription {

    @Test
    fun unsubscribeShouldRemoveSubscription() {
        val item: SubscriptionEvent = SubscriptionEvent()
        val listener: (String?) -> Unit = { }

        item.subscribe(listener)
        item.subscriptions shouldEqual setOf(listener)
        item.unsubscribe(listener)
        item.subscriptions shouldEqual emptySet()
    }

    @Test
    fun unsubscribeAllShouldRemoveSubscriptions() {
        val item: SubscriptionEvent = SubscriptionEvent()
        val listenerA: (String?) -> Unit = { }
        val listenerB: (String?) -> Unit = { }

        item.subscribe(listenerA)
        item.subscribe(listenerB)
        item.subscriptions shouldEqual setOf(listenerA, listenerB)
        item.unsubscribeAll()
        item.subscriptions shouldEqual emptySet()
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy