libphonenumber-js 1.12.40 → 1.12.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/bundle/libphonenumber-js.min.js +1 -1
- package/bundle/libphonenumber-js.min.js.map +1 -1
- package/bundle/libphonenumber-max.js +1 -1
- package/bundle/libphonenumber-max.js.map +1 -1
- package/bundle/libphonenumber-min.js +1 -1
- package/bundle/libphonenumber-min.js.map +1 -1
- package/bundle/libphonenumber-mobile.js +1 -1
- package/bundle/libphonenumber-mobile.js.map +1 -1
- package/max/metadata/metadata.max.json +1 -1
- package/max/metadata/metadata.max.json.js +1 -1
- package/metadata.full.json +1 -1
- package/metadata.full.json.js +1 -1
- package/metadata.max.json +1 -1
- package/metadata.max.json.js +1 -1
- package/metadata.min.json +1 -1
- package/metadata.min.json.js +1 -1
- package/metadata.mobile.json +1 -1
- package/metadata.mobile.json.js +1 -1
- package/min/metadata/metadata.min.json +1 -1
- package/min/metadata/metadata.min.json.js +1 -1
- package/mobile/metadata/metadata.mobile.json +1 -1
- package/mobile/metadata/metadata.mobile.json.js +1 -1
- package/package.json +1 -1
- package/.babelrc +0 -21
- package/.nycrc +0 -27
- package/METADATA.md +0 -155
- package/autoupdate.cmd +0 -6
- package/autoupdate.sh +0 -16
- package/build/AsYouType.test.js +0 -1339
- package/build/AsYouTypeFormatter.PatternMatcher.test.js +0 -502
- package/build/AsYouTypeFormatter.PatternParser.test.js +0 -49
- package/build/AsYouTypeFormatter.util.test.js +0 -24
- package/build/PhoneNumber.test.js +0 -141
- package/build/PhoneNumberMatcher.test.js +0 -122
- package/build/findNumbers/util.test.js +0 -34
- package/build/findPhoneNumbersInText.test.js +0 -300
- package/build/format.test.js +0 -339
- package/build/formatIncompletePhoneNumber.test.js +0 -33
- package/build/getCountries.test.js +0 -13
- package/build/getCountryCallingCode.test.js +0 -18
- package/build/getExampleNumber.test.js +0 -21
- package/build/helpers/RFC3966.test.js +0 -47
- package/build/helpers/applyInternationalSeparatorStyle.test.js +0 -13
- package/build/helpers/checkNumberLength.test.js +0 -81
- package/build/helpers/extractCountryCallingCode.test.js +0 -23
- package/build/helpers/extractNationalNumber.test.js +0 -27
- package/build/helpers/extractNationalNumberFromPossiblyIncompleteNumber.test.js +0 -20
- package/build/helpers/extractPhoneContext.test.js +0 -71
- package/build/helpers/getNumberType.test.js +0 -23
- package/build/helpers/matchesEntirely.test.js +0 -16
- package/build/helpers/mergeArrays.test.js +0 -12
- package/build/helpers/parseDigits.test.js +0 -12
- package/build/helpers/stripIddPrefix.test.js +0 -22
- package/build/isPossible.test.js +0 -121
- package/build/isPossiblePhoneNumber.test.js +0 -42
- package/build/isValid.test.js +0 -144
- package/build/isValidPhoneNumber.test.js +0 -29
- package/build/legacy/findNumbers.test.js +0 -210
- package/build/legacy/findPhoneNumbers.test.js +0 -245
- package/build/legacy/format.test.js +0 -299
- package/build/legacy/getNumberType.test.js +0 -80
- package/build/legacy/isPossibleNumber.test.js +0 -82
- package/build/legacy/isValidNumber.test.js +0 -102
- package/build/legacy/isValidNumberForRegion.test.js +0 -40
- package/build/legacy/parse.test.js +0 -617
- package/build/legacy/searchNumbers.test.js +0 -33
- package/build/metadata.test.js +0 -170
- package/build/parse.test.js +0 -653
- package/build/parseIncompletePhoneNumber.test.js +0 -109
- package/build/parsePhoneNumber.test.js +0 -98
- package/build/parsePhoneNumberWithError.test.js +0 -140
- package/build/searchPhoneNumbersInText.test.js +0 -51
- package/build/tools/semver-compare.test.js +0 -13
- package/build/validatePhoneNumberLength.test.js +0 -37
- package/build-scripts/check-for-metadata-changes-and-create-pull-request.js +0 -88
- package/build-scripts/check-for-metadata-changes-and-release.js +0 -67
- package/build-scripts/check-for-uncommitted-files.js +0 -13
- package/build-scripts/create-commonjs-package-json-file.js +0 -11
- package/build-scripts/create-js-file-for-json-file.js +0 -14
- package/build-scripts/create-metadata-update-branch.js +0 -31
- package/build-scripts/generate-country-codes-list-in-typescript.js +0 -14
- package/build-scripts/generate-metadata-from-google-metadata.js +0 -75
- package/build-scripts/helpers/commit.js +0 -14
- package/build-scripts/helpers/exec.js +0 -6
- package/build-scripts/helpers/getUncommittedChanges.js +0 -33
- package/build-scripts/helpers/sendEmail.js +0 -62
- package/build-scripts/helpers/updateMetadataFromGoogleMetadata.js +0 -130
- package/build-scripts/pull-google-metadata.js +0 -29
- package/es6/AsYouType.test.js +0 -1336
- package/es6/AsYouTypeFormatter.PatternMatcher.test.js +0 -499
- package/es6/AsYouTypeFormatter.PatternParser.test.js +0 -46
- package/es6/AsYouTypeFormatter.util.test.js +0 -22
- package/es6/PhoneNumber.test.js +0 -138
- package/es6/PhoneNumberMatcher.test.js +0 -119
- package/es6/findNumbers/util.test.js +0 -32
- package/es6/findPhoneNumbersInText.test.js +0 -297
- package/es6/format.test.js +0 -336
- package/es6/formatIncompletePhoneNumber.test.js +0 -30
- package/es6/getCountries.test.js +0 -10
- package/es6/getCountryCallingCode.test.js +0 -15
- package/es6/getExampleNumber.test.js +0 -18
- package/es6/helpers/RFC3966.test.js +0 -45
- package/es6/helpers/applyInternationalSeparatorStyle.test.js +0 -10
- package/es6/helpers/checkNumberLength.test.js +0 -76
- package/es6/helpers/extractCountryCallingCode.test.js +0 -20
- package/es6/helpers/extractNationalNumber.test.js +0 -24
- package/es6/helpers/extractNationalNumberFromPossiblyIncompleteNumber.test.js +0 -17
- package/es6/helpers/extractPhoneContext.test.js +0 -68
- package/es6/helpers/getNumberType.test.js +0 -20
- package/es6/helpers/matchesEntirely.test.js +0 -13
- package/es6/helpers/mergeArrays.test.js +0 -9
- package/es6/helpers/parseDigits.test.js +0 -9
- package/es6/helpers/stripIddPrefix.test.js +0 -19
- package/es6/isPossible.test.js +0 -118
- package/es6/isPossiblePhoneNumber.test.js +0 -39
- package/es6/isValid.test.js +0 -141
- package/es6/isValidPhoneNumber.test.js +0 -26
- package/es6/legacy/findNumbers.test.js +0 -207
- package/es6/legacy/findPhoneNumbers.test.js +0 -243
- package/es6/legacy/format.test.js +0 -296
- package/es6/legacy/getNumberType.test.js +0 -77
- package/es6/legacy/isPossibleNumber.test.js +0 -79
- package/es6/legacy/isValidNumber.test.js +0 -99
- package/es6/legacy/isValidNumberForRegion.test.js +0 -37
- package/es6/legacy/parse.test.js +0 -614
- package/es6/legacy/searchNumbers.test.js +0 -30
- package/es6/metadata.test.js +0 -166
- package/es6/parse.test.js +0 -650
- package/es6/parseIncompletePhoneNumber.test.js +0 -105
- package/es6/parsePhoneNumber.test.js +0 -95
- package/es6/parsePhoneNumberWithError.test.js +0 -137
- package/es6/searchPhoneNumbersInText.test.js +0 -48
- package/es6/tools/semver-compare.test.js +0 -10
- package/es6/validatePhoneNumberLength.test.js +0 -34
- package/jest.config.json +0 -26
- package/rollup.config.mjs +0 -57
- package/source/AsYouType.test.js +0 -1409
- package/source/AsYouTypeFormatter.PatternMatcher.test.js +0 -644
- package/source/AsYouTypeFormatter.PatternParser.test.js +0 -70
- package/source/AsYouTypeFormatter.util.test.js +0 -25
- package/source/PhoneNumber.test.js +0 -138
- package/source/PhoneNumberMatcher.test.js +0 -112
- package/source/findNumbers/util.test.js +0 -37
- package/source/findPhoneNumbersInText.test.js +0 -316
- package/source/format.test.js +0 -273
- package/source/formatIncompletePhoneNumber.test.js +0 -33
- package/source/getCountries.test.js +0 -12
- package/source/getCountryCallingCode.test.js +0 -16
- package/source/getExampleNumber.test.js +0 -20
- package/source/helpers/RFC3966.test.js +0 -39
- package/source/helpers/applyInternationalSeparatorStyle.test.js +0 -11
- package/source/helpers/checkNumberLength.test.js +0 -85
- package/source/helpers/extractCountryCallingCode.test.js +0 -23
- package/source/helpers/extractNationalNumber.test.js +0 -27
- package/source/helpers/extractNationalNumberFromPossiblyIncompleteNumber.test.js +0 -18
- package/source/helpers/extractPhoneContext.test.js +0 -107
- package/source/helpers/getNumberType.test.js +0 -27
- package/source/helpers/matchesEntirely.test.js +0 -14
- package/source/helpers/mergeArrays.test.js +0 -10
- package/source/helpers/parseDigits.test.js +0 -10
- package/source/helpers/stripIddPrefix.test.js +0 -24
- package/source/isPossible.test.js +0 -86
- package/source/isPossiblePhoneNumber.test.js +0 -36
- package/source/isValid.test.js +0 -123
- package/source/isValidPhoneNumber.test.js +0 -23
- package/source/legacy/findNumbers.test.js +0 -220
- package/source/legacy/findPhoneNumbers.test.js +0 -252
- package/source/legacy/format.test.js +0 -246
- package/source/legacy/getNumberType.test.js +0 -70
- package/source/legacy/isPossibleNumber.test.js +0 -49
- package/source/legacy/isValidNumber.test.js +0 -95
- package/source/legacy/isValidNumberForRegion.test.js +0 -31
- package/source/legacy/parse.test.js +0 -533
- package/source/legacy/searchNumbers.test.js +0 -29
- package/source/metadata.test.js +0 -178
- package/source/parse.test.js +0 -561
- package/source/parseIncompletePhoneNumber.test.js +0 -118
- package/source/parsePhoneNumber.test.js +0 -99
- package/source/parsePhoneNumberWithError.test.js +0 -115
- package/source/searchPhoneNumbersInText.test.js +0 -47
- package/source/tools/semver-compare.test.js +0 -43
- package/source/validatePhoneNumberLength.test.js +0 -33
package/build/format.test.js
DELETED
|
@@ -1,339 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _mocha = require("mocha");
|
|
4
|
-
var _chai = require("chai");
|
|
5
|
-
var _metadataMin = _interopRequireDefault(require("../metadata.min.json"));
|
|
6
|
-
var _format = _interopRequireDefault(require("./format.js"));
|
|
7
|
-
var _parsePhoneNumber = _interopRequireDefault(require("./parsePhoneNumber.js"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
9
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
10
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
12
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
13
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
14
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
15
|
-
function formatNumber() {
|
|
16
|
-
var v2;
|
|
17
|
-
for (var _len = arguments.length, parameters = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
18
|
-
parameters[_key] = arguments[_key];
|
|
19
|
-
}
|
|
20
|
-
if (parameters.length < 1) {
|
|
21
|
-
// `input` parameter.
|
|
22
|
-
parameters.push(undefined);
|
|
23
|
-
} else {
|
|
24
|
-
// Convert string `input` to a `PhoneNumber` instance.
|
|
25
|
-
if (typeof parameters[0] === 'string') {
|
|
26
|
-
v2 = true;
|
|
27
|
-
parameters[0] = (0, _parsePhoneNumber["default"])(parameters[0], _objectSpread(_objectSpread({}, parameters[2]), {}, {
|
|
28
|
-
extract: false
|
|
29
|
-
}), _metadataMin["default"]);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
if (parameters.length < 2) {
|
|
33
|
-
// `format` parameter.
|
|
34
|
-
parameters.push(undefined);
|
|
35
|
-
}
|
|
36
|
-
if (parameters.length < 3) {
|
|
37
|
-
// `options` parameter.
|
|
38
|
-
parameters.push(undefined);
|
|
39
|
-
}
|
|
40
|
-
// Set `v2` flag.
|
|
41
|
-
parameters[2] = _objectSpread({
|
|
42
|
-
v2: v2
|
|
43
|
-
}, parameters[2]);
|
|
44
|
-
// Add `metadata` parameter.
|
|
45
|
-
parameters.push(_metadataMin["default"]);
|
|
46
|
-
// Call the function.
|
|
47
|
-
return _format["default"].apply(this, parameters);
|
|
48
|
-
}
|
|
49
|
-
(0, _mocha.describe)('format', function () {
|
|
50
|
-
(0, _mocha.it)('should work with the first argument being a E.164 number', function () {
|
|
51
|
-
(0, _chai.expect)(formatNumber('+12133734253', 'NATIONAL')).to.equal('(213) 373-4253');
|
|
52
|
-
(0, _chai.expect)(formatNumber('+12133734253', 'INTERNATIONAL')).to.equal('+1 213 373 4253');
|
|
53
|
-
|
|
54
|
-
// Invalid number.
|
|
55
|
-
(0, _chai.expect)(formatNumber('+12111111111', 'NATIONAL')).to.equal('(211) 111-1111');
|
|
56
|
-
|
|
57
|
-
// Formatting invalid E.164 numbers.
|
|
58
|
-
(0, _chai.expect)(formatNumber('+11111', 'INTERNATIONAL')).to.equal('+1 1111');
|
|
59
|
-
(0, _chai.expect)(formatNumber('+11111', 'NATIONAL')).to.equal('1111');
|
|
60
|
-
});
|
|
61
|
-
(0, _mocha.it)('should work with the first object argument expanded', function () {
|
|
62
|
-
(0, _chai.expect)(formatNumber('2133734253', 'NATIONAL', {
|
|
63
|
-
defaultCountry: 'US'
|
|
64
|
-
})).to.equal('(213) 373-4253');
|
|
65
|
-
(0, _chai.expect)(formatNumber('2133734253', 'INTERNATIONAL', {
|
|
66
|
-
defaultCountry: 'US'
|
|
67
|
-
})).to.equal('+1 213 373 4253');
|
|
68
|
-
});
|
|
69
|
-
(0, _mocha.it)('should format using formats with no leading digits (`format.leadingDigitsPatterns().length === 0`)', function () {
|
|
70
|
-
(0, _chai.expect)(formatNumber({
|
|
71
|
-
phone: '12345678901',
|
|
72
|
-
countryCallingCode: 888
|
|
73
|
-
}, 'INTERNATIONAL')).to.equal('+888 123 456 78901');
|
|
74
|
-
});
|
|
75
|
-
(0, _mocha.it)('should sort out the arguments', function () {
|
|
76
|
-
var options = {
|
|
77
|
-
formatExtension: function formatExtension(number, extension) {
|
|
78
|
-
return "".concat(number, " \u0434\u043E\u0431. ").concat(extension);
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
(0, _chai.expect)(formatNumber({
|
|
82
|
-
phone: '8005553535',
|
|
83
|
-
country: 'RU',
|
|
84
|
-
ext: '123'
|
|
85
|
-
}, 'NATIONAL', options)).to.equal('8 (800) 555-35-35 доб. 123');
|
|
86
|
-
|
|
87
|
-
// Parse number from string.
|
|
88
|
-
(0, _chai.expect)(formatNumber('+78005553535', 'NATIONAL', options)).to.equal('8 (800) 555-35-35');
|
|
89
|
-
(0, _chai.expect)(formatNumber('8005553535', 'NATIONAL', _objectSpread(_objectSpread({}, options), {}, {
|
|
90
|
-
defaultCountry: 'RU'
|
|
91
|
-
}))).to.equal('8 (800) 555-35-35');
|
|
92
|
-
});
|
|
93
|
-
(0, _mocha.it)('should format with national prefix when specifically instructed', function () {
|
|
94
|
-
// With national prefix.
|
|
95
|
-
(0, _chai.expect)(formatNumber('88005553535', 'NATIONAL', {
|
|
96
|
-
defaultCountry: 'RU'
|
|
97
|
-
})).to.equal('8 (800) 555-35-35');
|
|
98
|
-
// Without national prefix via an explicitly set option.
|
|
99
|
-
(0, _chai.expect)(formatNumber('88005553535', 'NATIONAL', {
|
|
100
|
-
nationalPrefix: false,
|
|
101
|
-
defaultCountry: 'RU'
|
|
102
|
-
})).to.equal('800 555-35-35');
|
|
103
|
-
});
|
|
104
|
-
(0, _mocha.it)('should format valid phone numbers', function () {
|
|
105
|
-
// Switzerland
|
|
106
|
-
(0, _chai.expect)(formatNumber({
|
|
107
|
-
country: 'CH',
|
|
108
|
-
phone: '446681800'
|
|
109
|
-
}, 'INTERNATIONAL')).to.equal('+41 44 668 18 00');
|
|
110
|
-
(0, _chai.expect)(formatNumber({
|
|
111
|
-
country: 'CH',
|
|
112
|
-
phone: '446681800'
|
|
113
|
-
}, 'E.164')).to.equal('+41446681800');
|
|
114
|
-
(0, _chai.expect)(formatNumber({
|
|
115
|
-
country: 'CH',
|
|
116
|
-
phone: '446681800'
|
|
117
|
-
}, 'RFC3966')).to.equal('tel:+41446681800');
|
|
118
|
-
(0, _chai.expect)(formatNumber({
|
|
119
|
-
country: 'CH',
|
|
120
|
-
phone: '446681800'
|
|
121
|
-
}, 'NATIONAL')).to.equal('044 668 18 00');
|
|
122
|
-
|
|
123
|
-
// France
|
|
124
|
-
(0, _chai.expect)(formatNumber({
|
|
125
|
-
country: 'FR',
|
|
126
|
-
phone: '169454850'
|
|
127
|
-
}, 'NATIONAL')).to.equal('01 69 45 48 50');
|
|
128
|
-
|
|
129
|
-
// Kazakhstan
|
|
130
|
-
(0, _chai.expect)(formatNumber('+7 702 211 1111', 'NATIONAL')).to.equal('8 (702) 211 1111');
|
|
131
|
-
});
|
|
132
|
-
(0, _mocha.it)('should format national numbers with national prefix even if it\'s optional', function () {
|
|
133
|
-
// Russia
|
|
134
|
-
(0, _chai.expect)(formatNumber({
|
|
135
|
-
country: 'RU',
|
|
136
|
-
phone: '9991234567'
|
|
137
|
-
}, 'NATIONAL')).to.equal('8 (999) 123-45-67');
|
|
138
|
-
});
|
|
139
|
-
(0, _mocha.it)('should work in edge cases', function () {
|
|
140
|
-
var thrower;
|
|
141
|
-
|
|
142
|
-
// // No phone number
|
|
143
|
-
// formatNumber('', 'INTERNATIONAL', { defaultCountry: 'RU' }).should.equal('')
|
|
144
|
-
// formatNumber('', 'NATIONAL', { defaultCountry: 'RU' }).should.equal('')
|
|
145
|
-
|
|
146
|
-
(0, _chai.expect)(formatNumber({
|
|
147
|
-
country: 'RU',
|
|
148
|
-
phone: ''
|
|
149
|
-
}, 'INTERNATIONAL')).to.equal('+7');
|
|
150
|
-
(0, _chai.expect)(formatNumber({
|
|
151
|
-
country: 'RU',
|
|
152
|
-
phone: ''
|
|
153
|
-
}, 'NATIONAL')).to.equal('');
|
|
154
|
-
|
|
155
|
-
// No suitable format
|
|
156
|
-
(0, _chai.expect)(formatNumber('+121337342530', 'NATIONAL', {
|
|
157
|
-
defaultCountry: 'US'
|
|
158
|
-
})).to.equal('21337342530');
|
|
159
|
-
// No suitable format (leading digits mismatch)
|
|
160
|
-
(0, _chai.expect)(formatNumber('28199999', 'NATIONAL', {
|
|
161
|
-
defaultCountry: 'AD'
|
|
162
|
-
})).to.equal('28199999');
|
|
163
|
-
|
|
164
|
-
// // Numerical `value`
|
|
165
|
-
// thrower = () => formatNumber(89150000000, 'NATIONAL', { defaultCountry: 'RU' })
|
|
166
|
-
// thrower.should.throw('A phone number must either be a string or an object of shape { phone, [country] }.')
|
|
167
|
-
|
|
168
|
-
// // No metadata for country
|
|
169
|
-
// expect(() => formatNumber('+121337342530', 'NATIONAL', { defaultCountry: 'USA' })).to.throw('Unknown country')
|
|
170
|
-
// expect(() => formatNumber('21337342530', 'NATIONAL', { defaultCountry: 'USA' })).to.throw('Unknown country')
|
|
171
|
-
|
|
172
|
-
// No format type
|
|
173
|
-
thrower = function thrower() {
|
|
174
|
-
return formatNumber('+123');
|
|
175
|
-
};
|
|
176
|
-
(0, _chai.expect)(thrower).to["throw"]('Unknown "format" argument');
|
|
177
|
-
|
|
178
|
-
// Unknown format type
|
|
179
|
-
thrower = function thrower() {
|
|
180
|
-
return formatNumber('123', 'Gay', {
|
|
181
|
-
defaultCountry: 'US'
|
|
182
|
-
});
|
|
183
|
-
};
|
|
184
|
-
(0, _chai.expect)(thrower).to["throw"]('Unknown "format" argument');
|
|
185
|
-
|
|
186
|
-
// // No metadata
|
|
187
|
-
// thrower = () => _formatNumber('123', 'E.164', { defaultCountry: 'RU' })
|
|
188
|
-
// thrower.should.throw('`metadata`')
|
|
189
|
-
|
|
190
|
-
// No formats
|
|
191
|
-
(0, _chai.expect)(formatNumber('012345', 'NATIONAL', {
|
|
192
|
-
defaultCountry: 'AC'
|
|
193
|
-
})).to.equal('012345');
|
|
194
|
-
|
|
195
|
-
// No `fromCountry` for `IDD` format.
|
|
196
|
-
(0, _chai.expect)(formatNumber('+78005553535', 'IDD')).to.be.undefined;
|
|
197
|
-
|
|
198
|
-
// `fromCountry` has no default IDD prefix.
|
|
199
|
-
(0, _chai.expect)(formatNumber('+78005553535', 'IDD', {
|
|
200
|
-
fromCountry: 'BO'
|
|
201
|
-
})).to.be.undefined;
|
|
202
|
-
|
|
203
|
-
// No such country.
|
|
204
|
-
(0, _chai.expect)(function () {
|
|
205
|
-
return formatNumber({
|
|
206
|
-
phone: '123',
|
|
207
|
-
country: 'USA'
|
|
208
|
-
}, 'NATIONAL');
|
|
209
|
-
}).to["throw"]('Unknown country');
|
|
210
|
-
});
|
|
211
|
-
(0, _mocha.it)('should format phone number extensions', function () {
|
|
212
|
-
// National
|
|
213
|
-
(0, _chai.expect)(formatNumber({
|
|
214
|
-
country: 'US',
|
|
215
|
-
phone: '2133734253',
|
|
216
|
-
ext: '123'
|
|
217
|
-
}, 'NATIONAL')).to.equal('(213) 373-4253 ext. 123');
|
|
218
|
-
|
|
219
|
-
// International
|
|
220
|
-
(0, _chai.expect)(formatNumber({
|
|
221
|
-
country: 'US',
|
|
222
|
-
phone: '2133734253',
|
|
223
|
-
ext: '123'
|
|
224
|
-
}, 'INTERNATIONAL')).to.equal('+1 213 373 4253 ext. 123');
|
|
225
|
-
|
|
226
|
-
// International
|
|
227
|
-
(0, _chai.expect)(formatNumber({
|
|
228
|
-
country: 'US',
|
|
229
|
-
phone: '2133734253',
|
|
230
|
-
ext: '123'
|
|
231
|
-
}, 'INTERNATIONAL')).to.equal('+1 213 373 4253 ext. 123');
|
|
232
|
-
|
|
233
|
-
// E.164
|
|
234
|
-
(0, _chai.expect)(formatNumber({
|
|
235
|
-
country: 'US',
|
|
236
|
-
phone: '2133734253',
|
|
237
|
-
ext: '123'
|
|
238
|
-
}, 'E.164')).to.equal('+12133734253');
|
|
239
|
-
|
|
240
|
-
// RFC3966
|
|
241
|
-
(0, _chai.expect)(formatNumber({
|
|
242
|
-
country: 'US',
|
|
243
|
-
phone: '2133734253',
|
|
244
|
-
ext: '123'
|
|
245
|
-
}, 'RFC3966')).to.equal('tel:+12133734253;ext=123');
|
|
246
|
-
|
|
247
|
-
// Custom ext prefix.
|
|
248
|
-
(0, _chai.expect)(formatNumber({
|
|
249
|
-
country: 'GB',
|
|
250
|
-
phone: '7912345678',
|
|
251
|
-
ext: '123'
|
|
252
|
-
}, 'INTERNATIONAL')).to.equal('+44 7912 345678 x123');
|
|
253
|
-
});
|
|
254
|
-
(0, _mocha.it)('should work with Argentina numbers', function () {
|
|
255
|
-
// The same mobile number is written differently
|
|
256
|
-
// in different formats in Argentina:
|
|
257
|
-
// `9` gets prepended in international format.
|
|
258
|
-
(0, _chai.expect)(formatNumber({
|
|
259
|
-
country: 'AR',
|
|
260
|
-
phone: '3435551212'
|
|
261
|
-
}, 'INTERNATIONAL')).to.equal('+54 3435 55 1212');
|
|
262
|
-
(0, _chai.expect)(formatNumber({
|
|
263
|
-
country: 'AR',
|
|
264
|
-
phone: '3435551212'
|
|
265
|
-
}, 'NATIONAL')).to.equal('03435 55-1212');
|
|
266
|
-
});
|
|
267
|
-
(0, _mocha.it)('should work with Mexico numbers', function () {
|
|
268
|
-
// Fixed line.
|
|
269
|
-
(0, _chai.expect)(formatNumber({
|
|
270
|
-
country: 'MX',
|
|
271
|
-
phone: '4499780001'
|
|
272
|
-
}, 'INTERNATIONAL')).to.equal('+52 449 978 0001');
|
|
273
|
-
(0, _chai.expect)(formatNumber({
|
|
274
|
-
country: 'MX',
|
|
275
|
-
phone: '4499780001'
|
|
276
|
-
}, 'NATIONAL')).to.equal('449 978 0001');
|
|
277
|
-
// or '(449)978-0001'.
|
|
278
|
-
// Mobile.
|
|
279
|
-
// `1` is prepended before area code to mobile numbers in international format.
|
|
280
|
-
(0, _chai.expect)(formatNumber({
|
|
281
|
-
country: 'MX',
|
|
282
|
-
phone: '3312345678'
|
|
283
|
-
}, 'INTERNATIONAL')).to.equal('+52 33 1234 5678');
|
|
284
|
-
(0, _chai.expect)(formatNumber({
|
|
285
|
-
country: 'MX',
|
|
286
|
-
phone: '3312345678'
|
|
287
|
-
}, 'NATIONAL')).to.equal('33 1234 5678');
|
|
288
|
-
// or '045 33 1234-5678'.
|
|
289
|
-
});
|
|
290
|
-
(0, _mocha.it)('should format possible numbers', function () {
|
|
291
|
-
(0, _chai.expect)(formatNumber({
|
|
292
|
-
countryCallingCode: '7',
|
|
293
|
-
phone: '1111111111'
|
|
294
|
-
}, 'E.164')).to.equal('+71111111111');
|
|
295
|
-
(0, _chai.expect)(formatNumber({
|
|
296
|
-
countryCallingCode: '7',
|
|
297
|
-
phone: '1111111111'
|
|
298
|
-
}, 'NATIONAL')).to.equal('1111111111');
|
|
299
|
-
(0, _chai.expect)(formatNumber({
|
|
300
|
-
countryCallingCode: '7',
|
|
301
|
-
phone: '1111111111'
|
|
302
|
-
}, 'INTERNATIONAL')).to.equal('+7 1111111111');
|
|
303
|
-
});
|
|
304
|
-
(0, _mocha.it)('should format IDD-prefixed number', function () {
|
|
305
|
-
// No `fromCountry`.
|
|
306
|
-
(0, _chai.expect)(formatNumber('+78005553535', 'IDD')).to.be.undefined;
|
|
307
|
-
|
|
308
|
-
// No default IDD prefix.
|
|
309
|
-
(0, _chai.expect)(formatNumber('+78005553535', 'IDD', {
|
|
310
|
-
fromCountry: 'BO'
|
|
311
|
-
})).to.be.undefined;
|
|
312
|
-
|
|
313
|
-
// Same country calling code.
|
|
314
|
-
(0, _chai.expect)(formatNumber('+12133734253', 'IDD', {
|
|
315
|
-
fromCountry: 'CA'
|
|
316
|
-
})).to.equal('1 (213) 373-4253');
|
|
317
|
-
(0, _chai.expect)(formatNumber('+78005553535', 'IDD', {
|
|
318
|
-
fromCountry: 'KZ'
|
|
319
|
-
})).to.equal('8 (800) 555-35-35');
|
|
320
|
-
|
|
321
|
-
// formatNumber('+78005553535', 'IDD', { fromCountry: 'US' }).should.equal('01178005553535')
|
|
322
|
-
(0, _chai.expect)(formatNumber('+78005553535', 'IDD', {
|
|
323
|
-
fromCountry: 'US'
|
|
324
|
-
})).to.equal('011 7 800 555 35 35');
|
|
325
|
-
});
|
|
326
|
-
(0, _mocha.it)('should format non-geographic numbering plan phone numbers', function () {
|
|
327
|
-
// https://github.com/catamphetamine/libphonenumber-js/issues/323
|
|
328
|
-
(0, _chai.expect)(formatNumber('+870773111632', 'INTERNATIONAL')).to.equal('+870 773 111 632');
|
|
329
|
-
(0, _chai.expect)(formatNumber('+870773111632', 'NATIONAL')).to.equal('773 111 632');
|
|
330
|
-
});
|
|
331
|
-
(0, _mocha.it)('should use the default IDD prefix when formatting a phone number', function () {
|
|
332
|
-
// Testing preferred international prefixes with ~ are supported.
|
|
333
|
-
// ("~" designates waiting on a line until proceeding with the input).
|
|
334
|
-
(0, _chai.expect)(formatNumber('+390236618300', 'IDD', {
|
|
335
|
-
fromCountry: 'BY'
|
|
336
|
-
})).to.equal('8~10 39 02 3661 8300');
|
|
337
|
-
});
|
|
338
|
-
});
|
|
339
|
-
//# sourceMappingURL=format.test.js.map
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _mocha = require("mocha");
|
|
4
|
-
var _chai = require("chai");
|
|
5
|
-
var _formatIncompletePhoneNumber = _interopRequireDefault(require("./formatIncompletePhoneNumber.js"));
|
|
6
|
-
var _metadataMin = _interopRequireDefault(require("../metadata.min.json"));
|
|
7
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
8
|
-
(0, _mocha.describe)('formatIncompletePhoneNumber', function () {
|
|
9
|
-
(0, _mocha.it)('should format parsed input value', function () {
|
|
10
|
-
var result;
|
|
11
|
-
|
|
12
|
-
// National input.
|
|
13
|
-
(0, _chai.expect)((0, _formatIncompletePhoneNumber["default"])('880055535', 'RU', _metadataMin["default"])).to.equal('8 (800) 555-35');
|
|
14
|
-
|
|
15
|
-
// International input, no country.
|
|
16
|
-
(0, _chai.expect)((0, _formatIncompletePhoneNumber["default"])('+780055535', null, _metadataMin["default"])).to.equal('+7 800 555 35');
|
|
17
|
-
|
|
18
|
-
// International input, no country argument.
|
|
19
|
-
(0, _chai.expect)((0, _formatIncompletePhoneNumber["default"])('+780055535', _metadataMin["default"])).to.equal('+7 800 555 35');
|
|
20
|
-
|
|
21
|
-
// International input, with country.
|
|
22
|
-
(0, _chai.expect)((0, _formatIncompletePhoneNumber["default"])('+780055535', 'RU', _metadataMin["default"])).to.equal('+7 800 555 35');
|
|
23
|
-
});
|
|
24
|
-
(0, _mocha.it)('should support an object argument', function () {
|
|
25
|
-
(0, _chai.expect)((0, _formatIncompletePhoneNumber["default"])('880055535', {
|
|
26
|
-
defaultCountry: 'RU'
|
|
27
|
-
}, _metadataMin["default"])).to.equal('8 (800) 555-35');
|
|
28
|
-
(0, _chai.expect)((0, _formatIncompletePhoneNumber["default"])('880055535', {
|
|
29
|
-
defaultCallingCode: '7'
|
|
30
|
-
}, _metadataMin["default"])).to.equal('8 (800) 555-35');
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
//# sourceMappingURL=formatIncompletePhoneNumber.test.js.map
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _mocha = require("mocha");
|
|
4
|
-
var _chai = require("chai");
|
|
5
|
-
var _metadataMin = _interopRequireDefault(require("../metadata.min.json"));
|
|
6
|
-
var _getCountries = _interopRequireDefault(require("./getCountries.js"));
|
|
7
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
8
|
-
(0, _mocha.describe)('getCountries', function () {
|
|
9
|
-
(0, _mocha.it)('should get countries list', function () {
|
|
10
|
-
(0, _chai.expect)((0, _getCountries["default"])(_metadataMin["default"]).indexOf('RU') > 0).to.equal(true);
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
//# sourceMappingURL=getCountries.test.js.map
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _mocha = require("mocha");
|
|
4
|
-
var _chai = require("chai");
|
|
5
|
-
var _metadataMin = _interopRequireDefault(require("../metadata.min.json"));
|
|
6
|
-
var _getCountryCallingCode = _interopRequireDefault(require("./getCountryCallingCode.js"));
|
|
7
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
8
|
-
(0, _mocha.describe)('getCountryCallingCode', function () {
|
|
9
|
-
(0, _mocha.it)('should get country calling code', function () {
|
|
10
|
-
(0, _chai.expect)((0, _getCountryCallingCode["default"])('US', _metadataMin["default"])).to.equal('1');
|
|
11
|
-
});
|
|
12
|
-
(0, _mocha.it)('should throw if country is unknown', function () {
|
|
13
|
-
(0, _chai.expect)(function () {
|
|
14
|
-
return (0, _getCountryCallingCode["default"])('ZZ', _metadataMin["default"]);
|
|
15
|
-
}).to["throw"]('Unknown country: ZZ');
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
//# sourceMappingURL=getCountryCallingCode.test.js.map
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _mocha = require("mocha");
|
|
4
|
-
var _chai = require("chai");
|
|
5
|
-
var _examplesMobile = _interopRequireDefault(require("../examples.mobile.json"));
|
|
6
|
-
var _metadataMin = _interopRequireDefault(require("../metadata.min.json"));
|
|
7
|
-
var _getExampleNumber = _interopRequireDefault(require("./getExampleNumber.js"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
9
|
-
(0, _mocha.describe)('getExampleNumber', function () {
|
|
10
|
-
(0, _mocha.it)('should get an example number', function () {
|
|
11
|
-
var phoneNumber = (0, _getExampleNumber["default"])('RU', _examplesMobile["default"], _metadataMin["default"]);
|
|
12
|
-
(0, _chai.expect)(phoneNumber.nationalNumber).to.equal('9123456789');
|
|
13
|
-
(0, _chai.expect)(phoneNumber.number).to.equal('+79123456789');
|
|
14
|
-
(0, _chai.expect)(phoneNumber.countryCallingCode).to.equal('7');
|
|
15
|
-
(0, _chai.expect)(phoneNumber.country).to.equal('RU');
|
|
16
|
-
});
|
|
17
|
-
(0, _mocha.it)('should handle a non-existing country', function () {
|
|
18
|
-
(0, _chai.expect)((0, _getExampleNumber["default"])('XX', _examplesMobile["default"], _metadataMin["default"])).to.be.undefined;
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
//# sourceMappingURL=getExampleNumber.test.js.map
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _mocha = require("mocha");
|
|
4
|
-
var _chai = require("chai");
|
|
5
|
-
var _RFC = require("./RFC3966.js");
|
|
6
|
-
(0, _mocha.describe)('RFC3966', function () {
|
|
7
|
-
(0, _mocha.it)('should format', function () {
|
|
8
|
-
(0, _chai.expect)(function () {
|
|
9
|
-
return (0, _RFC.formatRFC3966)({
|
|
10
|
-
number: '123'
|
|
11
|
-
});
|
|
12
|
-
}).to["throw"]('expects "number" to be in E.164 format');
|
|
13
|
-
(0, _chai.expect)((0, _RFC.formatRFC3966)({})).to.equal('');
|
|
14
|
-
(0, _chai.expect)((0, _RFC.formatRFC3966)({
|
|
15
|
-
number: '+78005553535'
|
|
16
|
-
})).to.equal('tel:+78005553535');
|
|
17
|
-
(0, _chai.expect)((0, _RFC.formatRFC3966)({
|
|
18
|
-
number: '+78005553535',
|
|
19
|
-
ext: '123'
|
|
20
|
-
})).to.equal('tel:+78005553535;ext=123');
|
|
21
|
-
});
|
|
22
|
-
(0, _mocha.it)('should parse', function () {
|
|
23
|
-
(0, _chai.expect)((0, _RFC.parseRFC3966)('tel:+78005553535')).to.deep.equal({
|
|
24
|
-
number: '+78005553535'
|
|
25
|
-
});
|
|
26
|
-
(0, _chai.expect)((0, _RFC.parseRFC3966)('tel:+78005553535;ext=123')).to.deep.equal({
|
|
27
|
-
number: '+78005553535',
|
|
28
|
-
ext: '123'
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
// With `phone-context`
|
|
32
|
-
(0, _chai.expect)((0, _RFC.parseRFC3966)('tel:8005553535;ext=123;phone-context=+7')).to.deep.equal({
|
|
33
|
-
number: '+78005553535',
|
|
34
|
-
ext: '123'
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
// "Domain contexts" are ignored
|
|
38
|
-
(0, _chai.expect)((0, _RFC.parseRFC3966)('tel:8005553535;ext=123;phone-context=www.leningrad.spb.ru')).to.deep.equal({
|
|
39
|
-
number: '8005553535',
|
|
40
|
-
ext: '123'
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
// Not a viable phone number.
|
|
44
|
-
(0, _chai.expect)((0, _RFC.parseRFC3966)('tel:3')).to.deep.equal({});
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
//# sourceMappingURL=RFC3966.test.js.map
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _mocha = require("mocha");
|
|
4
|
-
var _chai = require("chai");
|
|
5
|
-
var _applyInternationalSeparatorStyle = _interopRequireDefault(require("./applyInternationalSeparatorStyle.js"));
|
|
6
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
7
|
-
(0, _mocha.describe)('applyInternationalSeparatorStyle', function () {
|
|
8
|
-
(0, _mocha.it)('should change Google\'s international format style', function () {
|
|
9
|
-
(0, _chai.expect)((0, _applyInternationalSeparatorStyle["default"])('(xxx) xxx-xx-xx')).to.equal('xxx xxx xx xx');
|
|
10
|
-
(0, _chai.expect)((0, _applyInternationalSeparatorStyle["default"])('(xxx)xxx')).to.equal('xxx xxx');
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
//# sourceMappingURL=applyInternationalSeparatorStyle.test.js.map
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
-
var _mocha = require("mocha");
|
|
5
|
-
var _chai = require("chai");
|
|
6
|
-
var _metadata2 = _interopRequireDefault(require("../metadata.js"));
|
|
7
|
-
var _metadataMax = _interopRequireDefault(require("../../metadata.max.json"));
|
|
8
|
-
var _metadataMin = _interopRequireDefault(require("../../test/metadata/1.0.0/metadata.min.json"));
|
|
9
|
-
var _checkNumberLength = _interopRequireWildcard(require("./checkNumberLength.js"));
|
|
10
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
12
|
-
(0, _mocha.describe)('checkNumberLength', function () {
|
|
13
|
-
(0, _mocha.it)('should check phone number length', function () {
|
|
14
|
-
// Too short.
|
|
15
|
-
(0, _chai.expect)(checkNumberLengthWithCountry('800555353', 'RU', 'FIXED_LINE')).to.equal('TOO_SHORT');
|
|
16
|
-
// Normal.
|
|
17
|
-
(0, _chai.expect)(checkNumberLengthWithCountry('8005553535', 'RU', 'FIXED_LINE')).to.equal('IS_POSSIBLE');
|
|
18
|
-
// Too long.
|
|
19
|
-
(0, _chai.expect)(checkNumberLengthWithCountry('80055535355', 'RU', 'FIXED_LINE')).to.equal('TOO_LONG');
|
|
20
|
-
|
|
21
|
-
// No such type.
|
|
22
|
-
(0, _chai.expect)(checkNumberLengthWithCountry('169454850', 'AC', 'VOIP')).to.equal('INVALID_LENGTH');
|
|
23
|
-
// No such possible length.
|
|
24
|
-
(0, _chai.expect)(checkNumberLengthWithCountry('1694548', 'AD', undefined)).to.equal('INVALID_LENGTH');
|
|
25
|
-
|
|
26
|
-
// FIXED_LINE_OR_MOBILE
|
|
27
|
-
(0, _chai.expect)(checkNumberLengthWithCountry('1694548', 'AD', 'FIXED_LINE_OR_MOBILE')).to.equal('INVALID_LENGTH');
|
|
28
|
-
// No mobile phones.
|
|
29
|
-
(0, _chai.expect)(checkNumberLengthWithCountry('8123', 'TA', 'FIXED_LINE_OR_MOBILE')).to.equal('IS_POSSIBLE');
|
|
30
|
-
// No "possible lengths" for "mobile".
|
|
31
|
-
(0, _chai.expect)(checkNumberLengthWithCountry('81234567', 'SZ', 'FIXED_LINE_OR_MOBILE')).to.equal('IS_POSSIBLE');
|
|
32
|
-
});
|
|
33
|
-
(0, _mocha.it)('should check phone number length (no `country` specified)', function () {
|
|
34
|
-
// Too short.
|
|
35
|
-
(0, _chai.expect)(checkNumberLengthWithoutCountry('800555353', 'RU', 'FIXED_LINE')).to.equal('TOO_SHORT');
|
|
36
|
-
// Normal.
|
|
37
|
-
(0, _chai.expect)(checkNumberLengthWithoutCountry('8005553535', 'RU', 'FIXED_LINE')).to.equal('IS_POSSIBLE');
|
|
38
|
-
// Too long.
|
|
39
|
-
(0, _chai.expect)(checkNumberLengthWithoutCountry('80055535355', 'RU', 'FIXED_LINE')).to.equal('TOO_LONG');
|
|
40
|
-
|
|
41
|
-
// No such type.
|
|
42
|
-
(0, _chai.expect)(checkNumberLengthWithoutCountry('169454850', 'AC', 'VOIP')).to.equal('INVALID_LENGTH');
|
|
43
|
-
// No such possible length.
|
|
44
|
-
(0, _chai.expect)(checkNumberLengthWithoutCountry('1694548', 'AD', undefined)).to.equal('INVALID_LENGTH');
|
|
45
|
-
|
|
46
|
-
// FIXED_LINE_OR_MOBILE
|
|
47
|
-
(0, _chai.expect)(checkNumberLengthWithoutCountry('1694548', 'AD', 'FIXED_LINE_OR_MOBILE')).to.equal('INVALID_LENGTH');
|
|
48
|
-
// No mobile phones.
|
|
49
|
-
(0, _chai.expect)(checkNumberLengthWithoutCountry('8123', 'TA', 'FIXED_LINE_OR_MOBILE')).to.equal('IS_POSSIBLE');
|
|
50
|
-
// No "possible lengths" for "mobile".
|
|
51
|
-
(0, _chai.expect)(checkNumberLengthWithoutCountry('81234567', 'SZ', 'FIXED_LINE_OR_MOBILE')).to.equal('IS_POSSIBLE');
|
|
52
|
-
});
|
|
53
|
-
(0, _mocha.it)('should work for old metadata', function () {
|
|
54
|
-
var _oldMetadata = new _metadata2["default"](_metadataMin["default"]);
|
|
55
|
-
_oldMetadata.country('RU');
|
|
56
|
-
(0, _chai.expect)((0, _checkNumberLength.checkNumberLengthForType)('8005553535', 'RU', 'FIXED_LINE', _oldMetadata)).to.equal('IS_POSSIBLE');
|
|
57
|
-
});
|
|
58
|
-
(0, _mocha.it)('should work for old metadata (no `country` specified)', function () {
|
|
59
|
-
var _oldMetadata = new _metadata2["default"](_metadataMin["default"]);
|
|
60
|
-
_oldMetadata.country('RU');
|
|
61
|
-
(0, _chai.expect)((0, _checkNumberLength.checkNumberLengthForType)('8005553535', undefined, 'FIXED_LINE', _oldMetadata)).to.equal('IS_POSSIBLE');
|
|
62
|
-
});
|
|
63
|
-
(0, _mocha.it)('should handle the cases when multiple countries share the same country calling code and a phone number is possible in non-"main" country and is not possible in the "main" country', function () {
|
|
64
|
-
var _metadata = new _metadata2["default"](_metadataMax["default"]);
|
|
65
|
-
_metadata.country('US');
|
|
66
|
-
(0, _chai.expect)((0, _checkNumberLength["default"])('3100000', undefined, _metadata)).to.equal('TOO_SHORT');
|
|
67
|
-
(0, _chai.expect)((0, _checkNumberLength["default"])('3100000', 'US', _metadata)).to.equal('TOO_SHORT');
|
|
68
|
-
(0, _chai.expect)((0, _checkNumberLength["default"])('3100000', 'CA', _metadata)).to.equal('IS_POSSIBLE');
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
function checkNumberLengthWithCountry(number, country, type) {
|
|
72
|
-
var _metadata = new _metadata2["default"](_metadataMax["default"]);
|
|
73
|
-
_metadata.country(country);
|
|
74
|
-
return (0, _checkNumberLength.checkNumberLengthForType)(number, country, type, _metadata);
|
|
75
|
-
}
|
|
76
|
-
function checkNumberLengthWithoutCountry(number, country, type) {
|
|
77
|
-
var _metadata = new _metadata2["default"](_metadataMax["default"]);
|
|
78
|
-
_metadata.country(country);
|
|
79
|
-
return (0, _checkNumberLength.checkNumberLengthForType)(number, undefined, type, _metadata);
|
|
80
|
-
}
|
|
81
|
-
//# sourceMappingURL=checkNumberLength.test.js.map
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _mocha = require("mocha");
|
|
4
|
-
var _chai = require("chai");
|
|
5
|
-
var _extractCountryCallingCode = _interopRequireDefault(require("./extractCountryCallingCode.js"));
|
|
6
|
-
var _metadataMin = _interopRequireDefault(require("../../metadata.min.json"));
|
|
7
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
8
|
-
(0, _mocha.describe)('extractCountryCallingCode', function () {
|
|
9
|
-
(0, _mocha.it)('should extract country calling code from a number', function () {
|
|
10
|
-
(0, _chai.expect)((0, _extractCountryCallingCode["default"])('+78005553535', null, null, null, _metadataMin["default"])).to.deep.equal({
|
|
11
|
-
countryCallingCodeSource: 'FROM_NUMBER_WITH_PLUS_SIGN',
|
|
12
|
-
countryCallingCode: '7',
|
|
13
|
-
number: '8005553535'
|
|
14
|
-
});
|
|
15
|
-
(0, _chai.expect)((0, _extractCountryCallingCode["default"])('+7800', null, null, null, _metadataMin["default"])).to.deep.equal({
|
|
16
|
-
countryCallingCodeSource: 'FROM_NUMBER_WITH_PLUS_SIGN',
|
|
17
|
-
countryCallingCode: '7',
|
|
18
|
-
number: '800'
|
|
19
|
-
});
|
|
20
|
-
(0, _chai.expect)((0, _extractCountryCallingCode["default"])('', null, null, null, _metadataMin["default"])).to.deep.equal({});
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
//# sourceMappingURL=extractCountryCallingCode.test.js.map
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _mocha = require("mocha");
|
|
4
|
-
var _chai = require("chai");
|
|
5
|
-
var _extractNationalNumber = _interopRequireDefault(require("./extractNationalNumber.js"));
|
|
6
|
-
var _metadata = _interopRequireDefault(require("../metadata.js"));
|
|
7
|
-
var _metadataMin = _interopRequireDefault(require("../../test/metadata/1.0.0/metadata.min.json"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
9
|
-
(0, _mocha.describe)('extractNationalNumber', function () {
|
|
10
|
-
(0, _mocha.it)('should extract a national number when using old metadata (no `country` or `defaultCountry` specified)', function () {
|
|
11
|
-
var _oldMetadata = new _metadata["default"](_metadataMin["default"]);
|
|
12
|
-
_oldMetadata.selectNumberingPlan('RU');
|
|
13
|
-
(0, _chai.expect)((0, _extractNationalNumber["default"])('88005553535', undefined, _oldMetadata)).to.deep.equal({
|
|
14
|
-
nationalNumber: '8005553535',
|
|
15
|
-
carrierCode: undefined
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
(0, _mocha.it)('should extract a national number when using old metadata (`country` is specified)', function () {
|
|
19
|
-
var _oldMetadata = new _metadata["default"](_metadataMin["default"]);
|
|
20
|
-
_oldMetadata.selectNumberingPlan('RU');
|
|
21
|
-
(0, _chai.expect)((0, _extractNationalNumber["default"])('88005553535', 'RU', _oldMetadata)).to.deep.equal({
|
|
22
|
-
nationalNumber: '8005553535',
|
|
23
|
-
carrierCode: undefined
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
//# sourceMappingURL=extractNationalNumber.test.js.map
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _mocha = require("mocha");
|
|
4
|
-
var _chai = require("chai");
|
|
5
|
-
var _metadata = _interopRequireDefault(require("../metadata.js"));
|
|
6
|
-
var _metadataMin = _interopRequireDefault(require("../../metadata.min.json"));
|
|
7
|
-
var _extractNationalNumberFromPossiblyIncompleteNumber = _interopRequireDefault(require("./extractNationalNumberFromPossiblyIncompleteNumber.js"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
9
|
-
(0, _mocha.describe)('extractNationalNumberFromPossiblyIncompleteNumber', function () {
|
|
10
|
-
(0, _mocha.it)('should parse a carrier code when there is no national prefix transform rule', function () {
|
|
11
|
-
var meta = new _metadata["default"](_metadataMin["default"]);
|
|
12
|
-
meta.country('AU');
|
|
13
|
-
(0, _chai.expect)((0, _extractNationalNumberFromPossiblyIncompleteNumber["default"])('18311800123', meta)).to.deep.equal({
|
|
14
|
-
nationalPrefix: undefined,
|
|
15
|
-
carrierCode: '1831',
|
|
16
|
-
nationalNumber: '1800123'
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
//# sourceMappingURL=extractNationalNumberFromPossiblyIncompleteNumber.test.js.map
|