1 | import metadata from '../metadata.min.json'
|
2 | import _isPossibleNumber from './isPossibleNumber'
|
3 |
|
4 | function isPossibleNumber(...parameters) {
|
5 | parameters.push(metadata)
|
6 | return _isPossibleNumber.apply(this, parameters)
|
7 | }
|
8 |
|
9 | describe('isPossibleNumber', () => {
|
10 | it('should work', function()
|
11 | {
|
12 | isPossibleNumber('+79992223344').should.equal(true)
|
13 |
|
14 | isPossibleNumber({ phone: '1112223344', country: 'RU' }).should.equal(true)
|
15 | isPossibleNumber({ phone: '111222334', country: 'RU' }).should.equal(false)
|
16 | isPossibleNumber({ phone: '11122233445', country: 'RU' }).should.equal(false)
|
17 |
|
18 | isPossibleNumber({ phone: '1112223344', countryCallingCode: 7 }).should.equal(true)
|
19 | })
|
20 |
|
21 | it('should work v2', () => {
|
22 | isPossibleNumber({ nationalNumber: '111222334', countryCallingCode: 7 }, { v2: true }).should.equal(false)
|
23 | isPossibleNumber({ nationalNumber: '1112223344', countryCallingCode: 7 }, { v2: true }).should.equal(true)
|
24 | isPossibleNumber({ nationalNumber: '11122233445', countryCallingCode: 7 }, { v2: true }).should.equal(false)
|
25 | })
|
26 |
|
27 | it('should work in edge cases', () => {
|
28 |
|
29 | expect(() => isPossibleNumber({}, { v2: true })).to.throw('Invalid phone number object passed')
|
30 |
|
31 |
|
32 |
|
33 |
|
34 | isPossibleNumber({}).should.equal(false)
|
35 | expect(() => isPossibleNumber({ phone: '1112223344' })).to.throw('Invalid phone number object passed')
|
36 |
|
37 |
|
38 | expect(() => isPossibleNumber({ phone: '1112223344', country: 'XX' })).to.throw('Unknown country')
|
39 | })
|
40 | }) |
\ | No newline at end of file |