runAjwahTest<State> function
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);
}