expectDispatched<T> function

void expectDispatched<T>(
  1. ActionDispatcher<T> actionDispatcher, {
  2. void verifier(
    1. Action<T> action
    )?,
  3. int count = 1,
  4. int max = 0,
  5. String? id,
  6. String? reason,
})

expectDispatched verifies that a given action is dispatched at a later time using expectAsync1. It runs the verifier function provided when the action is called so you can perform expects on the payload. It takes all of the same optional params as expectAsync.

Implementation

void expectDispatched<T>(
  ActionDispatcher<T> actionDispatcher, {
  void Function(Action<T> action)? verifier,
  int count = 1,
  int max = 0,
  String? id,
  String? reason,
}) {
  actionDispatcher.setDispatcher(expectAsync1((Action<dynamic> action) {
    if (verifier != null) verifier(action as Action<T>);
  }, count: count, max: max, id: id, reason: reason));
}