1 |
- {"version":3,"file":"parsePhoneNumber.test.js","names":["parsePhoneNumber","parameters","push","metadata","_parsePhoneNumber","apply","USE_NON_GEOGRAPHIC_COUNTRY_CODE","describe","it","nationalNumber","should","equal","expect","to","be","undefined","phoneNumber","number","country","countryCallingCode","defaultCallingCode","isPossible","phoneNumber2","testCorrectness","expectedResult","result","extract","defaultCountry","not","isValid"],"sources":["../source/parsePhoneNumber.test.js"],"sourcesContent":["import _parsePhoneNumber from './parsePhoneNumber.js'\r\nimport metadata from '../metadata.min.json' assert { type: 'json' }\r\n\r\nfunction parsePhoneNumber(...parameters) {\r\n\tparameters.push(metadata)\r\n\treturn _parsePhoneNumber.apply(this, parameters)\r\n}\r\n\r\nconst USE_NON_GEOGRAPHIC_COUNTRY_CODE = false\r\n\r\ndescribe('parsePhoneNumber', () => {\r\n\tit('should parse phone numbers from string', () => {\r\n\t\tparsePhoneNumber('Phone: 8 (800) 555 35 35.', 'RU').nationalNumber.should.equal('8005553535')\r\n\t\texpect(parsePhoneNumber('3', 'RU')).to.be.undefined\r\n\t})\r\n\r\n\tit('should work in edge cases', () => {\r\n\t\texpect(parsePhoneNumber('')).to.be.undefined\r\n\t})\r\n\r\n\tit('should parse phone numbers when invalid country code is passed', () => {\r\n\t\tparsePhoneNumber('Phone: +7 (800) 555 35 35.', 'XX').nationalNumber.should.equal('8005553535')\r\n\t\texpect(parsePhoneNumber('Phone: 8 (800) 555-35-35.', 'XX')).to.be.undefined\r\n\t})\r\n\r\n\r\n\tit('should parse non-geographic numbering plan phone numbers (extended)', () => {\r\n\t\tconst phoneNumber = parsePhoneNumber('+870773111632')\r\n\t\tphoneNumber.number.should.equal('+870773111632')\r\n\t\tif (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {\r\n\t\t\tphoneNumber.country.should.equal('001')\r\n\t\t} else {\r\n\t\t\texpect(phoneNumber.country).to.be.undefined\r\n\t\t}\r\n\t\tphoneNumber.countryCallingCode.should.equal('870')\r\n\t})\r\n\r\n\tit('should parse non-geographic numbering plan phone numbers (default country code) (extended)', () => {\r\n\t\tconst phoneNumber = parsePhoneNumber('773111632', { defaultCallingCode: '870' })\r\n\t\tphoneNumber.number.should.equal('+870773111632')\r\n\t\tif (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {\r\n\t\t\tphoneNumber.country.should.equal('001')\r\n\t\t} else {\r\n\t\t\texpect(phoneNumber.country).to.be.undefined\r\n\t\t}\r\n\t\tphoneNumber.countryCallingCode.should.equal('870')\r\n\t})\r\n\r\n\tit('should determine the possibility of non-geographic phone numbers', () => {\r\n\t\tconst phoneNumber = parsePhoneNumber('+870773111632')\r\n\t\tphoneNumber.isPossible().should.equal(true)\r\n\t\tconst phoneNumber2 = parsePhoneNumber('+8707731116321')\r\n\t\tphoneNumber2.isPossible().should.equal(false)\r\n\t})\r\n\r\n\tit('should support `extract: false` flag', () => {\r\n\t\tconst testCorrectness = (number, expectedResult) => {\r\n\t\t\tconst result = expect(parsePhoneNumber(number, { extract: false, defaultCountry: 'US' }))\r\n\t\t\tif (expectedResult) {\r\n\t\t\t\tresult.to.not.be.undefined\r\n\t\t\t} else {\r\n\t\t\t\tresult.to.be.undefined\r\n\t\t\t}\r\n\t\t}\r\n\t\ttestCorrectness('Call: (213) 373-4253', false)\r\n\t\ttestCorrectness('(213) 373-4253x', false)\r\n\t\ttestCorrectness('(213) 373-4253', true)\r\n\t\ttestCorrectness('- (213) 373-4253 -', true)\r\n\t\ttestCorrectness('+1 (213) 373-4253', true)\r\n\t\ttestCorrectness(' +1 (213) 373-4253', false)\r\n\t})\r\n\r\n\tit('should not prematurely strip a possible national prefix from Chinese numbers', () => {\r\n\t\t// https://gitlab.com/catamphetamine/libphonenumber-js/-/issues/57\r\n\t\tconst phoneNumber = parsePhoneNumber('+86123456789')\r\n\t\tphoneNumber.isPossible().should.equal(true)\r\n\t\tphoneNumber.isValid().should.equal(false)\r\n\t\tphoneNumber.nationalNumber.should.equal('123456789')\r\n\t})\r\n})\r\n"],"mappings":";;AA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