mvrx-mocking / com.airbnb.mvrx.mocking / MockStateHolder

MockStateHolder

class MockStateHolder

Used to mock the initial state value of a viewmodel.

Types

ViewModelDelegateInfo

data class ViewModelDelegateInfo<VM : MavericksViewModel<S>, S : MavericksState>

Constructors

<init>

MockStateHolder()

Used to mock the initial state value of a viewmodel.

Functions

addViewModelDelegate

fun <VM : MavericksViewModel<S>, S : MavericksState> addViewModelDelegate(view: MockableMavericksView, existingViewModel: Boolean, viewModelProperty: KProperty<*>, viewModelDelegate: lifecycleAwareLazy<VM>): Unit

clearAllMocks

fun clearAllMocks(): Unit

clearMock

fun clearMock(view: MockableMavericksView): Unit

Clear the stored mock info for the given view. This should be called after the view is done initializing itself with the mock. This should be done to prevent leaking references to the view and its mocks.

getMockedState

fun <S : MavericksState> getMockedState(view: MockableMavericksView, viewModelProperty: KProperty<*>, existingViewModel: Boolean, stateClass: Class<S>, forceMockExistingViewModel: Boolean): S?

Get the mocked state for the viewmodel on the given view. Returns null if no mocked state has been set - this is valid if a view under mock contains nested views that are not under mock.

setMock

fun <V : MockableMavericksView, A : Parcelable> setMock(view: MockableMavericksView, mockInfo: MavericksMock<V, A>): Unit

Set mock data for a view reference. The mocks will be used to provide initial state when the view models are initialized as the view is started.