Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Unittests for lib/widgets/event_card.dart #2669

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions test/widget_tests/widgets/event_card_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ void main() {
testSetupLocator();
});

tearDown(() {
userConfig.currentUser.id = null;
});

group("Test for EventCard widget", () {
testWidgets('Check if Event Card shows up', (tester) async {
mockNetworkImages(() async {
Expand Down Expand Up @@ -195,5 +199,37 @@ 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(
'should not show Created row and verified icon when current user is not the event creator',
(tester) async {
mockNetworkImages(() async {
final event = getEvent();
userConfig.currentUser.id = "nonCreatorId";
await tester.pumpWidget(createCustomEventCard(event));
await tester.pump();
final BuildContext ctx = tester.element(find.byType(EventCard));
expect(find.byIcon(Icons.verified), findsNothing);
expect(
find.text(AppLocalizations.of(ctx)!.strictTranslate('Created')),
findsNothing,
);
});
});
});
}
Loading