Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use proper format for congo phone numbers #127

Merged
merged 2 commits into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/formatters/phone_input_formatter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ class PhoneCodes {
'countryRU': 'Конго',
'internalPhoneCode': '242',
'countryCode': 'CG',
'phoneMask': '+000 00 000 0000',
'phoneMask': '+000 00 00 00000',
},
{
'country': 'Cook Islands',
Expand Down Expand Up @@ -2171,7 +2171,7 @@ class PhoneCodes {
'countryRU': 'Конго, Демократическая Республика',
'internalPhoneCode': '243',
'countryCode': 'CD',
'phoneMask': '+000 00 000 0000',
'phoneMask': '+000 00 00 00000',
},
{
'country': 'Cote d\'Ivoire',
Expand Down
84 changes: 84 additions & 0 deletions test/flutter_multi_formatter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,88 @@ void main() {
);
expect(withoutDefault, formatted);
});

group('congo', () {
group('242', () {
test('should format partial congo mask +000 00', () {
final inputNumber = '+24255';

final formattedNumber = PhoneInputFormatter()
.formatEditUpdate(
TextEditingValue(text: ''),
TextEditingValue(text: inputNumber),
)
.text;

expect(formattedNumber, '+242 55');
});

test('should format partial congo mask +000 00 00', () {
final inputNumber = '+2425566';

final formattedNumber = PhoneInputFormatter()
.formatEditUpdate(
TextEditingValue(text: ''),
TextEditingValue(text: inputNumber),
)
.text;

expect(formattedNumber, '+242 55 66');
});

test('should format full congo mask +000 00 00 00000', () {
final inputNumber = '+242556677777';

final formattedNumber = PhoneInputFormatter()
.formatEditUpdate(
TextEditingValue(text: ''),
TextEditingValue(text: inputNumber),
)
.text;

expect(formattedNumber, '+242 55 66 77777');
});
});

group('243', () {
test('should format partial congo mask +000 00', () {
final inputNumber = '+24355';

final formattedNumber = PhoneInputFormatter()
.formatEditUpdate(
TextEditingValue(text: ''),
TextEditingValue(text: inputNumber),
)
.text;

expect(formattedNumber, '+243 55');
});

test('should format partial congo mask +000 00 00', () {
final inputNumber = '+2435566';

final formattedNumber = PhoneInputFormatter()
.formatEditUpdate(
TextEditingValue(text: ''),
TextEditingValue(text: inputNumber),
)
.text;

expect(formattedNumber, '+243 55 66');
});

test('should format full congo mask +000 00 00 00000', () {
final inputNumber = '+243556677777';

final formattedNumber = PhoneInputFormatter()
.formatEditUpdate(
TextEditingValue(text: ''),
TextEditingValue(text: inputNumber),
)
.text;

expect(formattedNumber, '+243 55 66 77777');
});
});
});
}