testYubikiri<T extends Yubikiri<J> , J> function
Future<YubikiriTester<T, J> >
testYubikiri<T extends Yubikiri<J> , J>(
- WidgetTester tester, {
- required T create(),
- Widget parentBuilder()?,
Creates a YubikiriTester that emulates normal flutter widget behavior
On creation it will call init and didChangeDependencies. On the one side you are able to test if the model has the states you are expecting. On the other side you are able to check how often your widget did rebuild.
If there are dependencies that are provided via the BuildContext you can add a parentBuilder, with this you are able to add a BlocProvider for example.
await testViewModel(
tester,
create: () => MyViewModel(),
parentBuilder: (context, child) => MyDependency(
child: child,
)
);
Implementation
Future<YubikiriTester<T, J>> testYubikiri<T extends Yubikiri<J>, J>(
WidgetTester tester, {
required T Function() create,
Widget Function(BuildContext, Widget)? parentBuilder,
}) async {
final viewModelTester = YubikiriTester<T, J>(viewModel: create());
await viewModelTester.init(tester, parentBuilder: parentBuilder);
return viewModelTester;
}