Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ packages:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.4"
version: "1.3.0-nullsafety.3"
path:
dependency: transitive
description:
Expand All @@ -99,7 +99,7 @@ packages:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.0-nullsafety.2"
version: "1.10.0-nullsafety.1"
stream_channel:
dependency: transitive
description:
Expand Down Expand Up @@ -143,4 +143,4 @@ packages:
source: hosted
version: "2.1.0-nullsafety.3"
sdks:
dart: ">=2.10.0-110 <=2.11.0-213.1.beta"
dart: ">=2.10.0-110 <2.11.0"
116 changes: 116 additions & 0 deletions test/typography_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:getwidget/getwidget.dart';

void main() {
final Widget childWidget = Container(
width: 11,
height: 22,
);

const icon = Icon(Icons.home);
const text = 'Hello';

const dividerRadius = BorderRadius.all(Radius.circular(2));
const textcolor = GFColors.INFO;
const dividerposition = Alignment.center;

testWidgets('GFTypograpgy can be created', (WidgetTester tester) async {
final GFTypography typography = GFTypography(
icon: icon,
dividerBorderRadius: dividerRadius,
text: text,
textColor: textcolor,
dividerAlignment: dividerposition,
type: GFTypographyType.typo2,
child: childWidget,
);

final TestApp app = TestApp(typography);

await tester.pumpWidget(app);

await tester.pumpWidget(Container(child: childWidget));
expect(find.byWidget(childWidget), findsOneWidget);

expect(app.typography.child, childWidget);
expect(app.typography.icon, icon);
expect(app.typography.dividerAlignment, Alignment.center);
expect(app.typography.dividerBorderRadius, dividerRadius);
expect(app.typography.textColor, textcolor);
});

testWidgets('GF Typography with divider', (tester) async {
const bool divider = true;

const GFTypography typography = GFTypography(
showDivider: divider,
);

const TestApp app = TestApp(typography);

expect(app.typography.showDivider, divider);
});

testWidgets('GF Typography with opacity', (tester) async {
final textopacity = Colors.black.withOpacity(0.56);

final GFTypography typography = GFTypography(
textColor: textopacity,
);

final TestApp app = TestApp(typography);

expect(app.typography.textColor, textopacity);
});

testWidgets('GF Typography with Custom Heading', (tester) async {
final textopacity = Colors.black.withOpacity(0.56);
const bool divider = true;
const icon = GFAvatar();
const colorfilter = ColorFilter.mode(Colors.black, BlendMode.darken);
const bgImage = NetworkImage(
'https://images.unsplash.com/photo-1547721064-da6cfb341d50',
);

final GFTypography typography = GFTypography(
textColor: textopacity,
showDivider: divider,
icon: icon,
backgroundImage: bgImage,
backgroundImagecolorFilter: colorfilter,
);

final TestApp app = TestApp(typography);

expect(app.typography.textColor, textopacity);
expect(app.typography.showDivider, divider);
expect(app.typography.icon, icon);
expect(app.typography.backgroundImage, bgImage);
expect(app.typography.backgroundImagecolorFilter, colorfilter);
});
}

class TestApp extends StatefulWidget {
const TestApp(this.typography);

final GFTypography typography;

@override
_TestAppState createState() => _TestAppState();
}

class _TestAppState extends State<TestApp> {
@override
Widget build(BuildContext context) => MaterialApp(
home: Scaffold(
body: Column(
children: [
Expanded(
child: widget.typography,
)
],
),
),
);
}