Skip to content

GitAuto: Add widget tests for all the files under lib/components/badge/ #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions lib/components/badge/gf_button_badge.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'package:flutter/material.dart';
import 'package:getwidget/getwidget.dart';

class GFButtonBadge extends StatefulWidget {
class GFBadgeButton extends StatefulWidget {
/// Create badges badges of all types. check out [GFIconButton] for icon badges, and [GFBadge] for badges
const GFButtonBadge({
const GFBadgeButton({
Key? key,
required this.onPressed,
this.onHighlightChanged,
Expand Down Expand Up @@ -214,10 +214,10 @@ class GFButtonBadge extends StatefulWidget {
final Widget? icon;

@override
_GFButtonBadgeState createState() => _GFButtonBadgeState();
_GFBadgeButtonState createState() => _GFBadgeButtonState();
}

class _GFButtonBadgeState extends State<GFButtonBadge> {
class _GFBadgeButtonState extends State<GFBadgeButton> {
@override
Widget build(BuildContext context) => ConstrainedBox(
constraints: const BoxConstraints(
Expand Down
2 changes: 1 addition & 1 deletion lib/components/badge/gf_icon_badge.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:getwidget/getwidget.dart';

class GFIconBadge extends StatefulWidget {
class GFBadgeIcon extends StatefulWidget {
/// Create badges of all types, check out [GFBadge] for button badges and [GFIconBadge] for icon badges.
const GFIconBadge(
{Key? key,
Expand Down
4 changes: 1 addition & 3 deletions test/components/badge/gf_badge_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ void main() {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: GFBadge(
text: 'Test Badge',
),
body: GFBadge(text: 'Test Badge'),
),
),
);
Expand Down
28 changes: 28 additions & 0 deletions test/components/badge/gf_button_badge_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:getwidget/components/badge/gf_button_badge.dart';

void main() {
testWidgets('GFBadgeButton displays text when provided', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: GFBadgeButton(text: 'Button Badge', onPressed: () {}),
),
),
);
expect(find.text('Button Badge'), findsOneWidget);
});

testWidgets('GFBadgeButton displays child widget when no text is provided', (WidgetTester tester) async {
final childKey = Key('child_key');
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: GFBadgeButton(icon: Container(key: childKey), onPressed: () {}),
),
),
);
expect(find.byKey(childKey), findsOneWidget);
});
}
27 changes: 27 additions & 0 deletions test/components/badge/gf_icon_badge_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:getwidget/getwidget.dart';

void main() {
testWidgets('GFIconBadge displays an icon when provided', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: GFIconBadge(child: Icon(Icons.star), counterChild: Container()),
),
),
);
expect(find.byIcon(Icons.star), findsOneWidget);
});

testWidgets('GFIconBadge displays an icon with default properties', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: GFIconBadge(child: Icon(Icons.favorite), counterChild: Container()),
),
),
);
expect(find.byIcon(Icons.favorite), findsOneWidget);
});
}
Loading