2018-11-02 18:02:53 +00:00
|
|
|
/* global libphonenumber */
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
describe('libphonenumber util', () => {
|
|
|
|
describe('parseNumber', () => {
|
|
|
|
it('numbers with + are valid without providing regionCode', () => {
|
|
|
|
const result = libphonenumber.util.parseNumber('+14155555555');
|
|
|
|
assert.isTrue(result.isValidNumber);
|
|
|
|
assert.strictEqual(result.nationalNumber, '4155555555');
|
|
|
|
assert.strictEqual(result.e164, '+14155555555');
|
|
|
|
assert.strictEqual(result.regionCode, 'US');
|
|
|
|
assert.strictEqual(result.countryCode, '1');
|
|
|
|
});
|
|
|
|
it('variant numbers with the right regionCode are valid', () => {
|
|
|
|
['4155555555', '14155555555', '+14155555555'].forEach(number => {
|
|
|
|
const result = libphonenumber.util.parseNumber(number, 'US');
|
2018-04-27 21:25:04 +00:00
|
|
|
assert.isTrue(result.isValidNumber);
|
|
|
|
assert.strictEqual(result.nationalNumber, '4155555555');
|
|
|
|
assert.strictEqual(result.e164, '+14155555555');
|
|
|
|
assert.strictEqual(result.regionCode, 'US');
|
|
|
|
assert.strictEqual(result.countryCode, '1');
|
|
|
|
});
|
2015-12-05 01:38:41 +00:00
|
|
|
});
|
2018-04-27 21:25:04 +00:00
|
|
|
});
|
2018-11-02 18:02:53 +00:00
|
|
|
});
|