Unable to add data to stream while testing using mockito. When I call stream sink function then it throws function call on null. The auth.changeShowProgress(true) return function call on null. How can I add data to the stream in the bloc?
testWidgets('Correct email and password gives success',
(WidgetTester widgetTester) async {
final AuthBloc auth = MockAuthBloc();
when(auth.showProgress).thenReturn(null);
when(auth.changeShowProgress(true)).thenAnswer((_) {
Future.value(null);
});
await widgetTester.pumpWidget(
makeTestableWidget(
authbloc: auth,
child: MaterialApp(home: LoginPage()),
),
);
await widgetTester.pump(Duration.zero);
verify(auth.showProgress).called(1);
expect(find.byType(CircularProgressIndicator), findsOneWidget);
await widgetTester.enterText(
find.bySemanticsLabel("Email address"), "admin@admin.com");
await widgetTester.enterText(find.bySemanticsLabel("Password"), "password");
await widgetTester.tap(find.widgetWithText(PRaisedButton, "Login"));
await widgetTester.pump();
});
Aucun commentaire:
Enregistrer un commentaire