Skip to content

Commit a5b46c6

Browse files
committed
test: Add widget tests for custom themes in theme_test.dart
1 parent 68a83e7 commit a5b46c6

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

test/widgets/theme_test.dart

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import 'package:checks/checks.dart';
22
import 'package:flutter/material.dart';
33
import 'package:flutter/rendering.dart';
44
import 'package:flutter_test/flutter_test.dart';
5+
import 'package:get/get.dart';
6+
import 'package:zulip/themes/appbar_theme.dart';
7+
import 'package:zulip/themes/elevated_button_theme.dart';
58
import 'package:zulip/widgets/channel_colors.dart';
69
import 'package:zulip/widgets/text.dart';
710
import 'package:zulip/widgets/theme.dart';
@@ -133,4 +136,77 @@ void main() {
133136
.isSameColorSwatchAs(ChannelColorSwatch.dark(baseColor));
134137
});
135138
});
139+
140+
141+
group('ZAppBarTheme Tests', () {
142+
testWidgets('Light AppBarThme Test', (tester) async {
143+
final designVariables = DesignVariables.light();
144+
145+
await tester.pumpWidget(GetMaterialApp(
146+
home: Scaffold(
147+
appBar: AppBar(
148+
title: const Text('Test'),
149+
),
150+
),
151+
));
152+
153+
final context = Get.context;
154+
155+
final appBarTheme =
156+
ZAppBarTheme.lightAppBarTheme(context!, designVariables);
157+
158+
expect(appBarTheme.backgroundColor, designVariables.bgTopBar);
159+
expect(appBarTheme.actionsIconTheme!.color, designVariables.icon);
160+
expect(appBarTheme.titleTextStyle!.color, designVariables.title);
161+
expect(appBarTheme.titleTextStyle!.fontSize, 20);
162+
expect(appBarTheme.titleTextStyle!.fontFamily, kDefaultFontFamily);
163+
});
164+
165+
testWidgets('Dark AppBarThem Test', (tester) async {
166+
final designVariables = DesignVariables.dark();
167+
168+
await tester.pumpWidget(GetMaterialApp(
169+
home: Scaffold(
170+
appBar: AppBar(
171+
title: const Text('Test'),
172+
),
173+
),
174+
));
175+
176+
final context = Get.context;
177+
final appBarTheme =
178+
ZAppBarTheme.darkAppBarTheme(context!, designVariables);
179+
180+
expect(appBarTheme.backgroundColor, designVariables.bgTopBar);
181+
expect(appBarTheme.actionsIconTheme!.color, designVariables.icon);
182+
expect(appBarTheme.titleTextStyle!.color, designVariables.title);
183+
expect(appBarTheme.titleTextStyle!.fontSize, 20);
184+
expect(appBarTheme.titleTextStyle!.fontFamily, kDefaultFontFamily);
185+
});
186+
});
187+
188+
testWidgets("Zbutton tests", (tester) async{
189+
final designVariables = DesignVariables.dark();
190+
191+
// Use Get.context to access the context directly
192+
await tester.pumpWidget(
193+
GetMaterialApp(
194+
home: Scaffold(
195+
body: ElevatedButton(
196+
onPressed: () {},
197+
child: const Text('Test Button'),
198+
),
199+
),
200+
),
201+
);
202+
203+
// Act
204+
final elevatedButtonTheme = ZButtonTheme.darkElevatedButtonTheme(designVariables);
205+
206+
// Assert
207+
final elevatedButtonStyle = elevatedButtonTheme.style!;
208+
expect(elevatedButtonStyle.backgroundColor?.resolve({}), designVariables.bgTopBar);
209+
expect(elevatedButtonStyle.foregroundColor?.resolve({}), designVariables.title);
210+
expect(elevatedButtonStyle.elevation?.resolve({}), 4.0);
211+
});
136212
}

0 commit comments

Comments
 (0)