Skip to content

Commit 67a3152

Browse files
MelvinBotcead22
andcommitted
Use CONST.COUNTRY for AS and MP, clean up test descriptions
- Add AS (American Samoa) and MP (Northern Mariana Islands) to CONST.COUNTRY in src/CONST/index.ts - Update validUSRegionCodes to use CONST.COUNTRY.AS and CONST.COUNTRY.MP instead of string literals - Remove parenthesized area codes from test descriptions Co-authored-by: Carlos Alvarez <cead22@users.noreply.github.com>
1 parent fc1dc82 commit 67a3152

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

src/CONST/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,8 @@ const CONST = {
802802
PR: 'PR',
803803
GU: 'GU',
804804
VI: 'VI',
805+
AS: 'AS',
806+
MP: 'MP',
805807
},
806808
SWIPE_DIRECTION: {
807809
DOWN: 'down',

src/libs/ValidationUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ function isValidUSPhone(phoneNumber = '', isCountryCodeOptional?: boolean): bool
324324

325325
// US territories share the +1 country calling code but have their own ISO region codes.
326326
// We accept these as valid US phone numbers for wallet/bank account verification.
327-
const validUSRegionCodes = [CONST.COUNTRY.US, CONST.COUNTRY.PR, CONST.COUNTRY.GU, CONST.COUNTRY.VI, 'AS', 'MP'];
327+
const validUSRegionCodes = [CONST.COUNTRY.US, CONST.COUNTRY.PR, CONST.COUNTRY.GU, CONST.COUNTRY.VI, CONST.COUNTRY.AS, CONST.COUNTRY.MP];
328328
return parsedPhoneNumber.possible && validUSRegionCodes.includes(parsedPhoneNumber.regionCode ?? '');
329329
}
330330

tests/unit/ValidationUtilsTest.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -558,23 +558,23 @@ describe('ValidationUtils', () => {
558558
expect(isValidUSPhone('+12018675309')).toBe(true);
559559
});
560560

561-
test('Should return true for a Puerto Rico phone number (+1-787)', () => {
561+
test('Should return true for a Puerto Rico phone number', () => {
562562
expect(isValidUSPhone('+17873464732')).toBe(true);
563563
});
564564

565-
test('Should return true for a US Virgin Islands phone number (+1-340)', () => {
565+
test('Should return true for a US Virgin Islands phone number', () => {
566566
expect(isValidUSPhone('+13405551234')).toBe(true);
567567
});
568568

569-
test('Should return true for a Guam phone number (+1-671)', () => {
569+
test('Should return true for a Guam phone number', () => {
570570
expect(isValidUSPhone('+16715551234')).toBe(true);
571571
});
572572

573-
test('Should return true for a Northern Mariana Islands phone number (+1-670)', () => {
573+
test('Should return true for a Northern Mariana Islands phone number', () => {
574574
expect(isValidUSPhone('+16705551234')).toBe(true);
575575
});
576576

577-
test('Should return false for a Canadian phone number (+1-416)', () => {
577+
test('Should return false for a Canadian phone number', () => {
578578
expect(isValidUSPhone('+14165551234')).toBe(false);
579579
});
580580

0 commit comments

Comments
 (0)