UNPKG

2.7 kBJavaScriptView Raw
1"use strict";
2
3var _findPhoneNumbersInText = _interopRequireDefault(require("./findPhoneNumbersInText"));
4
5var _metadataMin = _interopRequireDefault(require("../metadata.min.json"));
6
7function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
8
9describe('findPhoneNumbersInText', function () {
10 it('should find phone numbers in text (with default country)', function () {
11 (0, _findPhoneNumbersInText["default"])('+7 (800) 555-35-35', 'US', _metadataMin["default"])[0].number.number.should.equal('+78005553535');
12 });
13 it('should find phone numbers in text (with default country in options)', function () {
14 (0, _findPhoneNumbersInText["default"])('+7 (800) 555-35-35', {
15 defaultCountry: 'US'
16 }, _metadataMin["default"])[0].number.number.should.equal('+78005553535');
17 });
18 it('should find phone numbers in text (with default country and options)', function () {
19 (0, _findPhoneNumbersInText["default"])('+7 (800) 555-35-35', 'US', {}, _metadataMin["default"])[0].number.number.should.equal('+78005553535');
20 });
21 it('should find phone numbers in text (without default country, with options)', function () {
22 (0, _findPhoneNumbersInText["default"])('+7 (800) 555-35-35', undefined, {}, _metadataMin["default"])[0].number.number.should.equal('+78005553535');
23 });
24 it('should find phone numbers in text (with default country, without options)', function () {
25 (0, _findPhoneNumbersInText["default"])('+7 (800) 555-35-35', 'US', undefined, _metadataMin["default"])[0].number.number.should.equal('+78005553535');
26 });
27 it('should find phone numbers in text (with empty default country)', function () {
28 (0, _findPhoneNumbersInText["default"])('+7 (800) 555-35-35', undefined, _metadataMin["default"])[0].number.number.should.equal('+78005553535');
29 });
30 it('should find phone numbers in text', function () {
31 var NUMBERS = ['+78005553535', '+12133734253'];
32 var results = (0, _findPhoneNumbersInText["default"])('The number is +7 (800) 555-35-35 and not (213) 373-4253 as written in the document.', _metadataMin["default"]);
33 var i = 0;
34
35 while (i < results.length) {
36 results[i].number.number.should.equal(NUMBERS[i]);
37 i++;
38 }
39 });
40 it('should find phone numbers in text (default country calling code)', function () {
41 var NUMBERS = ['+870773111632'];
42 var results = (0, _findPhoneNumbersInText["default"])('The number is 773 111 632', {
43 defaultCallingCode: '870'
44 }, _metadataMin["default"]);
45 var i = 0;
46
47 while (i < results.length) {
48 results[i].number.number.should.equal(NUMBERS[i]);
49 i++;
50 }
51 });
52});
53//# sourceMappingURL=findPhoneNumbersInText.test.js.map
\No newline at end of file