MockStore

public class MockStore<State, Environment> : Store<State, Environment>

A MockStore is intended to be used in unit tests where you want to observe which Actions are dispatched and manipulate the State and Selectors.

  • All the Actions and state changes that has happened.

    Declaration

    Swift

    public var stateChanges: [(action: Action, oldState: State, newState: State)] { get }
  • All the Actions that has been dispatched.

    Declaration

    Swift

    public var dispatchedActions: [Action] { get }
  • Initializes the MockStore with an initial State.

    Declaration

    Swift

    override public init(initialState: State, environment: Environment, reducers: [Reducer<State>] = [])

    Parameters

    initialState

    The initial State for the Store

    reducers

    The Reducers to register

    effects

    The Effects to register

  • Sets a new State on the Store.

    Declaration

    Swift

    public func setState(newState: State)

    Parameters

    newState

    The new State to set on the Store

  • Overrides the Selector with a ‘default’ value.

    When a Selector is overriden it will always give the same value when used to select from this MockStore.

    Declaration

    Swift

    public func overrideSelector<Value>(_ selector: Fluxor.Selector<State, Value>, value: Value)

    Parameters

    selector

    The Selector to override

    value

    The value the Selector should give when selecting

  • Resets all overridden Selectors on this MockStore.

    Declaration

    Swift

    public func resetOverriddenSelectors()
  • Declaration

    Swift

    override public func select<Value>(_ selector: Fluxor.Selector<State, Value>) -> AnyPublisher<Value, Never>
  • Declaration

    Swift

    override public func selectCurrent<Value>(_ selector: Fluxor.Selector<State, Value>) -> Value