From 2b8582ac1a654b7a2e3912ad9dc0ef413fa8f414 Mon Sep 17 00:00:00 2001 From: AhsanSarwar45 Date: Sat, 16 Dec 2023 11:49:11 +0500 Subject: [PATCH] Fix tests for date chips --- lib/common/widgets/fields/date_picker_field.dart | 1 + test/common/widgets/fields/date_picker_field_test.dart | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/common/widgets/fields/date_picker_field.dart b/lib/common/widgets/fields/date_picker_field.dart index 486f4308..1d8a7681 100644 --- a/lib/common/widgets/fields/date_picker_field.dart +++ b/lib/common/widgets/fields/date_picker_field.dart @@ -144,6 +144,7 @@ class DateChip extends StatelessWidget { Widget build(BuildContext context) { ColorScheme colorScheme = Theme.of(context).colorScheme; return CardContainer( + key: const Key("DateChip"), color: colorScheme.primary, margin: const EdgeInsets.all(0), child: Padding( diff --git a/test/common/widgets/fields/date_picker_field_test.dart b/test/common/widgets/fields/date_picker_field_test.dart index cc1a93a7..fbaf5392 100644 --- a/test/common/widgets/fields/date_picker_field_test.dart +++ b/test/common/widgets/fields/date_picker_field_test.dart @@ -17,19 +17,19 @@ void main() { testWidgets('with 1 date', (tester) async { final value = [DateTime(2021, 1, 1)]; await _renderWidget(tester, value: value); - final valueFinder = find.byType(DateChip); + final valueFinder = find.byKey(const Key("DateChip")); expect(valueFinder, findsOneWidget); }); testWidgets('with 2 dates', (tester) async { final value = [DateTime(2021, 1, 1), DateTime(2021, 1, 2)]; await _renderWidget(tester, value: value); - final valueFinder = find.byType(DateChip); + final valueFinder = find.byKey(const Key("DateChip")); expect(valueFinder, findsNWidgets(2)); }); testWidgets('with 10 dates', (tester) async { final value = List.generate(10, (index) => DateTime(2021, 1, 1)); await _renderWidget(tester, value: value); - final valueFinder = find.byType(DateChip); + final valueFinder = find.byKey(const Key("DateChip")); expect(valueFinder, findsNWidgets(10)); }); });