Package 

Class TwoViewModelMockBuilder

    • Method Summary

      Modifier and Type Method Description
      <ERROR CLASS> getMocks() A list of mocks to use when testing a view.
      List<List<MavericksMock<V, out Args>>> getMockGroups()
      final Unit state(String name, Function1<Args, Args> args, Function1<TwoStatesBuilder<V, S1, VM1, S2, VM2>, Unit> statesBuilder) Provide state objects for each view model in the view.
      final <T extends Any, A extends Async<T>> Unit viewModel1StateForLoadingAndFailure(S1 state, Function1<S1, KProperty0<A>> asyncPropertyBlock) Helper to mock the loading and failure state of an Async property on your state in the first view model.
      final <T extends Any, A extends Async<T>> Unit viewModel2StateForLoadingAndFailure(S2 state, Function1<S2, KProperty0<A>> asyncPropertyBlock) Helper to mock the loading and failure state of an Async property on your state in the second view model.
      • Methods inherited from class com.airbnb.mvrx.mocking.TwoViewModelMockBuilder

        args
      • Methods inherited from class com.airbnb.mvrx.mocking.MockBuilder

        invoke, set, setEmpty, setFalse, setLoading, setNetworkFailure, setNull, setTrue, setZero, success, validate, with
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getMocks

         <ERROR CLASS> getMocks()

        A list of mocks to use when testing a view. Each mock represents a unique state to be tested.

        At least one of mocks or mockGroups must be implemented.

      • state

         final Unit state(String name, Function1<Args, Args> args, Function1<TwoStatesBuilder<V, S1, VM1, S2, VM2>, Unit> statesBuilder)

        Provide state objects for each view model in the view.

        The DSL provided by DataClassSetDsl can be used for simpler state modification.

        Mock variations should test alterations to the "default" state, with each variant testing a minimal difference (ideally only one change). For example, a variant may test that a single property is null or empty.

        Parameters:
        name - Describes the UI these states put the view in.
        args - The arguments that should be provided to the view.
        statesBuilder - A lambda that is used to define state objects for each view model.
      • viewModel1StateForLoadingAndFailure

         final <T extends Any, A extends Async<T>> Unit viewModel1StateForLoadingAndFailure(S1 state, Function1<S1, KProperty0<A>> asyncPropertyBlock)

        Helper to mock the loading and failure state of an Async property on your state in the first view model. Creates two different mocked states stemmed from the given state - one where the async property is set to Loading and one where it is set to Fail.

      • viewModel2StateForLoadingAndFailure

         final <T extends Any, A extends Async<T>> Unit viewModel2StateForLoadingAndFailure(S2 state, Function1<S2, KProperty0<A>> asyncPropertyBlock)

        Helper to mock the loading and failure state of an Async property on your state in the second view model. Creates two different mocked states stemmed from the given state - one where the async property is set to Loading and one where it is set to Fail.