diff --git a/test/ui/pressable_scale_test.dart b/test/ui/pressable_scale_test.dart new file mode 100644 index 0000000..07a7b23 --- /dev/null +++ b/test/ui/pressable_scale_test.dart @@ -0,0 +1,43 @@ +import 'package:block_seasons/ui/widgets/pressable_scale.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('inner button onPressed still fires when wrapped', (tester) async { + var taps = 0; + await tester.pumpWidget(MaterialApp( + home: Scaffold( + body: Center( + child: PressableScale( + child: FilledButton( + onPressed: () => taps++, + child: const Text('Play'), + ), + ), + ), + ), + )); + + await tester.tap(find.text('Play')); + await tester.pump(); + expect(taps, 1, reason: 'PressableScale must not swallow the inner tap'); + }); + + testWidgets('own onTap fires when no inner handler', (tester) async { + var taps = 0; + await tester.pumpWidget(MaterialApp( + home: Scaffold( + body: Center( + child: PressableScale( + onTap: () => taps++, + child: const SizedBox(width: 100, height: 50), + ), + ), + ), + )); + + await tester.tap(find.byType(PressableScale)); + await tester.pump(); + expect(taps, 1); + }); +}