Files
rely/test/features/share_intake/share_intake_debug_log_test.dart
2026-05-19 11:26:23 +02:00

41 lines
1.2 KiB
Dart

import 'package:flutter_test/flutter_test.dart';
import 'package:relationship_saver/features/share_intake/application/share_intake_debug_log.dart';
import 'package:shared_preferences/shared_preferences.dart';
void main() {
setUp(() {
SharedPreferences.setMockInitialValues(<String, Object>{});
});
test('records optional share details for diagnostics', () async {
const ShareIntakeDebugLog log = ShareIntakeDebugLog();
await log.record(
'raw_share_text',
'Captured raw share text (18 chars).',
details: 'Alex: likes cycling',
);
final List<ShareIntakeDebugEvent> events = await log.read();
expect(events, hasLength(1));
expect(events.single.stage, 'raw_share_text');
expect(events.single.details, 'Alex: likes cycling');
});
test('trims very large details before storing', () async {
const ShareIntakeDebugLog log = ShareIntakeDebugLog();
await log.record(
'raw_share_text',
'large',
details: List<String>.filled(7000, 'x').join(),
);
final List<ShareIntakeDebugEvent> events = await log.read();
expect(events.single.details, endsWith('[truncated]'));
expect(events.single.details!.length, lessThan(7000));
});
}