test(juice): PressableScale doesn't swallow the inner button tap
This commit is contained in:
@@ -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);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user