Skip to content

Commit

Permalink
add Unittests for lib/widgets/event_card.dart
Browse files Browse the repository at this point in the history
  • Loading branch information
sayyad-asifbasha committed Dec 17, 2024
1 parent e73d1c1 commit 6d9e297
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/widget_tests/widgets/event_card_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -195,5 +195,36 @@ void main() {
expect(find.text("1"), findsOneWidget);
});
});

testWidgets('Check for Created Row visibility', (tester) async {
mockNetworkImages(() async {
final event = getEvent();
userConfig.currentUser.id = event.creator!.id;
await tester.pumpWidget(createCustomEventCard(event));
await tester.pump();
final BuildContext ctx = tester.element(find.byType(EventCard));
expect(find.byIcon(Icons.verified), findsOneWidget);
expect(
find.text(AppLocalizations.of(ctx)!.strictTranslate('Created')),
findsOneWidget,
);
});
});

testWidgets('Check for absence of Created Row for non-creators',
(tester) async {
mockNetworkImages(() async {
final event = getEvent();
userConfig.currentUser.id = "nonCreatorId";
await tester.pumpWidget(createCustomEventCard(event));
await tester.pumpAndSettle();
final BuildContext ctx = tester.element(find.byType(EventCard));
expect(find.byIcon(Icons.verified), findsNothing);
expect(
find.text(AppLocalizations.of(ctx)!.strictTranslate('Created')),
findsNothing,
);
});
});
});
}

0 comments on commit 6d9e297

Please sign in to comment.