Skip to content

Commit

Permalink
Merge pull request #95 from ES2-UFPI/kaua
Browse files Browse the repository at this point in the history
Kaua
  • Loading branch information
iuryFilho authored Jan 21, 2025
2 parents 332f4f6 + 65a0c71 commit 4c3d44b
Showing 1 changed file with 30 additions and 16 deletions.
46 changes: 30 additions & 16 deletions healthway_app/test/nutricionista_dashboard_screen_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,37 @@ import 'package:healthway_app/constants.dart';
import 'package:healthway_app/screens_nutricionist/nutritionist_dashboard_screen.dart';

void main() {
final Map<String, dynamic> mockUserData = {
'nome': 'Dr. Silva',
'pacientes': ['João', 'Maria'],
};
testWidgets('NutritionistDashboardScreen displays correctly',
(WidgetTester tester) async {
// Build the NutritionistDashboardScreen widget.
await tester.pumpWidget(MaterialApp(
home: NutritionistDashboardScreen(
userData: mockUserData,
)));
group('NutritionistDashboardScreen', () {
testWidgets('Exibe o cabeçalho corretamente com o nome do usuário', (WidgetTester tester) async {
// Dados simulados para o teste
const String mockUserName = 'Teste Nutricionista';

// Verify if the background color is correct.
final scaffold = tester.widget<Scaffold>(find.byType(Scaffold));
expect(scaffold.backgroundColor, kBackgroundColor);
// Renderiza o widget com dados de teste
await tester.pumpWidget(
MaterialApp(
home: NutritionistDashboardScreen(userData: {'name': mockUserName}),
),
);

// Verify if the Icon widget is present.
expect(find.byType(Scaffold), findsOneWidget);
// Verifica se o texto esperado está presente
expect(find.text('Olá, Nutricionista!'), findsOneWidget);
expect(find.text(mockUserName), findsOneWidget);
});

testWidgets('Não exibe widgets desnecessários ou duplicados', (WidgetTester tester) async {
const String mockUserName = 'Nutricionista Exemplo';

await tester.pumpWidget(
MaterialApp(
home: NutritionistDashboardScreen(userData: {'name': mockUserName}),
),
);

// Verifica que apenas um widget com "Olá, Nutricionista!" existe
expect(find.text('Olá, Nutricionista!'), findsOneWidget);

// Certifica-se de que widgets com textos incorretos não existem
expect(find.text('Texto não esperado'), findsNothing);
});
});
}

0 comments on commit 4c3d44b

Please sign in to comment.