GardenPlanner/test/widgets/sidebar_test.dart

33 lines
937 B
Dart
Raw Permalink Normal View History

2023-06-25 10:13:39 +02:00
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:garden_planner/repositories/beet.repositories.dart';
import 'package:garden_planner/widgets/sidebar.dart';
import '../helpers/beet_repository_generator.dart';
void main() {
testWidgets('Sidebar widget displays all items', (WidgetTester tester) async {
//Arrange
BeetRepository repo = BeetRepositoryGenerator.getBeetRepository();
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Sidebar(
beetRepository: repo,
),
),
),
);
//Act
await tester.pumpAndSettle(const Duration(seconds: 5));
//Assert
expect(find.text('Verfügbare Pflanzen'), findsOneWidget);
expect(find.byType(Divider), findsOneWidget);
expect(find.byType(Image), findsNWidgets(2),
reason: 'The image of the plants should be displayed');
});
}