libphonenumber-js 1.12.40 → 1.12.41

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