@@ -13,36 +13,38 @@ void main() {
1313 TestZulipBinding .ensureInitialized ();
1414
1515 group ('UnreadCountBadge' , () {
16- testWidgets ('smoke test; no crash' , (tester) async {
16+ Future <void > prepare (WidgetTester tester, {
17+ required Widget child,
18+ }) async {
1719 addTearDown (testBinding.reset);
18- await tester.pumpWidget (const TestZulipApp (
19- child: UnreadCountBadge (count : 1 , backgroundColor : null ) ));
20+ await tester.pumpWidget (TestZulipApp (
21+ child: child ));
2022 await tester.pump ();
23+ }
24+
25+ testWidgets ('smoke test; no crash' , (tester) async {
26+ await prepare (tester,
27+ child: UnreadCountBadge (count: 1 , backgroundColor: null ));
2128 tester.widget (find.text ("1" ));
2229 });
2330
2431 group ('background' , () {
25- Future <void > prepare (WidgetTester tester, ChannelColorSwatch ? backgroundColor) async {
26- addTearDown (testBinding.reset);
27- await tester.pumpWidget (TestZulipApp (
28- child: UnreadCountBadge (count: 1 , backgroundColor: backgroundColor)));
29- await tester.pump ();
30- }
31-
3232 Color ? findBackgroundColor (WidgetTester tester) {
3333 final widget = tester.widget <DecoratedBox >(find.byType (DecoratedBox ));
3434 final decoration = widget.decoration as BoxDecoration ;
3535 return decoration.color;
3636 }
3737
3838 testWidgets ('default color' , (tester) async {
39- await prepare (tester, null );
39+ await prepare (tester,
40+ child: UnreadCountBadge (count: 1 , backgroundColor: null ));
4041 check (findBackgroundColor (tester)).isNotNull ().isSameColorAs (const Color (0x26666699 ));
4142 });
4243
4344 testWidgets ('stream color' , (tester) async {
4445 final swatch = ChannelColorSwatch .light (0xff76ce90 );
45- await prepare (tester, swatch);
46+ await prepare (tester,
47+ child: UnreadCountBadge (count: 1 , backgroundColor: swatch));
4648 check (findBackgroundColor (tester)).isNotNull ().isSameColorAs (swatch.unreadCountBadgeBackground);
4749 });
4850 });
0 commit comments