runAjwahTest<State> function Null safety

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

      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,
        Function(List<State> models)? log,
      }) async {
        final unhandledErrors = <Object>[];
        await runZonedGuarded(
          () 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);
            await log?.call(states);
            if (expect != null) test.expect(states, expect);
            await subscription.cancel();
            await verify?.call(states);
            await tearDown?.call();
          },
          (Object error, _) {
            unhandledErrors.add(error);
          },
        );
        if (errors != null) test.expect(unhandledErrors, errors);
      }