49 lines
1.5 KiB
Dart
49 lines
1.5 KiB
Dart
|
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/content_widgets/footer.dart';
|
||
|
|
||
|
import '../../helpers/beet_repository_generator.dart';
|
||
|
|
||
|
void main() {
|
||
|
late BeetRepository beetRepository;
|
||
|
late DateTime currentDate;
|
||
|
late Function(DateTime) mockOnNewDaySelected;
|
||
|
DateTime selectedPickerDate = DateTime(2023, 1, 1);
|
||
|
|
||
|
setUp(() {
|
||
|
beetRepository = BeetRepositoryGenerator.getBeetRepository();
|
||
|
currentDate = DateTime.now();
|
||
|
currentDate =
|
||
|
DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day);
|
||
|
|
||
|
mockOnNewDaySelected = (DateTime selectedDate) {
|
||
|
selectedPickerDate = selectedDate;
|
||
|
};
|
||
|
});
|
||
|
|
||
|
testWidgets('Displays elements Date select works',
|
||
|
(WidgetTester tester) async {
|
||
|
//Arrange
|
||
|
await tester.pumpWidget(
|
||
|
MaterialApp(
|
||
|
home: Scaffold(
|
||
|
body: Footer(
|
||
|
onNewDaySelected: mockOnNewDaySelected,
|
||
|
beetRepository: beetRepository,
|
||
|
date: currentDate,
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
);
|
||
|
|
||
|
expect(find.byType(Slider), findsOneWidget);
|
||
|
expect(selectedPickerDate, DateTime(2023, 1, 1));
|
||
|
await tester.tap(find.byType(IconButton));
|
||
|
await tester.pumpAndSettle();
|
||
|
await tester.tap(find.text('OK'));
|
||
|
await tester.pumpAndSettle();
|
||
|
expect(selectedPickerDate, equals(currentDate), reason: 'Datepicker works');
|
||
|
});
|
||
|
}
|