Skip to content

Commit

Permalink
test(#58): melhora casos de test da view
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielCostaDeOliveira committed Dec 23, 2024
1 parent 0e6095a commit 13ac32f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions test/ui/login/view/login_view_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ void main() {
mockViewModel = MockLoginViewModel();
when(mockViewModel.formKey).thenReturn(GlobalKey<FormState>());
when(mockViewModel.emailController).thenReturn(TextEditingController());
when(mockViewModel.isLoading).thenReturn(false);
});

testWidgets('Displays loading screen while waiting for Future',
Expand All @@ -42,8 +41,9 @@ void main() {
expect(find.byType(CircularProgressIndicator), findsNothing);
});


testWidgets('login with auth device', (WidgetTester tester) async {
when(mockViewModel.loginWithDeviceAuth()).thenAnswer((_) async => true);
when(mockViewModel.loginWithDeviceAuth()).thenAnswer((_) async => false);

await tester.pumpWidget(
ChangeNotifierProvider<LoginViewModel>.value(
Expand All @@ -56,9 +56,14 @@ void main() {

await tester.pumpAndSettle();

verify(mockViewModel.loginWithDeviceAuth()).called(1);
when(mockViewModel.loginWithDeviceAuth()).thenAnswer((_) async => true);
final button = find.text('Usar senha do celular');
expect(button, findsOneWidget);
await tester.tap(button);

await tester.pumpAndSettle();

verify(mockViewModel.goToHome()).called(1);
verify(mockViewModel.loginWithDeviceAuth()).called(2);
});
}

0 comments on commit 13ac32f

Please sign in to comment.