TestStore<State, Action, Environment> class
A testing wrapper around Store that records all dispatched actions and state changes for easy assertions.
Use TestStore to verify that your reducer produces the expected state
transitions and effects in response to actions.
Example
final testStore = TestStore(0, counterReducer, null);
testStore.send(CounterAction.increment);
expect(testStore.states, [0, 1]);
expect(testStore.actions, [CounterAction.increment]);
testStore.send(
CounterAction.increment,
expected: (state) => expect(state, 2),
);
Constructors
Properties
-
actions
↔ List<
Action> -
All actions that have been dispatched to this store, in order.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
states
↔ List<
State> -
All state values observed by this store, in order.
getter/setter pair
Methods
-
checkState(
void expected(State)) → void -
Asserts the current state using the
expectedcallback. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
send(
Action action, {void expected(State)?}) → void -
Dispatches an
actionand optionally asserts the resulting state viaexpected. -
sendSequence(
List< (Action, Duration)> actions) → Future<void> - Dispatches a sequence of actions with delays between each.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited