@@ -13,36 +13,38 @@ void main() {
13
13
TestZulipBinding .ensureInitialized ();
14
14
15
15
group ('UnreadCountBadge' , () {
16
- testWidgets ('smoke test; no crash' , (tester) async {
16
+ Future <void > prepare (WidgetTester tester, {
17
+ required Widget child,
18
+ }) async {
17
19
addTearDown (testBinding.reset);
18
- await tester.pumpWidget (const TestZulipApp (
19
- child: UnreadCountBadge (count : 1 , backgroundColor : null ) ));
20
+ await tester.pumpWidget (TestZulipApp (
21
+ child: child ));
20
22
await tester.pump ();
23
+ }
24
+
25
+ testWidgets ('smoke test; no crash' , (tester) async {
26
+ await prepare (tester,
27
+ child: UnreadCountBadge (count: 1 , backgroundColor: null ));
21
28
tester.widget (find.text ("1" ));
22
29
});
23
30
24
31
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
-
32
32
Color ? findBackgroundColor (WidgetTester tester) {
33
33
final widget = tester.widget <DecoratedBox >(find.byType (DecoratedBox ));
34
34
final decoration = widget.decoration as BoxDecoration ;
35
35
return decoration.color;
36
36
}
37
37
38
38
testWidgets ('default color' , (tester) async {
39
- await prepare (tester, null );
39
+ await prepare (tester,
40
+ child: UnreadCountBadge (count: 1 , backgroundColor: null ));
40
41
check (findBackgroundColor (tester)).isNotNull ().isSameColorAs (const Color (0x26666699 ));
41
42
});
42
43
43
44
testWidgets ('stream color' , (tester) async {
44
45
final swatch = ChannelColorSwatch .light (0xff76ce90 );
45
- await prepare (tester, swatch);
46
+ await prepare (tester,
47
+ child: UnreadCountBadge (count: 1 , backgroundColor: swatch));
46
48
check (findBackgroundColor (tester)).isNotNull ().isSameColorAs (swatch.unreadCountBadgeBackground);
47
49
});
48
50
});
0 commit comments