|
|
@ -974,10 +974,15 @@ function testFormatWithPreferredCarrierCode() { |
|
|
phoneUtil.formatNationalNumberWithPreferredCarrierCode(arNumber, '15')); |
|
|
phoneUtil.formatNationalNumberWithPreferredCarrierCode(arNumber, '15')); |
|
|
assertEquals('01234 19 12-5678', |
|
|
assertEquals('01234 19 12-5678', |
|
|
phoneUtil.formatNationalNumberWithPreferredCarrierCode(arNumber, '')); |
|
|
phoneUtil.formatNationalNumberWithPreferredCarrierCode(arNumber, '')); |
|
|
// When the preferred_domestic_carrier_code is present (even when it contains
|
|
|
|
|
|
// an empty string), use it instead of the default carrier code passed in.
|
|
|
|
|
|
|
|
|
// When the preferred_domestic_carrier_code is present (even when it is just a
|
|
|
|
|
|
// space), use it instead of the default carrier code passed in.
|
|
|
|
|
|
arNumber.setPreferredDomesticCarrierCode(' '); |
|
|
|
|
|
assertEquals("01234 12-5678", |
|
|
|
|
|
phoneUtil.formatNationalNumberWithPreferredCarrierCode(arNumber, '15')); |
|
|
|
|
|
// When the preferred_domestic_carrier_code is present but empty, treat it as
|
|
|
|
|
|
// unset and use instead the default carrier code passed in.
|
|
|
arNumber.setPreferredDomesticCarrierCode(''); |
|
|
arNumber.setPreferredDomesticCarrierCode(''); |
|
|
assertEquals('01234 12-5678', |
|
|
|
|
|
|
|
|
assertEquals('01234 15 12-5678', |
|
|
phoneUtil.formatNationalNumberWithPreferredCarrierCode(arNumber, '15')); |
|
|
phoneUtil.formatNationalNumberWithPreferredCarrierCode(arNumber, '15')); |
|
|
// We don't support this for the US so there should be no change.
|
|
|
// We don't support this for the US so there should be no change.
|
|
|
/** @type {i18n.phonenumbers.PhoneNumber} */ |
|
|
/** @type {i18n.phonenumbers.PhoneNumber} */ |
|
|
@ -2819,14 +2824,11 @@ function testParseNumbersWithPlusWithNoRegion() { |
|
|
phoneUtil.parse('tel:03-331-6005;isub=12345;phone-context=+64', |
|
|
phoneUtil.parse('tel:03-331-6005;isub=12345;phone-context=+64', |
|
|
RegionCode.ZZ))); |
|
|
RegionCode.ZZ))); |
|
|
|
|
|
|
|
|
// It is important that we set the carrier code to an empty string, since we
|
|
|
|
|
|
// used ParseAndKeepRawInput and no carrier code was found.
|
|
|
|
|
|
/** @type {i18n.phonenumbers.PhoneNumber} */ |
|
|
/** @type {i18n.phonenumbers.PhoneNumber} */ |
|
|
var nzNumberWithRawInput = NZ_NUMBER.clone(); |
|
|
var nzNumberWithRawInput = NZ_NUMBER.clone(); |
|
|
nzNumberWithRawInput.setRawInput('+64 3 331 6005'); |
|
|
nzNumberWithRawInput.setRawInput('+64 3 331 6005'); |
|
|
nzNumberWithRawInput.setCountryCodeSource(i18n.phonenumbers.PhoneNumber |
|
|
nzNumberWithRawInput.setCountryCodeSource(i18n.phonenumbers.PhoneNumber |
|
|
.CountryCodeSource.FROM_NUMBER_WITH_PLUS_SIGN); |
|
|
.CountryCodeSource.FROM_NUMBER_WITH_PLUS_SIGN); |
|
|
nzNumberWithRawInput.setPreferredDomesticCarrierCode(''); |
|
|
|
|
|
assertTrue(nzNumberWithRawInput.equals( |
|
|
assertTrue(nzNumberWithRawInput.equals( |
|
|
phoneUtil.parseAndKeepRawInput('+64 3 331 6005', RegionCode.ZZ))); |
|
|
phoneUtil.parseAndKeepRawInput('+64 3 331 6005', RegionCode.ZZ))); |
|
|
// Null is also allowed for the region code in these cases.
|
|
|
// Null is also allowed for the region code in these cases.
|
|
|
@ -2984,7 +2986,6 @@ function testParseAndKeepRaw() { |
|
|
var alphaNumericNumber = ALPHA_NUMERIC_NUMBER.clone(); |
|
|
var alphaNumericNumber = ALPHA_NUMERIC_NUMBER.clone(); |
|
|
alphaNumericNumber.setRawInput('800 six-flags'); |
|
|
alphaNumericNumber.setRawInput('800 six-flags'); |
|
|
alphaNumericNumber.setCountryCodeSource(CCS.FROM_DEFAULT_COUNTRY); |
|
|
alphaNumericNumber.setCountryCodeSource(CCS.FROM_DEFAULT_COUNTRY); |
|
|
alphaNumericNumber.setPreferredDomesticCarrierCode(''); |
|
|
|
|
|
assertTrue(alphaNumericNumber.equals( |
|
|
assertTrue(alphaNumericNumber.equals( |
|
|
phoneUtil.parseAndKeepRawInput('800 six-flags', RegionCode.US))); |
|
|
phoneUtil.parseAndKeepRawInput('800 six-flags', RegionCode.US))); |
|
|
|
|
|
|
|
|
@ -2994,7 +2995,6 @@ function testParseAndKeepRaw() { |
|
|
shorterAlphaNumber.setNationalNumber(8007493524); |
|
|
shorterAlphaNumber.setNationalNumber(8007493524); |
|
|
shorterAlphaNumber.setRawInput('1800 six-flag'); |
|
|
shorterAlphaNumber.setRawInput('1800 six-flag'); |
|
|
shorterAlphaNumber.setCountryCodeSource(CCS.FROM_NUMBER_WITHOUT_PLUS_SIGN); |
|
|
shorterAlphaNumber.setCountryCodeSource(CCS.FROM_NUMBER_WITHOUT_PLUS_SIGN); |
|
|
shorterAlphaNumber.setPreferredDomesticCarrierCode(''); |
|
|
|
|
|
assertTrue(shorterAlphaNumber.equals( |
|
|
assertTrue(shorterAlphaNumber.equals( |
|
|
phoneUtil.parseAndKeepRawInput('1800 six-flag', RegionCode.US))); |
|
|
phoneUtil.parseAndKeepRawInput('1800 six-flag', RegionCode.US))); |
|
|
|
|
|
|
|
|
|