1 | import findPhoneNumbersInText from './findPhoneNumbersInText'
|
2 | import metadata from '../metadata.min.json'
|
3 |
|
4 | describe('findPhoneNumbersInText', () => {
|
5 | it('should find phone numbers in text (with default country)', () => {
|
6 | findPhoneNumbersInText('+7 (800) 555-35-35', 'US', metadata)[0].number.number.should.equal('+78005553535')
|
7 | })
|
8 |
|
9 | it('should find phone numbers in text (with default country in options)', () => {
|
10 | findPhoneNumbersInText('+7 (800) 555-35-35', { defaultCountry: 'US' }, metadata)[0].number.number.should.equal('+78005553535')
|
11 | })
|
12 |
|
13 | it('should find phone numbers in text (with default country and options)', () => {
|
14 | findPhoneNumbersInText('+7 (800) 555-35-35', 'US', {}, metadata)[0].number.number.should.equal('+78005553535')
|
15 | })
|
16 |
|
17 | it('should find phone numbers in text (without default country, with options)', () => {
|
18 | findPhoneNumbersInText('+7 (800) 555-35-35', undefined, {}, metadata)[0].number.number.should.equal('+78005553535')
|
19 | })
|
20 |
|
21 | it('should find phone numbers in text (with default country, without options)', () => {
|
22 | findPhoneNumbersInText('+7 (800) 555-35-35', 'US', undefined, metadata)[0].number.number.should.equal('+78005553535')
|
23 | })
|
24 |
|
25 | it('should find phone numbers in text (with empty default country)', () => {
|
26 | findPhoneNumbersInText('+7 (800) 555-35-35', undefined, metadata)[0].number.number.should.equal('+78005553535')
|
27 | })
|
28 |
|
29 | it('should find phone numbers in text', () => {
|
30 | const NUMBERS = ['+78005553535', '+12133734253']
|
31 | const results = findPhoneNumbersInText('The number is +7 (800) 555-35-35 and not (213) 373-4253 as written in the document.', metadata)
|
32 | let i = 0
|
33 | while (i < results.length) {
|
34 | results[i].number.number.should.equal(NUMBERS[i])
|
35 | i++
|
36 | }
|
37 | })
|
38 |
|
39 | it('should find phone numbers in text (default country calling code)', () => {
|
40 | const NUMBERS = ['+870773111632']
|
41 | const results = findPhoneNumbersInText('The number is 773 111 632', { defaultCallingCode: '870' }, metadata)
|
42 | let i = 0
|
43 | while (i < results.length) {
|
44 | results[i].number.number.should.equal(NUMBERS[i])
|
45 | i++
|
46 | }
|
47 | })
|
48 | }) |
\ | No newline at end of file |