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

Bugfix / Argentinian transformRule mismatch $2 15-$3-$4 #76

Merged
merged 3 commits into from
Nov 10, 2024
Merged
Changes from 1 commit
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
47 changes: 47 additions & 0 deletions test/phone_number_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -407,4 +407,51 @@ void main() {
expect(zero.isSequentialTo(two), isFalse);
});
});
group(
'format national phone number if transformRule does not start with \$1. example: (\$2 15-\$3-\$4)(AR)',
() {
test('should return the formated phone number not the transformRule string',
Copy link
Owner

@cedvdb cedvdb Nov 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the test, can you rename

should return the formated phone number not the transformRule string

to

=> should format argentinian phone numbers

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing. Done.

() {
String format(String phoneNumber) =>
PhoneNumber.parse(phoneNumber, destinationCountry: IsoCode.AR)
.formatNsn();
var testNumber = '';
expect(format(testNumber), equals(''));
testNumber = '5';
expect(format(testNumber), equals('5'));
testNumber = '54';
expect(format(testNumber), equals('54'));
testNumber = '549';
expect(format(testNumber), equals('549'));
testNumber = '5492';
expect(format(testNumber), equals('5492'));
testNumber = '54926';
expect(format(testNumber), equals('54926'));
testNumber = '549261';
expect(format(testNumber), equals('549261'));
testNumber = '5492615';
expect(format(testNumber), equals('5492615'));
testNumber = '54926153';
expect(format(testNumber), equals('54926153'));
testNumber = '549261532';
expect(format(testNumber), equals('549261532'));
testNumber = '5492615325';
expect(format(testNumber), equals('5492615325'));

testNumber = '54926153256';
expect(format(testNumber), equals('54926153256'));
testNumber = '549261532565';
expect(format(testNumber), equals('549261532565'));
testNumber = '5492615325656';
expect(format(testNumber), equals('261 15-532-5656'));
testNumber = '+5492615325656';
expect(format(testNumber), equals('261 15-532-5656'));
testNumber = '54 9 261-5325 656';
expect(format(testNumber), equals('261 15-532-5656'));
testNumber = '54-9-261-5325-656';
expect(format(testNumber), equals('261 15-532-5656'));
testNumber = '54.9.261.5325.656';
expect(format(testNumber), equals('261 15-532-5656'));
});
});
}