Skip to content

Commit 47e2a3b

Browse files
authored
Merge pull request #206 from shravyackm/gftypography_testing
Gftypography testing
2 parents 0a9e55f + c0c1925 commit 47e2a3b

File tree

2 files changed

+119
-3
lines changed

2 files changed

+119
-3
lines changed

pubspec.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ packages:
7373
name: meta
7474
url: "https://pub.dartlang.org"
7575
source: hosted
76-
version: "1.3.0-nullsafety.4"
76+
version: "1.3.0-nullsafety.3"
7777
path:
7878
dependency: transitive
7979
description:
@@ -99,7 +99,7 @@ packages:
9999
name: stack_trace
100100
url: "https://pub.dartlang.org"
101101
source: hosted
102-
version: "1.10.0-nullsafety.2"
102+
version: "1.10.0-nullsafety.1"
103103
stream_channel:
104104
dependency: transitive
105105
description:
@@ -143,4 +143,4 @@ packages:
143143
source: hosted
144144
version: "2.1.0-nullsafety.3"
145145
sdks:
146-
dart: ">=2.10.0-110 <=2.11.0-213.1.beta"
146+
dart: ">=2.10.0-110 <2.11.0"

test/typography_test.dart

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_test/flutter_test.dart';
3+
import 'package:getwidget/getwidget.dart';
4+
5+
void main() {
6+
final Widget childWidget = Container(
7+
width: 11,
8+
height: 22,
9+
);
10+
11+
const icon = Icon(Icons.home);
12+
const text = 'Hello';
13+
14+
const dividerRadius = BorderRadius.all(Radius.circular(2));
15+
const textcolor = GFColors.INFO;
16+
const dividerposition = Alignment.center;
17+
18+
testWidgets('GFTypograpgy can be created', (WidgetTester tester) async {
19+
final GFTypography typography = GFTypography(
20+
icon: icon,
21+
dividerBorderRadius: dividerRadius,
22+
text: text,
23+
textColor: textcolor,
24+
dividerAlignment: dividerposition,
25+
type: GFTypographyType.typo2,
26+
child: childWidget,
27+
);
28+
29+
final TestApp app = TestApp(typography);
30+
31+
await tester.pumpWidget(app);
32+
33+
await tester.pumpWidget(Container(child: childWidget));
34+
expect(find.byWidget(childWidget), findsOneWidget);
35+
36+
expect(app.typography.child, childWidget);
37+
expect(app.typography.icon, icon);
38+
expect(app.typography.dividerAlignment, Alignment.center);
39+
expect(app.typography.dividerBorderRadius, dividerRadius);
40+
expect(app.typography.textColor, textcolor);
41+
});
42+
43+
testWidgets('GF Typography with divider', (tester) async {
44+
const bool divider = true;
45+
46+
const GFTypography typography = GFTypography(
47+
showDivider: divider,
48+
);
49+
50+
const TestApp app = TestApp(typography);
51+
52+
expect(app.typography.showDivider, divider);
53+
});
54+
55+
testWidgets('GF Typography with opacity', (tester) async {
56+
final textopacity = Colors.black.withOpacity(0.56);
57+
58+
final GFTypography typography = GFTypography(
59+
textColor: textopacity,
60+
);
61+
62+
final TestApp app = TestApp(typography);
63+
64+
expect(app.typography.textColor, textopacity);
65+
});
66+
67+
testWidgets('GF Typography with Custom Heading', (tester) async {
68+
final textopacity = Colors.black.withOpacity(0.56);
69+
const bool divider = true;
70+
const icon = GFAvatar();
71+
const colorfilter = ColorFilter.mode(Colors.black, BlendMode.darken);
72+
const bgImage = NetworkImage(
73+
'https://images.unsplash.com/photo-1547721064-da6cfb341d50',
74+
);
75+
76+
final GFTypography typography = GFTypography(
77+
textColor: textopacity,
78+
showDivider: divider,
79+
icon: icon,
80+
backgroundImage: bgImage,
81+
backgroundImagecolorFilter: colorfilter,
82+
);
83+
84+
final TestApp app = TestApp(typography);
85+
86+
expect(app.typography.textColor, textopacity);
87+
expect(app.typography.showDivider, divider);
88+
expect(app.typography.icon, icon);
89+
expect(app.typography.backgroundImage, bgImage);
90+
expect(app.typography.backgroundImagecolorFilter, colorfilter);
91+
});
92+
}
93+
94+
class TestApp extends StatefulWidget {
95+
const TestApp(this.typography);
96+
97+
final GFTypography typography;
98+
99+
@override
100+
_TestAppState createState() => _TestAppState();
101+
}
102+
103+
class _TestAppState extends State<TestApp> {
104+
@override
105+
Widget build(BuildContext context) => MaterialApp(
106+
home: Scaffold(
107+
body: Column(
108+
children: [
109+
Expanded(
110+
child: widget.typography,
111+
)
112+
],
113+
),
114+
),
115+
);
116+
}

0 commit comments

Comments
 (0)