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
|
@@ -1,499 +0,0 @@
|
|
|
1
|
-
import { describe, it } from 'mocha';
|
|
2
|
-
import { expect } from 'chai';
|
|
3
|
-
import PatternMatcher from './AsYouTypeFormatter.PatternMatcher.js';
|
|
4
|
-
describe('AsYouTypeFormatter.PatternMatcher', function () {
|
|
5
|
-
it('should throw when no pattern is passed', function () {
|
|
6
|
-
expect(function () {
|
|
7
|
-
return new PatternMatcher();
|
|
8
|
-
}).to["throw"]('Pattern is required');
|
|
9
|
-
});
|
|
10
|
-
it('should throw when no string is passed', function () {
|
|
11
|
-
var matcher = new PatternMatcher('1');
|
|
12
|
-
expect(function () {
|
|
13
|
-
return matcher.match();
|
|
14
|
-
}).to["throw"]('String is required');
|
|
15
|
-
});
|
|
16
|
-
it('should throw on illegal characters', function () {
|
|
17
|
-
expect(function () {
|
|
18
|
-
return new PatternMatcher('4(5|6)7');
|
|
19
|
-
}).to["throw"]('Illegal characters');
|
|
20
|
-
});
|
|
21
|
-
it('should throw on an illegal ] operator', function () {
|
|
22
|
-
expect(function () {
|
|
23
|
-
return new PatternMatcher('4]7');
|
|
24
|
-
}).to["throw"]('"]" operator must be preceded by "[" operator');
|
|
25
|
-
});
|
|
26
|
-
it('should throw on an illegal - operator in a one-of set', function () {
|
|
27
|
-
expect(function () {
|
|
28
|
-
return new PatternMatcher('[-5]');
|
|
29
|
-
}).to["throw"]('Couldn\'t parse a one-of set pattern: -5');
|
|
30
|
-
});
|
|
31
|
-
it('should throw on a non-finalized context', function () {
|
|
32
|
-
expect(function () {
|
|
33
|
-
return new PatternMatcher('4(?:5|7');
|
|
34
|
-
}).to["throw"]('Non-finalized contexts left when pattern parse ended');
|
|
35
|
-
});
|
|
36
|
-
it('should throw on an illegal (|) operator', function () {
|
|
37
|
-
expect(function () {
|
|
38
|
-
return new PatternMatcher('4(?:5|)7');
|
|
39
|
-
}).to["throw"]('No instructions found after "|" operator in an "or" group');
|
|
40
|
-
});
|
|
41
|
-
it('should throw on an illegal ) operator', function () {
|
|
42
|
-
expect(function () {
|
|
43
|
-
return new PatternMatcher('4[56)]7');
|
|
44
|
-
}).to["throw"]('")" operator must be preceded by "(?:" operator');
|
|
45
|
-
});
|
|
46
|
-
it('should throw on an illegal | operator', function () {
|
|
47
|
-
expect(function () {
|
|
48
|
-
return new PatternMatcher('4[5|6]7');
|
|
49
|
-
}).to["throw"]('operator can only be used inside "or" groups');
|
|
50
|
-
});
|
|
51
|
-
it('should match a one-digit pattern', function () {
|
|
52
|
-
var matcher = new PatternMatcher('4');
|
|
53
|
-
expect(matcher.match('1')).to.be.undefined;
|
|
54
|
-
expect(matcher.match('4')).to.deep.equal({
|
|
55
|
-
match: true
|
|
56
|
-
});
|
|
57
|
-
expect(matcher.match('44')).to.be.undefined;
|
|
58
|
-
expect(matcher.match('44', {
|
|
59
|
-
allowOverflow: true
|
|
60
|
-
})).to.deep.equal({
|
|
61
|
-
overflow: true
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
it('should match a two-digit pattern', function () {
|
|
65
|
-
var matcher = new PatternMatcher('44');
|
|
66
|
-
expect(matcher.match('1')).to.be.undefined;
|
|
67
|
-
expect(matcher.match('4')).to.deep.equal({
|
|
68
|
-
partialMatch: true
|
|
69
|
-
});
|
|
70
|
-
expect(matcher.match('44')).to.deep.equal({
|
|
71
|
-
match: true
|
|
72
|
-
});
|
|
73
|
-
expect(matcher.match('444')).to.be.undefined;
|
|
74
|
-
expect(matcher.match('444', {
|
|
75
|
-
allowOverflow: true
|
|
76
|
-
})).to.deep.equal({
|
|
77
|
-
overflow: true
|
|
78
|
-
});
|
|
79
|
-
expect(matcher.match('55')).to.be.undefined;
|
|
80
|
-
});
|
|
81
|
-
it('should match a one-digit one-of set (single digit)', function () {
|
|
82
|
-
var matcher = new PatternMatcher('[4]');
|
|
83
|
-
expect(matcher.match('1')).to.be.undefined;
|
|
84
|
-
expect(matcher.match('4')).to.deep.equal({
|
|
85
|
-
match: true
|
|
86
|
-
});
|
|
87
|
-
expect(matcher.match('44')).to.be.undefined;
|
|
88
|
-
expect(matcher.match('44', {
|
|
89
|
-
allowOverflow: true
|
|
90
|
-
})).to.deep.equal({
|
|
91
|
-
overflow: true
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
it('should match a one-digit one-of set (multiple digits)', function () {
|
|
95
|
-
var matcher = new PatternMatcher('[479]');
|
|
96
|
-
expect(matcher.match('1')).to.be.undefined;
|
|
97
|
-
expect(matcher.match('4')).to.deep.equal({
|
|
98
|
-
match: true
|
|
99
|
-
});
|
|
100
|
-
expect(matcher.match('44')).to.be.undefined;
|
|
101
|
-
expect(matcher.match('44', {
|
|
102
|
-
allowOverflow: true
|
|
103
|
-
})).to.deep.equal({
|
|
104
|
-
overflow: true
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
it('should match a one-digit one-of set using a dash notation (not inclusive)', function () {
|
|
108
|
-
var matcher = new PatternMatcher('[2-5]');
|
|
109
|
-
expect(matcher.match('1')).to.be.undefined;
|
|
110
|
-
expect(matcher.match('4')).to.deep.equal({
|
|
111
|
-
match: true
|
|
112
|
-
});
|
|
113
|
-
expect(matcher.match('44')).to.be.undefined;
|
|
114
|
-
expect(matcher.match('44', {
|
|
115
|
-
allowOverflow: true
|
|
116
|
-
})).to.deep.equal({
|
|
117
|
-
overflow: true
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
it('should match a one-digit one-of set using a dash notation (inclusive)', function () {
|
|
121
|
-
var matcher = new PatternMatcher('[3-4]');
|
|
122
|
-
expect(matcher.match('1')).to.be.undefined;
|
|
123
|
-
expect(matcher.match('4')).to.deep.equal({
|
|
124
|
-
match: true
|
|
125
|
-
});
|
|
126
|
-
expect(matcher.match('44')).to.be.undefined;
|
|
127
|
-
expect(matcher.match('44', {
|
|
128
|
-
allowOverflow: true
|
|
129
|
-
})).to.deep.equal({
|
|
130
|
-
overflow: true
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
it('should match a one-digit one-of set including a dash notation', function () {
|
|
134
|
-
var matcher = new PatternMatcher('[124-68]');
|
|
135
|
-
expect(matcher.match('0')).to.be.undefined;
|
|
136
|
-
expect(matcher.match('1')).to.deep.equal({
|
|
137
|
-
match: true
|
|
138
|
-
});
|
|
139
|
-
expect(matcher.match('2')).to.deep.equal({
|
|
140
|
-
match: true
|
|
141
|
-
});
|
|
142
|
-
expect(matcher.match('3')).to.be.undefined;
|
|
143
|
-
expect(matcher.match('4')).to.deep.equal({
|
|
144
|
-
match: true
|
|
145
|
-
});
|
|
146
|
-
expect(matcher.match('5')).to.deep.equal({
|
|
147
|
-
match: true
|
|
148
|
-
});
|
|
149
|
-
expect(matcher.match('6')).to.deep.equal({
|
|
150
|
-
match: true
|
|
151
|
-
});
|
|
152
|
-
expect(matcher.match('7')).to.be.undefined;
|
|
153
|
-
expect(matcher.match('8')).to.deep.equal({
|
|
154
|
-
match: true
|
|
155
|
-
});
|
|
156
|
-
expect(matcher.match('9')).to.be.undefined;
|
|
157
|
-
expect(matcher.match('88')).to.be.undefined;
|
|
158
|
-
expect(matcher.match('88', {
|
|
159
|
-
allowOverflow: true
|
|
160
|
-
})).to.deep.equal({
|
|
161
|
-
overflow: true
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
it('should match a two-digit one-of set', function () {
|
|
165
|
-
var matcher = new PatternMatcher('[479][45]');
|
|
166
|
-
expect(matcher.match('1')).to.be.undefined;
|
|
167
|
-
expect(matcher.match('4')).to.deep.equal({
|
|
168
|
-
partialMatch: true
|
|
169
|
-
});
|
|
170
|
-
expect(matcher.match('5')).to.be.undefined;
|
|
171
|
-
expect(matcher.match('55')).to.be.undefined;
|
|
172
|
-
expect(matcher.match('44')).to.deep.equal({
|
|
173
|
-
match: true
|
|
174
|
-
});
|
|
175
|
-
expect(matcher.match('444')).to.be.undefined;
|
|
176
|
-
expect(matcher.match('444', {
|
|
177
|
-
allowOverflow: true
|
|
178
|
-
})).to.deep.equal({
|
|
179
|
-
overflow: true
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
it('should match a two-digit one-of set (regular digit and a one-of set)', function () {
|
|
183
|
-
var matcher = new PatternMatcher('1[45]');
|
|
184
|
-
expect(matcher.match('0')).to.be.undefined;
|
|
185
|
-
expect(matcher.match('1')).to.deep.equal({
|
|
186
|
-
partialMatch: true
|
|
187
|
-
});
|
|
188
|
-
expect(matcher.match('15')).to.deep.equal({
|
|
189
|
-
match: true
|
|
190
|
-
});
|
|
191
|
-
expect(matcher.match('16')).to.be.undefined;
|
|
192
|
-
});
|
|
193
|
-
it('should match a pattern with an or group', function () {
|
|
194
|
-
var matcher = new PatternMatcher('7(?:1[0-68]|2[1-9])');
|
|
195
|
-
expect(matcher.match('1')).to.be.undefined;
|
|
196
|
-
expect(matcher.match('7')).to.deep.equal({
|
|
197
|
-
partialMatch: true
|
|
198
|
-
});
|
|
199
|
-
expect(matcher.match('71')).to.deep.equal({
|
|
200
|
-
partialMatch: true
|
|
201
|
-
});
|
|
202
|
-
expect(matcher.match('73')).to.be.undefined;
|
|
203
|
-
expect(matcher.match('711')).to.deep.equal({
|
|
204
|
-
match: true
|
|
205
|
-
});
|
|
206
|
-
expect(matcher.match('717')).to.be.undefined;
|
|
207
|
-
expect(matcher.match('720')).to.be.undefined;
|
|
208
|
-
expect(matcher.match('722')).to.deep.equal({
|
|
209
|
-
match: true
|
|
210
|
-
});
|
|
211
|
-
expect(matcher.match('7222')).to.be.undefined;
|
|
212
|
-
expect(matcher.match('7222', {
|
|
213
|
-
allowOverflow: true
|
|
214
|
-
})).to.deep.equal({
|
|
215
|
-
overflow: true
|
|
216
|
-
});
|
|
217
|
-
});
|
|
218
|
-
it('should match an or pattern containing or groups', function () {
|
|
219
|
-
var matcher = new PatternMatcher('2(?:2[024-9]|3[0-59]|47|6[245]|9[02-8])|3(?:3[28]|4[03-9]|5[2-46-8]|7[1-578]|8[2-9])');
|
|
220
|
-
expect(matcher.match('1')).to.be.undefined;
|
|
221
|
-
expect(matcher.match('2')).to.deep.equal({
|
|
222
|
-
partialMatch: true
|
|
223
|
-
});
|
|
224
|
-
expect(matcher.match('3')).to.deep.equal({
|
|
225
|
-
partialMatch: true
|
|
226
|
-
});
|
|
227
|
-
expect(matcher.match('4')).to.be.undefined;
|
|
228
|
-
expect(matcher.match('21')).to.be.undefined;
|
|
229
|
-
expect(matcher.match('22')).to.deep.equal({
|
|
230
|
-
partialMatch: true
|
|
231
|
-
});
|
|
232
|
-
expect(matcher.match('221')).to.be.undefined;
|
|
233
|
-
expect(matcher.match('222')).to.deep.equal({
|
|
234
|
-
match: true
|
|
235
|
-
});
|
|
236
|
-
expect(matcher.match('2222')).to.be.undefined;
|
|
237
|
-
expect(matcher.match('2222', {
|
|
238
|
-
allowOverflow: true
|
|
239
|
-
})).to.deep.equal({
|
|
240
|
-
overflow: true
|
|
241
|
-
});
|
|
242
|
-
expect(matcher.match('3')).to.deep.equal({
|
|
243
|
-
partialMatch: true
|
|
244
|
-
});
|
|
245
|
-
expect(matcher.match('33')).to.deep.equal({
|
|
246
|
-
partialMatch: true
|
|
247
|
-
});
|
|
248
|
-
expect(matcher.match('332')).to.deep.equal({
|
|
249
|
-
match: true
|
|
250
|
-
});
|
|
251
|
-
expect(matcher.match('333')).to.be.undefined;
|
|
252
|
-
});
|
|
253
|
-
it('should match an or pattern', function () {
|
|
254
|
-
var matcher = new PatternMatcher('6|8');
|
|
255
|
-
expect(matcher.match('5')).to.be.undefined;
|
|
256
|
-
expect(matcher.match('6')).to.deep.equal({
|
|
257
|
-
match: true
|
|
258
|
-
});
|
|
259
|
-
expect(matcher.match('7')).to.be.undefined;
|
|
260
|
-
expect(matcher.match('8')).to.deep.equal({
|
|
261
|
-
match: true
|
|
262
|
-
});
|
|
263
|
-
});
|
|
264
|
-
it('should match an or pattern (one-of sets)', function () {
|
|
265
|
-
var matcher = new PatternMatcher('[123]|[5-8]');
|
|
266
|
-
expect(matcher.match('0')).to.be.undefined;
|
|
267
|
-
expect(matcher.match('1')).to.deep.equal({
|
|
268
|
-
match: true
|
|
269
|
-
});
|
|
270
|
-
expect(matcher.match('2')).to.deep.equal({
|
|
271
|
-
match: true
|
|
272
|
-
});
|
|
273
|
-
expect(matcher.match('3')).to.deep.equal({
|
|
274
|
-
match: true
|
|
275
|
-
});
|
|
276
|
-
expect(matcher.match('4')).to.be.undefined;
|
|
277
|
-
expect(matcher.match('5')).to.deep.equal({
|
|
278
|
-
match: true
|
|
279
|
-
});
|
|
280
|
-
expect(matcher.match('6')).to.deep.equal({
|
|
281
|
-
match: true
|
|
282
|
-
});
|
|
283
|
-
expect(matcher.match('7')).to.deep.equal({
|
|
284
|
-
match: true
|
|
285
|
-
});
|
|
286
|
-
expect(matcher.match('8')).to.deep.equal({
|
|
287
|
-
match: true
|
|
288
|
-
});
|
|
289
|
-
expect(matcher.match('9')).to.be.undefined;
|
|
290
|
-
expect(matcher.match('18')).to.be.undefined;
|
|
291
|
-
expect(matcher.match('18', {
|
|
292
|
-
allowOverflow: true
|
|
293
|
-
})).to.deep.equal({
|
|
294
|
-
overflow: true
|
|
295
|
-
});
|
|
296
|
-
});
|
|
297
|
-
it('should match an or pattern (different lengths)', function () {
|
|
298
|
-
var matcher = new PatternMatcher('60|8');
|
|
299
|
-
expect(matcher.match('5')).to.be.undefined;
|
|
300
|
-
expect(matcher.match('6')).to.deep.equal({
|
|
301
|
-
partialMatch: true
|
|
302
|
-
});
|
|
303
|
-
expect(matcher.match('60')).to.deep.equal({
|
|
304
|
-
match: true
|
|
305
|
-
});
|
|
306
|
-
expect(matcher.match('61')).to.be.undefined;
|
|
307
|
-
expect(matcher.match('7')).to.be.undefined;
|
|
308
|
-
expect(matcher.match('8')).to.deep.equal({
|
|
309
|
-
match: true
|
|
310
|
-
});
|
|
311
|
-
expect(matcher.match('68')).to.be.undefined;
|
|
312
|
-
});
|
|
313
|
-
it('should match an or pattern (one-of sets) (different lengths)', function () {
|
|
314
|
-
var matcher = new PatternMatcher('[123]|[5-8][2-8]');
|
|
315
|
-
expect(matcher.match('0')).to.be.undefined;
|
|
316
|
-
});
|
|
317
|
-
it('should match an or pattern (one-of sets and regular digits) (different lengths)', function () {
|
|
318
|
-
var matcher = new PatternMatcher('[2358][2-5]|4');
|
|
319
|
-
expect(matcher.match('0')).to.be.undefined;
|
|
320
|
-
expect(matcher.match('2')).to.deep.equal({
|
|
321
|
-
partialMatch: true
|
|
322
|
-
});
|
|
323
|
-
expect(matcher.match('21')).to.be.undefined;
|
|
324
|
-
expect(matcher.match('22')).to.deep.equal({
|
|
325
|
-
match: true
|
|
326
|
-
});
|
|
327
|
-
expect(matcher.match('25')).to.deep.equal({
|
|
328
|
-
match: true
|
|
329
|
-
});
|
|
330
|
-
expect(matcher.match('26')).to.be.undefined;
|
|
331
|
-
expect(matcher.match('222')).to.be.undefined;
|
|
332
|
-
expect(matcher.match('222', {
|
|
333
|
-
allowOverflow: true
|
|
334
|
-
})).to.deep.equal({
|
|
335
|
-
overflow: true
|
|
336
|
-
});
|
|
337
|
-
expect(matcher.match('3')).to.deep.equal({
|
|
338
|
-
partialMatch: true
|
|
339
|
-
});
|
|
340
|
-
expect(matcher.match('4')).to.deep.equal({
|
|
341
|
-
match: true
|
|
342
|
-
});
|
|
343
|
-
expect(matcher.match('6')).to.be.undefined;
|
|
344
|
-
});
|
|
345
|
-
it('should match an or pattern (one-of sets and regular digits mixed) (different lengths)', function () {
|
|
346
|
-
var matcher = new PatternMatcher('[2358]2|4');
|
|
347
|
-
expect(matcher.match('0')).to.be.undefined;
|
|
348
|
-
expect(matcher.match('2')).to.deep.equal({
|
|
349
|
-
partialMatch: true
|
|
350
|
-
});
|
|
351
|
-
expect(matcher.match('21')).to.be.undefined;
|
|
352
|
-
expect(matcher.match('22')).to.deep.equal({
|
|
353
|
-
match: true
|
|
354
|
-
});
|
|
355
|
-
expect(matcher.match('222')).to.be.undefined;
|
|
356
|
-
expect(matcher.match('222', {
|
|
357
|
-
allowOverflow: true
|
|
358
|
-
})).to.deep.equal({
|
|
359
|
-
overflow: true
|
|
360
|
-
});
|
|
361
|
-
expect(matcher.match('3')).to.deep.equal({
|
|
362
|
-
partialMatch: true
|
|
363
|
-
});
|
|
364
|
-
expect(matcher.match('4')).to.deep.equal({
|
|
365
|
-
match: true
|
|
366
|
-
});
|
|
367
|
-
expect(matcher.match('6')).to.be.undefined;
|
|
368
|
-
});
|
|
369
|
-
it('should match an or pattern (one-of sets groups and regular digits mixed) (different lengths)', function () {
|
|
370
|
-
var matcher = new PatternMatcher('1(?:11|[2-9])');
|
|
371
|
-
expect(matcher.match('1')).to.deep.equal({
|
|
372
|
-
partialMatch: true
|
|
373
|
-
});
|
|
374
|
-
expect(matcher.match('10')).to.be.undefined;
|
|
375
|
-
expect(matcher.match('11')).to.deep.equal({
|
|
376
|
-
partialMatch: true
|
|
377
|
-
});
|
|
378
|
-
expect(matcher.match('111')).to.deep.equal({
|
|
379
|
-
match: true
|
|
380
|
-
});
|
|
381
|
-
expect(matcher.match('1111')).to.be.undefined;
|
|
382
|
-
expect(matcher.match('1111', {
|
|
383
|
-
allowOverflow: true
|
|
384
|
-
})).to.deep.equal({
|
|
385
|
-
overflow: true
|
|
386
|
-
});
|
|
387
|
-
expect(matcher.match('12')).to.deep.equal({
|
|
388
|
-
match: true
|
|
389
|
-
});
|
|
390
|
-
expect(matcher.match('122')).to.be.undefined;
|
|
391
|
-
expect(matcher.match('19')).to.deep.equal({
|
|
392
|
-
match: true
|
|
393
|
-
});
|
|
394
|
-
expect(matcher.match('5')).to.be.undefined;
|
|
395
|
-
});
|
|
396
|
-
it('should match nested or groups', function () {
|
|
397
|
-
var matcher = new PatternMatcher('1(?:2(?:3(?:4|5)|6)|7(?:8|9))0');
|
|
398
|
-
expect(matcher.match('1')).to.deep.equal({
|
|
399
|
-
partialMatch: true
|
|
400
|
-
});
|
|
401
|
-
expect(matcher.match('2')).to.be.undefined;
|
|
402
|
-
expect(matcher.match('11')).to.be.undefined;
|
|
403
|
-
expect(matcher.match('12')).to.deep.equal({
|
|
404
|
-
partialMatch: true
|
|
405
|
-
});
|
|
406
|
-
expect(matcher.match('121')).to.be.undefined;
|
|
407
|
-
expect(matcher.match('123')).to.deep.equal({
|
|
408
|
-
partialMatch: true
|
|
409
|
-
});
|
|
410
|
-
expect(matcher.match('1231')).to.be.undefined;
|
|
411
|
-
expect(matcher.match('1234')).to.deep.equal({
|
|
412
|
-
partialMatch: true
|
|
413
|
-
});
|
|
414
|
-
expect(matcher.match('12340')).to.deep.equal({
|
|
415
|
-
match: true
|
|
416
|
-
});
|
|
417
|
-
expect(matcher.match('123401')).to.be.undefined;
|
|
418
|
-
expect(matcher.match('123401', {
|
|
419
|
-
allowOverflow: true
|
|
420
|
-
})).to.deep.equal({
|
|
421
|
-
overflow: true
|
|
422
|
-
});
|
|
423
|
-
expect(matcher.match('12350')).to.deep.equal({
|
|
424
|
-
match: true
|
|
425
|
-
});
|
|
426
|
-
expect(matcher.match('12360')).to.be.undefined;
|
|
427
|
-
expect(matcher.match('1260')).to.deep.equal({
|
|
428
|
-
match: true
|
|
429
|
-
});
|
|
430
|
-
expect(matcher.match('1270')).to.be.undefined;
|
|
431
|
-
expect(matcher.match('1770')).to.be.undefined;
|
|
432
|
-
expect(matcher.match('1780')).to.deep.equal({
|
|
433
|
-
match: true
|
|
434
|
-
});
|
|
435
|
-
expect(matcher.match('1790')).to.deep.equal({
|
|
436
|
-
match: true
|
|
437
|
-
});
|
|
438
|
-
expect(matcher.match('18')).to.be.undefined;
|
|
439
|
-
});
|
|
440
|
-
it('should match complex patterns', function () {
|
|
441
|
-
var matcher = new PatternMatcher('(?:31|4)6|51|6(?:5[0-3579]|[6-9])|7(?:20|32|8)|[89]');
|
|
442
|
-
expect(matcher.match('0')).to.be.undefined;
|
|
443
|
-
expect(matcher.match('3')).to.deep.equal({
|
|
444
|
-
partialMatch: true
|
|
445
|
-
});
|
|
446
|
-
expect(matcher.match('31')).to.deep.equal({
|
|
447
|
-
partialMatch: true
|
|
448
|
-
});
|
|
449
|
-
expect(matcher.match('32')).to.be.undefined;
|
|
450
|
-
expect(matcher.match('316')).to.deep.equal({
|
|
451
|
-
match: true
|
|
452
|
-
});
|
|
453
|
-
expect(matcher.match('315')).to.be.undefined;
|
|
454
|
-
expect(matcher.match('4')).to.deep.equal({
|
|
455
|
-
partialMatch: true
|
|
456
|
-
});
|
|
457
|
-
expect(matcher.match('46')).to.deep.equal({
|
|
458
|
-
match: true
|
|
459
|
-
});
|
|
460
|
-
expect(matcher.match('47')).to.be.undefined;
|
|
461
|
-
expect(matcher.match('5')).to.deep.equal({
|
|
462
|
-
partialMatch: true
|
|
463
|
-
});
|
|
464
|
-
expect(matcher.match('50')).to.be.undefined;
|
|
465
|
-
expect(matcher.match('51')).to.deep.equal({
|
|
466
|
-
match: true
|
|
467
|
-
});
|
|
468
|
-
expect(matcher.match('6')).to.deep.equal({
|
|
469
|
-
partialMatch: true
|
|
470
|
-
});
|
|
471
|
-
expect(matcher.match('64')).to.be.undefined;
|
|
472
|
-
expect(matcher.match('65')).to.deep.equal({
|
|
473
|
-
partialMatch: true
|
|
474
|
-
});
|
|
475
|
-
expect(matcher.match('650')).to.deep.equal({
|
|
476
|
-
match: true
|
|
477
|
-
});
|
|
478
|
-
expect(matcher.match('654')).to.be.undefined;
|
|
479
|
-
expect(matcher.match('69')).to.deep.equal({
|
|
480
|
-
match: true
|
|
481
|
-
});
|
|
482
|
-
expect(matcher.match('8')).to.deep.equal({
|
|
483
|
-
match: true
|
|
484
|
-
});
|
|
485
|
-
expect(matcher.match('9')).to.deep.equal({
|
|
486
|
-
match: true
|
|
487
|
-
});
|
|
488
|
-
});
|
|
489
|
-
it('shouldn\'t match things that shouldn\'t match', function () {
|
|
490
|
-
// There was a bug: "leading digits" `"2"` matched "leading digits pattern" `"90"`.
|
|
491
|
-
// The incorrect `.match()` function result was `{ oveflow: true }`
|
|
492
|
-
// while it should've been `undefined`.
|
|
493
|
-
// https://gitlab.com/catamphetamine/libphonenumber-js/-/issues/66
|
|
494
|
-
expect(new PatternMatcher('2').match('90', {
|
|
495
|
-
allowOverflow: true
|
|
496
|
-
})).to.be.undefined;
|
|
497
|
-
});
|
|
498
|
-
});
|
|
499
|
-
//# sourceMappingURL=AsYouTypeFormatter.PatternMatcher.test.js.map
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { describe, it } from 'mocha';
|
|
2
|
-
import { expect } from 'chai';
|
|
3
|
-
import PatternParser from './AsYouTypeFormatter.PatternParser.js';
|
|
4
|
-
describe('PatternParser', function () {
|
|
5
|
-
it('should parse single-character patterns', function () {
|
|
6
|
-
expect(new PatternParser().parse('2')).to.equal('2');
|
|
7
|
-
});
|
|
8
|
-
it('should parse string patterns', function () {
|
|
9
|
-
expect(new PatternParser().parse('123')).to.deep.equal(['1', '2', '3']);
|
|
10
|
-
});
|
|
11
|
-
it('should parse "one of" patterns', function () {
|
|
12
|
-
expect(new PatternParser().parse('[5-9]')).to.deep.equal({
|
|
13
|
-
op: '[]',
|
|
14
|
-
args: ['5', '6', '7', '8', '9']
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
it('should parse "or" patterns', function () {
|
|
18
|
-
expect(new PatternParser().parse('123|[5-9]')).to.deep.equal({
|
|
19
|
-
op: '|',
|
|
20
|
-
args: [['1', '2', '3'], {
|
|
21
|
-
op: '[]',
|
|
22
|
-
args: ['5', '6', '7', '8', '9']
|
|
23
|
-
}]
|
|
24
|
-
});
|
|
25
|
-
expect(new PatternParser().parse('123|[5-9]0')).to.deep.equal({
|
|
26
|
-
op: '|',
|
|
27
|
-
args: [['1', '2', '3'], [{
|
|
28
|
-
op: '[]',
|
|
29
|
-
args: ['5', '6', '7', '8', '9']
|
|
30
|
-
}, '0']]
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
it('should parse nested "or" patterns', function () {
|
|
34
|
-
expect(new PatternParser().parse('123|(?:2|34)[5-9]')).to.deep.equal({
|
|
35
|
-
op: '|',
|
|
36
|
-
args: [['1', '2', '3'], [{
|
|
37
|
-
op: '|',
|
|
38
|
-
args: ['2', ['3', '4']]
|
|
39
|
-
}, {
|
|
40
|
-
op: '[]',
|
|
41
|
-
args: ['5', '6', '7', '8', '9']
|
|
42
|
-
}]]
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
//# sourceMappingURL=AsYouTypeFormatter.PatternParser.test.js.map
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { describe, it } from 'mocha';
|
|
2
|
-
import { expect } from 'chai';
|
|
3
|
-
import { closeNonPairedParens, stripNonPairedParens, repeat } from './AsYouTypeFormatter.util.js';
|
|
4
|
-
describe('closeNonPairedParens', function () {
|
|
5
|
-
it('should close non-paired braces', function () {
|
|
6
|
-
expect(closeNonPairedParens('(000) 123-45 (9 )', 15)).to.equal('(000) 123-45 (9 )');
|
|
7
|
-
});
|
|
8
|
-
});
|
|
9
|
-
describe('stripNonPairedParens', function () {
|
|
10
|
-
it('should strip non-paired braces', function () {
|
|
11
|
-
expect(stripNonPairedParens('(000) 123-45 (9')).to.equal('(000) 123-45 9');
|
|
12
|
-
expect(stripNonPairedParens('(000) 123-45 (9)')).to.equal('(000) 123-45 (9)');
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
describe('repeat', function () {
|
|
16
|
-
it('should repeat string N times', function () {
|
|
17
|
-
expect(repeat('a', 0)).to.equal('');
|
|
18
|
-
expect(repeat('a', 3)).to.equal('aaa');
|
|
19
|
-
expect(repeat('a', 4)).to.equal('aaaa');
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
//# sourceMappingURL=AsYouTypeFormatter.util.test.js.map
|