Skip to content

Commit 251bb24

Browse files
committed
test: add widget tests for custom themes in theme_test.dart
1 parent 370e1f4 commit 251bb24

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

test/widgets/theme_test.dart

Lines changed: 75 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,76 @@ void main() {
133136
.isSameColorSwatchAs(ChannelColorSwatch.dark(baseColor));
134137
});
135138
});
139+
140+
group('ZAppBarTheme Tests', () {
141+
testWidgets('Light AppBarThme Test', (tester) async {
142+
final designVariables = DesignVariables.light();
143+
144+
await tester.pumpWidget(GetMaterialApp(
145+
home: Scaffold(
146+
appBar: AppBar(
147+
title: const Text('Test'),
148+
),
149+
),
150+
));
151+
152+
final context = Get.context;
153+
154+
final appBarTheme =
155+
ZAppBarTheme.lightAppBarTheme(context!, designVariables);
156+
157+
expect(appBarTheme.backgroundColor, designVariables.bgTopBar);
158+
expect(appBarTheme.actionsIconTheme!.color, designVariables.icon);
159+
expect(appBarTheme.titleTextStyle!.color, designVariables.title);
160+
expect(appBarTheme.titleTextStyle!.fontSize, 20);
161+
expect(appBarTheme.titleTextStyle!.fontFamily, kDefaultFontFamily);
162+
});
163+
164+
testWidgets('Dark AppBarThem Test', (tester) async {
165+
final designVariables = DesignVariables.dark();
166+
167+
await tester.pumpWidget(GetMaterialApp(
168+
home: Scaffold(
169+
appBar: AppBar(
170+
title: const Text('Test'),
171+
),
172+
),
173+
));
174+
175+
final context = Get.context;
176+
final appBarTheme =
177+
ZAppBarTheme.darkAppBarTheme(context!, designVariables);
178+
179+
expect(appBarTheme.backgroundColor, designVariables.bgTopBar);
180+
expect(appBarTheme.actionsIconTheme!.color, designVariables.icon);
181+
expect(appBarTheme.titleTextStyle!.color, designVariables.title);
182+
expect(appBarTheme.titleTextStyle!.fontSize, 20);
183+
expect(appBarTheme.titleTextStyle!.fontFamily, kDefaultFontFamily);
184+
});
185+
});
186+
187+
testWidgets("Zbutton tests", (tester) async{
188+
final designVariables = DesignVariables.dark();
189+
190+
// Use Get.context to access the context directly
191+
await tester.pumpWidget(
192+
GetMaterialApp(
193+
home: Scaffold(
194+
body: ElevatedButton(
195+
onPressed: () {},
196+
child: const Text('Test Button'),
197+
),
198+
),
199+
),
200+
);
201+
202+
// Act
203+
final elevatedButtonTheme = ZButtonTheme.darkElevatedButtonTheme(designVariables);
204+
205+
// Assert
206+
final elevatedButtonStyle = elevatedButtonTheme.style!;
207+
expect(elevatedButtonStyle.backgroundColor?.resolve({}), designVariables.bgTopBar);
208+
expect(elevatedButtonStyle.foregroundColor?.resolve({}), designVariables.title);
209+
expect(elevatedButtonStyle.elevation?.resolve({}), 4.0);
210+
});
136211
}

0 commit comments

Comments
 (0)