From f9ceb9bc866c26bde6ed9baabfd211fc409cce20 Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Thu, 6 Mar 2025 23:43:15 +0000 Subject: [PATCH] Update test/components/button/gf_button_test.dart --- test/components/button/gf_button_test.dart | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 test/components/button/gf_button_test.dart diff --git a/test/components/button/gf_button_test.dart b/test/components/button/gf_button_test.dart new file mode 100644 index 00000000..bc4cda9a --- /dev/null +++ b/test/components/button/gf_button_test.dart @@ -0,0 +1,46 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:getwidget/getwidget.dart'; + +void main() { + testWidgets('GFButton renders correctly and responds to tap', (WidgetTester tester) async { + bool tapped = false; + await tester.pumpWidget(MaterialApp( + home: Scaffold( + body: GFButton( + text: 'Test Button', + onPressed: () { + tapped = true; + }, + ), + ), + )); + + // Verify the GFButton renders with correct text + expect(find.text('Test Button'), findsOneWidget); + + // Tap the button. + await tester.tap(find.byType(GFButton)); + await tester.pump(); + + expect(tapped, isTrue); + }); + + testWidgets('GFButton disabled state works correctly', (WidgetTester tester) async { + await tester.pumpWidget(MaterialApp( + home: Scaffold( + body: GFButton( + text: 'Disabled Button', + onPressed: null, + ), + ), + )); + + // The button should be disabled, we check that text exists + expect(find.text('Disabled Button'), findsOneWidget); + + // Tapping should not trigger anything + await tester.tap(find.byType(GFButton)); + await tester.pump(); + }); +}