mirror of
https://github.com/nisrulz/flutter-examples.git
synced 2025-11-09 04:58:58 +00:00
New Example - Calendar (#91)
This commit is contained in:
31
flutter_date_pickers-master/test/day_selectable_test.dart
Normal file
31
flutter_date_pickers-master/test/day_selectable_test.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
import 'package:flutter_date_pickers/src/day_type.dart';
|
||||
import 'package:flutter_date_pickers/src/i_selectable_picker.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'date_time_utils.dart';
|
||||
|
||||
void main() {
|
||||
group("DaySelectable test.", () {
|
||||
test("getDayType() returns correct type for different dates", () {
|
||||
final selectedDate = DateTime.now();
|
||||
final firstDate = selectedDate.subtract(const Duration(days: 10));
|
||||
final lastDate = selectedDate.add(const Duration(days: 10));
|
||||
final disabledDate = selectedDate.subtract(const Duration(days: 1));
|
||||
|
||||
// ignore: prefer_function_declarations_over_variables
|
||||
final selectablePredicate = (DateTime d)
|
||||
=> !DateTimeUtils.sameDate(d, disabledDate);
|
||||
|
||||
final selectableLogic = DaySelectable(
|
||||
selectedDate, firstDate, lastDate,
|
||||
selectableDayPredicate: selectablePredicate);
|
||||
final selectedDateType = selectableLogic.getDayType(selectedDate);
|
||||
final notSelectedEnabledDateType = selectableLogic.getDayType(firstDate);
|
||||
final disabledDateType = selectableLogic.getDayType(disabledDate);
|
||||
|
||||
expect(selectedDateType, DayType.single);
|
||||
expect(notSelectedEnabledDateType, DayType.notSelected);
|
||||
expect(disabledDateType, DayType.disabled);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user