runAjwahTest<State> function

  1. @visibleForTesting
Future<void> runAjwahTest <State>(
  1. String description,
  2. {@required Stream<State> build(
      ),
    1. Function act,
    2. Duration wait,
    3. int skip: 0,
    4. Iterable expect,
    5. dynamic verify(
      1. List<State> models
      ),
    6. Iterable errors,
    7. Function tearDown}
    )

    Internal ajwahTest runner which is only visible for testing. This should never be used directly -- please use ajwahTest instead.

    Implementation

    @visibleForTesting
    Future<void> runAjwahTest<State>(
      String description, {
      @required Stream<State> Function() build,
      Function act,
      Duration wait,
      int skip = 0,
      Iterable expect,
      Function(List<State> models) verify,
      Iterable errors,
      Function tearDown,
    }) async {
      final unhandledErrors = <Object>[];
      await runZoned(
        () async {
          final states = <State>[];
          final stream = build();
          final subscription = stream.skip(skip).listen(states.add);
          await act?.call();
          if (wait != null) await Future<void>.delayed(wait);
          await Future<void>.delayed(Duration.zero);
          if (expect != null) test.expect(states, expect);
          await subscription.cancel();
          await verify?.call(states);
          await tearDown?.call();
        },
        onError: (Object error) {
          unhandledErrors.add(error);
        },
      );
      if (errors != null) test.expect(unhandledErrors, errors);
    }