Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f9ceb9b

Browse files
authoredMar 6, 2025··
Update test/components/button/gf_button_test.dart
1 parent cce2974 commit f9ceb9b

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
 
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
testWidgets('GFButton renders correctly and responds to tap', (WidgetTester tester) async {
7+
bool tapped = false;
8+
await tester.pumpWidget(MaterialApp(
9+
home: Scaffold(
10+
body: GFButton(
11+
text: 'Test Button',
12+
onPressed: () {
13+
tapped = true;
14+
},
15+
),
16+
),
17+
));
18+
19+
// Verify the GFButton renders with correct text
20+
expect(find.text('Test Button'), findsOneWidget);
21+
22+
// Tap the button.
23+
await tester.tap(find.byType(GFButton));
24+
await tester.pump();
25+
26+
expect(tapped, isTrue);
27+
});
28+
29+
testWidgets('GFButton disabled state works correctly', (WidgetTester tester) async {
30+
await tester.pumpWidget(MaterialApp(
31+
home: Scaffold(
32+
body: GFButton(
33+
text: 'Disabled Button',
34+
onPressed: null,
35+
),
36+
),
37+
));
38+
39+
// The button should be disabled, we check that text exists
40+
expect(find.text('Disabled Button'), findsOneWidget);
41+
42+
// Tapping should not trigger anything
43+
await tester.tap(find.byType(GFButton));
44+
await tester.pump();
45+
});
46+
}

0 commit comments

Comments
 (0)
Please sign in to comment.