diff --git a/test/widget_timer_button_test.dart b/test/widget_timer_button_test.dart new file mode 100644 index 0000000..6491896 --- /dev/null +++ b/test/widget_timer_button_test.dart @@ -0,0 +1,35 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:smoke_cess_app/widgets/timer_button.dart'; + +void main() { + testWidgets('TimerButton should display icon & color and react to click', (WidgetTester tester) async { + // Define the icon and color + final Icon icon = Icon(Icons.play_arrow); + final Color color = Colors.green; + + // Build the TimerButton + var clicked = false; + await tester.pumpWidget( + MaterialApp( + home: TimerButton( + onClicked: () => clicked = true, + icon: icon, + color: color, + ), + ), + ); + + // Verify that the icon and color are displayed + expect(find.byWidgetPredicate((widget) => widget is CircleAvatar && widget.child == icon ), findsOneWidget); + + expect(find.byWidgetPredicate((widget) => widget is CircleAvatar && widget.backgroundColor == color ), findsOneWidget); + + // Tap the button + await tester.tap(find.byType(InkWell)); + await tester.pump(); + + // Verify that the onClicked callback was called + expect(clicked, true); + }); +}