import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:halkyon_app/halkyon_app.dart'; /// The states [cubit] emits while [step] runs, in order. Future> statesOf( BlocBase cubit, Future Function() step, ) async { final states = []; final listening = cubit.stream.listen(states.add); await step(); // A cubit's stream hands its states on in a microtask. await Future.delayed(Duration.zero); await listening.cancel(); return states; } /// The states [cubit] emits as [step] (not awaited: it emits at once). Future> statesNow(BlocBase cubit, void Function() step) => statesOf(cubit, () async => step()); /// A refusal of [problem]. Matcher refusedAs(PasswordProblem problem) => isA().having( (failed) => failed.problem, 'problem', problem, );