1 |
- {"version":3,"file":"isPossible.test.js","names":["isPossibleNumber","v2","parameters","length","push","undefined","parsePhoneNumber","extract","metadata","_isPossibleNumber","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;;AACA;;AACA;;;;;;;;;;AAEA,SAASA,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,GAAgB,IAAAI,4BAAA,EAAiBJ,UAAU,CAAC,CAAD,CAA3B,kCACZA,UAAU,CAAC,CAAD,CADE;QAEfK,OAAO,EAAE;MAFM,IAGbC,uBAHa,CAAhB;IAIA;EACD;;EACD,IAAIN,UAAU,CAACC,MAAX,GAAoB,CAAxB,EAA2B;IAC1B;IACAD,UAAU,CAACE,IAAX,CAAgBC,SAAhB;EACA,CAlBuC,CAmBxC;;;EACAH,UAAU,CAAC,CAAD,CAAV;IACCD,EAAE,EAAF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