31 lines
901 B
Dart
31 lines
901 B
Dart
|
|
import 'package:flutter_test/flutter_test.dart';
|
||
|
|
import 'package:social_app/shared/utils/phone_display_formatter.dart';
|
||
|
|
|
||
|
|
void main() {
|
||
|
|
group('formatPhoneForDisplay', () {
|
||
|
|
test('formats +86 numbers as local masked style', () {
|
||
|
|
final formatted = formatPhoneForDisplay('+8613812345678');
|
||
|
|
|
||
|
|
expect(formatted, '138****5678');
|
||
|
|
});
|
||
|
|
|
||
|
|
test('keeps international country code while masking middle part', () {
|
||
|
|
final formatted = formatPhoneForDisplay('+14155552671');
|
||
|
|
|
||
|
|
expect(formatted, '+1 ****2671');
|
||
|
|
});
|
||
|
|
|
||
|
|
test('normalizes separators before formatting', () {
|
||
|
|
final formatted = formatPhoneForDisplay('(+86) 138-1234-5678');
|
||
|
|
|
||
|
|
expect(formatted, '138****5678');
|
||
|
|
});
|
||
|
|
|
||
|
|
test('prefers longer country code in fallback detection', () {
|
||
|
|
final formatted = formatPhoneForDisplay('+33612345678');
|
||
|
|
|
||
|
|
expect(formatted, '+33 ****5678');
|
||
|
|
});
|
||
|
|
});
|
||
|
|
}
|