Skip to content

Commit

Permalink
test: ensure NextEventPage hide goalkeepers section
Browse files Browse the repository at this point in the history
  • Loading branch information
hmartiins committed Jan 4, 2025
1 parent a78e760 commit 9a1bacb
Showing 1 changed file with 38 additions and 5 deletions.
43 changes: 38 additions & 5 deletions test/ui/pages/next_event_page_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@ class _NextEventPageState extends State<NextEventPage> {
if (snapshot.hasError) {
return const Text('Erro');
}

final viewModel = snapshot.data!;
return ListView(
children: [
const Text('DENTRO - GOLEIROS'),
Text(snapshot.data!.goalkeepers.length.toString()),
...snapshot.data!.goalkeepers.map(
(player) => Text(player.name),
),
if (viewModel.goalkeepers.isNotEmpty)
ListSection(
title: 'DENTRO - GOLEIROS',
items: viewModel.goalkeepers,
),
],
);
},
Expand All @@ -66,6 +68,30 @@ class _NextEventPageState extends State<NextEventPage> {
}
}

final class ListSection extends StatelessWidget {
final String title;
final List<NextEventPlayerViewModel> items;

const ListSection({
super.key,
required this.title,
required this.items,
});

@override
Widget build(BuildContext context) {
return Column(
children: [
Text(title),
Text(items.length.toString()),
...items.map(
(player) => Text(player.name),
),
],
);
}
}

abstract class NextEventPresenter {
Stream<NextEventViewModel> get nextEventStream;
void loadNextEvent({required String groupId});
Expand Down Expand Up @@ -156,4 +182,11 @@ void main() {
expect(find.text('Rafael'), findsOne);
expect(find.text('Isaac'), findsOne);
});

testWidgets('should hide all sections', (tester) async {
await tester.pumpWidget(sut);
presenter.emitNextEvent();
await tester.pump();
expect(find.text('DENTRO - GOLEIROS'), findsNothing);
});
}

0 comments on commit 9a1bacb

Please sign in to comment.