32 lines
1021 B
Dart
32 lines
1021 B
Dart
|
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();
|
||
|
|
||
|
// close the addhabit-dialog, as it was already tested in addhabit_popup.dart
|
||
|
await tester.tap(find.byType(IconButton));
|
||
|
await tester.pumpAndSettle();
|
||
|
});
|
||
|
}
|