dispatchState method

Future<TestInfo<St>> dispatchState(
  1. St state
)

Dispatches an action that changes the current state to the one provided by you. Then, runs until that action is dispatched and finished (ignoring other actions). Returns the info after the action finishes, containing the given state.

Example use:

var info = await storeTester.dispatchState(MyState(123)); expect(info.state, MyState(123));

Implementation

Future<TestInfo<St>> dispatchState(St state) async {
  var action = _NewStateAction(state);
  dispatch(action);

  TestInfo<St>? testInfo;

  while (testInfo == null || !identical(testInfo.action, action) || testInfo.isINI) {
    testInfo = await _next();
  }

  lastInfo = testInfo;

  return testInfo;
}