mvrx-mocking / com.airbnb.mvrx.mocking / MockableMavericks

MockableMavericks

object MockableMavericks

Entry point for setting up Mavericks for the app in a mockable way.

See initialize

Properties

enableMavericksViewMocking

var enableMavericksViewMocking: Boolean

Calls to MockableMavericksView.provideMocks will return empty unless this is enabled.

enableMockPrinterBroadcastReceiver

var enableMockPrinterBroadcastReceiver: Boolean

Calls to MavericksMockPrinter.startReceiver will be no-ops unless this is enabled.

mockConfigFactory

val mockConfigFactory: MockMavericksViewModelConfigFactory

mockPrinterConfiguration

var mockPrinterConfiguration: MockPrinterConfiguration

Configuration for how mock state is printed.

mockStateHolder

val mockStateHolder: MockStateHolder

This global instance enables mock states to be forced onto ViewModels as they are created. This enable easy testing.

Functions

initialize

fun initialize(applicationContext: Context): Unit
fun initialize(mocksEnabled: Boolean, debugMode: Boolean, applicationContext: Context?, viewModelCoroutineContext: CoroutineContext = EmptyCoroutineContext, stateStoreCoroutineContext: CoroutineContext = EmptyCoroutineContext, subscriptionCoroutineContextOverride: CoroutineContext = EmptyCoroutineContext): Unit

Initializes the required Mavericks.viewModelConfigFactory and sets ViewModel debug and mock behavior for the app.

setScriptableState

fun <VM : MavericksViewModel<S>, S : MavericksState> setScriptableState(viewModel: VM, state: S): Unit

If the given viewmodel has a state store that implements ScriptableStateStore then this function can be used to set the next state via ScriptableStateStore.next.

setState

fun <VM : MavericksViewModel<S>, S : MavericksState> setState(viewModel: VM, state: S): Unit

A helper to set a state on a view model via MavericksStateStore.set.