Skip to content

Commit

Permalink
qa(#59): Adiciona dublê ao teste
Browse files Browse the repository at this point in the history
  • Loading branch information
EngDann committed Dec 19, 2024
1 parent 44f1cd1 commit 763be4f
Showing 1 changed file with 40 additions and 11 deletions.
51 changes: 40 additions & 11 deletions test/ui/register_account/view/RegisterAccount_test.dart
Original file line number Diff line number Diff line change
@@ -1,21 +1,44 @@
import 'package:aranduapp/ui/register_account/viewModel/RegisterViewModel.dart';
import 'package:aranduapp/ui/shared/TextEmail.dart';
import 'package:aranduapp/ui/shared/TextName.dart';
import 'package:aranduapp/ui/shared/TextPassword.dart';
import 'package:aranduapp/ui/shared/TitleSlogan.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:aranduapp/ui/register_account/view/RegisterAccount.dart';
import 'package:provider/provider.dart';

class DubleRegisterAccountViewModel extends RegisterAccountViewModel {
@override
Future<void> register() async {
isLoading = true;
notifyListeners();
await Future.delayed(const Duration(milliseconds: 500));
isLoading = false;
notifyListeners();
}
}

void main() {
group('RegisterAccount Widget Tests', () {
late DubleRegisterAccountViewModel fakeViewModel;

setUp(() {
fakeViewModel = DubleRegisterAccountViewModel();
});

testWidgets('Verifica se os widgets básicos estão presentes',
(WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: RegisterAccount(),
ChangeNotifierProvider<RegisterAccountViewModel>.value(
value: fakeViewModel,
child: const MaterialApp(
home: RegisterAccount(),
),
),
);
// Verifica a presença dos itens.

// Verifica a presença dos itens
expect(find.byType(TitleSlogan), findsOneWidget);
expect(find.byType(TextName), findsNWidgets(2));
expect(find.byType(TextEmail), findsOneWidget);
Expand All @@ -26,8 +49,11 @@ void main() {
testWidgets('Interação com o formulário de registro',
(WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: RegisterAccount(),
ChangeNotifierProvider<RegisterAccountViewModel>.value(
value: fakeViewModel,
child: const MaterialApp(
home: RegisterAccount(),
),
),
);

Expand All @@ -49,24 +75,27 @@ void main() {
// Interação com o checkbox
await tester.tap(find.byType(Checkbox));
await tester.pump();
expect(tester.widget<Checkbox>(find.byType(Checkbox)).value, isTrue);
expect(fakeViewModel.isTermsAccepted, isTrue);

// Interações com o botão
// Interação com o botão
await tester.tap(find.byType(ElevatedButton));
await tester.pump();

expect(find.byType(CircularProgressIndicator), findsOneWidget);
expect(fakeViewModel.isLoading, isTrue);
});

testWidgets('Teste do botão de login com o Google',
(WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: RegisterAccount(),
ChangeNotifierProvider<RegisterAccountViewModel>.value(
value: fakeViewModel,
child: const MaterialApp(
home: RegisterAccount(),
),
),
);

// Interações com o botão do google
// Interação com o botão do Google
final googleButton = find.byType(GestureDetector);
expect(googleButton, findsOneWidget);

Expand Down

0 comments on commit 763be4f

Please sign in to comment.