Skip to content

Commit

Permalink
inbox test [nfc]: Extract hasIcon
Browse files Browse the repository at this point in the history
Signed-off-by: Zixuan James Li <[email protected]>
  • Loading branch information
PIG208 committed Dec 10, 2024
1 parent 4c3440b commit 1997ea3
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions test/widgets/inbox_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,17 @@ void main() {
));
}

bool hasIcon(WidgetTester tester, {
required Widget? parent,
required IconData icon,
}) {
check(parent).isNotNull();
return tester.widgetList(find.descendant(
of: find.byWidget(parent!),
matching: find.byIcon(icon),
)).isNotEmpty;
}

group('InboxPage', () {
testWidgets('page builds; empty', (tester) async {
await setupPage(tester, unreadMessages: []);
Expand Down Expand Up @@ -246,13 +257,8 @@ void main() {
final subscription = eg.subscription(stream);
const topic = 'lunch';

bool hasAtSign(WidgetTester tester, Widget? parent) {
check(parent).isNotNull();
return tester.widgetList(find.descendant(
of: find.byWidget(parent!),
matching: find.byIcon(ZulipIcons.at_sign),
)).isNotEmpty;
}
bool hasAtSign(WidgetTester tester, Widget? parent) =>
hasIcon(tester, parent: parent, icon: ZulipIcons.at_sign);

testWidgets('topic with a mention', (tester) async {
await setupPage(tester,
Expand Down

0 comments on commit 1997ea3

Please sign in to comment.