TestSwrClientPlus

This extended interface of the SwrClientPlus provides the capability to mock specific queries, mutations, and subscriptions for the purpose of testing. By registering certain keys as mocks, you can control the behavior of these specific keys while the rest of the keys function normally. This allows for more targeted and precise testing of your application.

val client = SwrCachePlus(..)
val testClient = client.testPlus {
on(MySubscriptionId) { MutableStateFlow("returned fake data") }
}

testClient.doSomething()

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
abstract val errorRelay: Flow<ErrorRecord>

Functions

Link copied to clipboard
abstract fun gc(level: MemoryPressureLevel)
Link copied to clipboard
abstract fun <T, S> getInfiniteQuery(key: InfiniteQueryKey<T, S>, marker: Marker): InfiniteQueryRef<T, S>
Link copied to clipboard
abstract fun <T, S> getMutation(key: MutationKey<T, S>, marker: Marker): MutationRef<T, S>
Link copied to clipboard
abstract fun <T> getQuery(key: QueryKey<T>, marker: Marker): QueryRef<T>
Link copied to clipboard
abstract fun <T> getSubscription(key: SubscriptionKey<T>, marker: Marker): SubscriptionRef<T>
Link copied to clipboard
abstract fun <T, S> on(id: InfiniteQueryId<T, S>, fetch: FakeInfiniteQueryFetch<T, S>)

Mocks the query process corresponding to InfiniteQueryId.

abstract fun <T, S> on(id: MutationId<T, S>, mutate: FakeMutationMutate<T, S>)

Mocks the mutation process corresponding to MutationId.

abstract fun <T> on(id: QueryId<T>, fetch: FakeQueryFetch<T>)

Mocks the query process corresponding to QueryId.

abstract fun <T> on(id: SubscriptionId<T>, subscribe: FakeSubscriptionSubscribe<T>)

Mocks the subscription process corresponding to SubscriptionId.

Link copied to clipboard
abstract fun onMount(id: String)
Link copied to clipboard
abstract fun onUnmount(id: String)
Link copied to clipboard
abstract fun perform(sideEffects: QueryEffect): Job
Link copied to clipboard
abstract fun <T, S> prefetchInfiniteQuery(key: InfiniteQueryKey<T, S>, marker: Marker): Job
Link copied to clipboard
abstract fun <T> prefetchQuery(key: QueryKey<T>, marker: Marker): Job
Link copied to clipboard
abstract fun purgeAll()
Link copied to clipboard
fun SwrClient.test(initializer: TestSwrClient.() -> Unit = {}): TestSwrClient

Switches SwrClient to a test interface.

Link copied to clipboard

Switches SwrClientPlus to a test interface.