main
dart 30 lines 823 Bytes
Raw
1 import 'package:flutter_test/flutter_test.dart';
2 import 'package:haptic_feedback/haptic_feedback.dart';
3 import 'package:localmind/core/services/app_haptics.dart';
4
5 void main() {
6 test('suppresses vibration while haptic feedback is disabled', () async {
7 var enabled = false;
8 final calls = <HapticsType>[];
9 final haptics = AppHaptics(
10 () => enabled,
11 vibrate: (type) async => calls.add(type),
12 );
13
14 await haptics.light();
15 expect(calls, isEmpty);
16
17 enabled = true;
18 await haptics.medium();
19 expect(calls, [HapticsType.medium]);
20 });
21
22 test('swallows platform vibration failures', () async {
23 final haptics = AppHaptics(
24 () => true,
25 vibrate: (_) => Future<void>.error(StateError('unsupported')),
26 );
27
28 await expectLater(haptics.selection(), completes);
29 });
30 }