cpd/test/widget_testing/homepage_test.dart

32 lines
1.0 KiB
Dart
Raw Permalink Normal View History

import 'package:cpd/pages/homepage.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:cpd/database/db.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
void main() {
setUpAll(() {
sqfliteFfiInit();
databaseFactory = databaseFactoryFfi;
});
testWidgets('MyHomePage displays correctly', (WidgetTester tester) async {
final mockHabitDatabase = HabitDatabase();
await tester.pumpWidget(MaterialApp(
home: MyHomePage(database: mockHabitDatabase, title: 'homepage'),
));
expect(find.text('step by step, day by day'), findsOneWidget);
expect(find.text('Keep Going!'), findsOneWidget);
expect(find.byType(FloatingActionButton), findsOneWidget);
await tester.tap(find.byType(FloatingActionButton));
await tester.pumpAndSettle();
2024-06-19 16:25:05 +02:00
//schließt das addhabit-dialog, da es schon in addhabit-popup.dart getestet wurde
await tester.tap(find.byType(IconButton));
await tester.pumpAndSettle();
});
}