libphonenumber-js
Version:
A simpler (and smaller) rewrite of Google Android's libphonenumber library in javascript
21 lines (17 loc) • 759 B
JavaScript
import extractCountryCallingCode from './extractCountryCallingCode.js'
import metadata from '../../metadata.min.json' with { type: 'json' }
describe('extractCountryCallingCode', () => {
it('should extract country calling code from a number', () => {
expect(extractCountryCallingCode('+78005553535', null, null, metadata)).to.deep.equal({
countryCallingCodeSource: 'FROM_NUMBER_WITH_PLUS_SIGN',
countryCallingCode: '7',
number: '8005553535'
})
expect(extractCountryCallingCode('+7800', null, null, metadata)).to.deep.equal({
countryCallingCodeSource: 'FROM_NUMBER_WITH_PLUS_SIGN',
countryCallingCode: '7',
number: '800'
})
expect(extractCountryCallingCode('', null, null, metadata)).to.deep.equal({})
})
})