1 |
- {"version":3,"file":"isPossible.test.js","names":["metadata","type","_isPossibleNumber","parsePhoneNumber","isPossibleNumber","v2","parameters","length","push","undefined","extract","apply","describe","it","should","equal","phone","country","countryCallingCode","nationalNumber","expect","to"],"sources":["../source/isPossible.test.js"],"sourcesContent":["import metadata from '../metadata.min.json' assert { type: 'json' }\r\nimport _isPossibleNumber from './isPossible.js'\r\nimport parsePhoneNumber from './parsePhoneNumber.js'\r\n\r\nfunction isPossibleNumber(...parameters) {\r\n\tlet v2\r\n\tif (parameters.length < 1) {\r\n\t\t// `input` parameter.\r\n\t\tparameters.push(undefined)\r\n\t} else {\r\n\t\t// Convert string `input` to a `PhoneNumber` instance.\r\n\t\tif (typeof parameters[0] === 'string') {\r\n\t\t\tv2 = true\r\n\t\t\tparameters[0] = parsePhoneNumber(parameters[0], {\r\n\t\t\t\t...parameters[1],\r\n\t\t\t\textract: false\r\n\t\t\t}, metadata)\r\n\t\t}\r\n\t}\r\n\tif (parameters.length < 2) {\r\n\t\t// `options` parameter.\r\n\t\tparameters.push(undefined)\r\n\t}\r\n\t// Set `v2` flag.\r\n\tparameters[1] = {\r\n\t\tv2,\r\n\t\t...parameters[1]\r\n\t}\r\n\t// Add `metadata` parameter.\r\n\tparameters.push(metadata)\r\n\t// Call the function.\r\n\treturn _isPossibleNumber.apply(this, parameters)\r\n}\r\n\r\ndescribe('isPossible', () => {\r\n\tit('should work', function()\r\n\t{\r\n\t\tisPossibleNumber('+79992223344').should.equal(true)\r\n\r\n\t\tisPossibleNumber({ phone: '1112223344', country: 'RU' }).should.equal(true)\r\n\t\tisPossibleNumber({ phone: '111222334', country: 'RU' }).should.equal(false)\r\n\t\tisPossibleNumber({ phone: '11122233445', country: 'RU' }).should.equal(false)\r\n\r\n\t\tisPossibleNumber({ phone: '1112223344', countryCallingCode: 7 }).should.equal(true)\r\n\t})\r\n\r\n\tit('should work v2', () => {\r\n\t\tisPossibleNumber({ nationalNumber: '111222334', countryCallingCode: 7 }, { v2: true }).should.equal(false)\r\n\t\tisPossibleNumber({ nationalNumber: '1112223344', countryCallingCode: 7 }, { v2: true }).should.equal(true)\r\n\t\tisPossibleNumber({ nationalNumber: '11122233445', countryCallingCode: 7 }, { v2: true }).should.equal(false)\r\n\t})\r\n\r\n\tit('should work in edge cases', () => {\r\n\t\t// Invalid `PhoneNumber` argument.\r\n\t\texpect(() => isPossibleNumber({}, { v2: true })).to.throw('Invalid phone number object passed')\r\n\r\n\t\t// Empty input is passed.\r\n\t\t// This is just to support `isValidNumber({})`\r\n\t\t// for cases when `parseNumber()` returns `{}`.\r\n\t\tisPossibleNumber({}).should.equal(false)\r\n\t\texpect(() => isPossibleNumber({ phone: '1112223344' })).to.throw('Invalid phone number object passed')\r\n\r\n\t\t// Incorrect country.\r\n\t\texpect(() => isPossibleNumber({ phone: '1112223344', country: 'XX' })).to.throw('Unknown country')\r\n\t})\r\n})"],"mappings":";;;;;;AAAA,OAAOA,QAAP,MAAqB,sBAArB,UAAqDC,IAAI,EAAE,MAA3D;AACA,OAAOC,iBAAP,MAA8B,iBAA9B;AACA,OAAOC,gBAAP,MAA6B,uBAA7B;;AAEA,SAASC,gBAAT,GAAyC;EACxC,IAAIC,EAAJ;;EADwC,kCAAZC,UAAY;IAAZA,UAAY;EAAA;;EAExC,IAAIA,UAAU,CAACC,MAAX,GAAoB,CAAxB,EAA2B;IAC1B;IACAD,UAAU,CAACE,IAAX,CAAgBC,SAAhB;EACA,CAHD,MAGO;IACN;IACA,IAAI,OAAOH,UAAU,CAAC,CAAD,CAAjB,KAAyB,QAA7B,EAAuC;MACtCD,EAAE,GAAG,IAAL;MACAC,UAAU,CAAC,CAAD,CAAV,GAAgBH,gBAAgB,CAACG,UAAU,CAAC,CAAD,CAAX,kCAC5BA,UAAU,CAAC,CAAD,CADkB;QAE/BI,OAAO,EAAE;MAFsB,IAG7BV,QAH6B,CAAhC;IAIA;EACD;;EACD,IAAIM,UAAU,CAACC,MAAX,GAAoB,CAAxB,EAA2B;IAC1B;IAC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