Back | Home
الـ Path الحالي: /home/picotech/domains/instantly.picotech.app/public_html/public/uploads/../uploads/../../../../instantly.picotech.app/homes/../../wa.picotech.app/public_html/node_modules/path-exists/../duplexify/./../@protobufjs/../cheerio/.././cliui/../curve25519-js/../libphonenumber-js/es6/helpers/../.
الملفات الموجودة في هذا الـ Path:
.
..
AsYouType.js
AsYouType.js.map
AsYouType.test.js
AsYouType.test.js.map
AsYouTypeFormatter.PatternMatcher.js
AsYouTypeFormatter.PatternMatcher.js.map
AsYouTypeFormatter.PatternMatcher.test.js
AsYouTypeFormatter.PatternMatcher.test.js.map
AsYouTypeFormatter.PatternParser.js
AsYouTypeFormatter.PatternParser.js.map
AsYouTypeFormatter.PatternParser.test.js
AsYouTypeFormatter.PatternParser.test.js.map
AsYouTypeFormatter.complete.js
AsYouTypeFormatter.complete.js.map
AsYouTypeFormatter.js
AsYouTypeFormatter.js.map
AsYouTypeFormatter.util.js
AsYouTypeFormatter.util.js.map
AsYouTypeFormatter.util.test.js
AsYouTypeFormatter.util.test.js.map
AsYouTypeParser.js
AsYouTypeParser.js.map
AsYouTypeState.js
AsYouTypeState.js.map
ParseError.js
ParseError.js.map
PhoneNumber.js
PhoneNumber.js.map
PhoneNumber.test.js
PhoneNumber.test.js.map
PhoneNumberMatcher.js
PhoneNumberMatcher.js.map
PhoneNumberMatcher.test.js
PhoneNumberMatcher.test.js.map
constants.js
constants.js.map
findNumbers
findPhoneNumbersInText.js
findPhoneNumbersInText.js.map
findPhoneNumbersInText.test.js
findPhoneNumbersInText.test.js.map
format.js
format.js.map
format.test.js
format.test.js.map
formatIncompletePhoneNumber.js
formatIncompletePhoneNumber.js.map
formatIncompletePhoneNumber.test.js
formatIncompletePhoneNumber.test.js.map
formatPhoneNumberForMobileDialing.js
formatPhoneNumberForMobileDialing.js.map
formatPhoneNumberForMobileDialing.test.js
formatPhoneNumberForMobileDialing.test.js.map
getCountries.js
getCountries.js.map
getCountries.test.js
getCountries.test.js.map
getCountryCallingCode.js
getCountryCallingCode.js.map
getCountryCallingCode.test.js
getCountryCallingCode.test.js.map
getExampleNumber.js
getExampleNumber.js.map
getExampleNumber.test.js
getExampleNumber.test.js.map
helpers
isPossible.js
isPossible.js.map
isPossible.test.js
isPossible.test.js.map
isPossiblePhoneNumber.js
isPossiblePhoneNumber.js.map
isPossiblePhoneNumber.test.js
isPossiblePhoneNumber.test.js.map
isValid.js
isValid.js.map
isValid.test.js
isValid.test.js.map
isValidPhoneNumber.js
isValidPhoneNumber.js.map
isValidPhoneNumber.test.js
isValidPhoneNumber.test.js.map
legacy
metadata.js
metadata.js.map
metadata.test.js
metadata.test.js.map
normalizeArguments.js
normalizeArguments.js.map
parse.js
parse.js.map
parse.test.js
parse.test.js.map
parseIncompletePhoneNumber.js
parseIncompletePhoneNumber.js.map
parseIncompletePhoneNumber.test.js
parseIncompletePhoneNumber.test.js.map
parsePhoneNumber.js
parsePhoneNumber.js.map
parsePhoneNumber.test.js
parsePhoneNumber.test.js.map
parsePhoneNumberWithError.js
parsePhoneNumberWithError.js.map
parsePhoneNumberWithError.test.js
parsePhoneNumberWithError.test.js.map
parsePhoneNumberWithError_.js
parsePhoneNumberWithError_.js.map
parsePhoneNumber_.js
parsePhoneNumber_.js.map
searchPhoneNumbersInText.js
searchPhoneNumbersInText.js.map
searchPhoneNumbersInText.test.js
searchPhoneNumbersInText.test.js.map
tools
validatePhoneNumberLength.js
validatePhoneNumberLength.js.map
validatePhoneNumberLength.test.js
validatePhoneNumberLength.test.js.map

مشاهدة ملف: parsePhoneNumberWithError.test.js

import _parsePhoneNumber from './parsePhoneNumberWithError.js';
import metadata from '../metadata.min.json' assert { type: 'json' };
import metadataFull from '../metadata.max.json' assert { type: 'json' };

function parsePhoneNumber() {
  for (var _len = arguments.length, parameters = new Array(_len), _key = 0; _key < _len; _key++) {
    parameters[_key] = arguments[_key];
  }

  parameters.push(metadata);
  return _parsePhoneNumber.apply(this, parameters);
}

function parsePhoneNumberFull() {
  for (var _len2 = arguments.length, parameters = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
    parameters[_key2] = arguments[_key2];
  }

  parameters.push(metadataFull);
  return _parsePhoneNumber.apply(this, parameters);
}

describe('parsePhoneNumberWithError', function () {
  it('should parse phone numbers', function () {
    var phoneNumber = parsePhoneNumber('The phone number is: 8 (800) 555 35 35. Some other text.', 'RU');
    phoneNumber.country.should.equal('RU');
    phoneNumber.countryCallingCode.should.equal('7');
    phoneNumber.nationalNumber.should.equal('8005553535');
    phoneNumber.number.should.equal('+78005553535');
    phoneNumber.isPossible().should.equal(true);
    phoneNumber.isValid().should.equal(true); // phoneNumber.isValidForRegion('RU').should.equal(true)
    // Russian phone type regexps aren't included in default metadata.

    parsePhoneNumberFull('Phone: 8 (800) 555 35 35.', 'RU').getType().should.equal('TOLL_FREE');
  });
  it('shouldn\'t set country when it\'s non-derivable', function () {
    var phoneNumber = parsePhoneNumber('+7 111 555 35 35');
    expect(phoneNumber.country).to.be.undefined;
    phoneNumber.countryCallingCode.should.equal('7');
    phoneNumber.nationalNumber.should.equal('1115553535');
  });
  it('should parse carrier code', function () {
    var phoneNumber = parsePhoneNumber('0 15 21 5555-5555', 'BR');
    phoneNumber.carrierCode.should.equal('15');
  });
  it('should parse phone extension', function () {
    var phoneNumber = parsePhoneNumber('Phone: 8 (800) 555 35 35 ext. 1234.', 'RU');
    phoneNumber.ext.should.equal('1234');
  });
  it('should validate numbers for countries with no type regular expressions', function () {
    parsePhoneNumber('+380391234567').isValid().should.equal(true);
    parsePhoneNumber('+380191234567').isValid().should.equal(false);
  });
  it('should format numbers', function () {
    var phoneNumber = parsePhoneNumber('Phone: 8 (800) 555 35 35.', 'RU');
    phoneNumber.format('NATIONAL').should.equal('8 (800) 555-35-35');
    phoneNumber.formatNational().should.equal('8 (800) 555-35-35');
    phoneNumber.format('INTERNATIONAL').should.equal('+7 800 555 35 35');
    phoneNumber.formatInternational().should.equal('+7 800 555 35 35');
  });
  it('should get tel: URI', function () {
    var phoneNumber = parsePhoneNumber('Phone: 8 (800) 555 35 35 ext. 1234.', 'RU');
    phoneNumber.getURI().should.equal('tel:+78005553535;ext=1234');
  });
  it('should work in edge cases', function () {
    expect(function () {
      return parsePhoneNumber('+78005553535', -1, {});
    }).to["throw"]('Invalid second argument');
  });
  it('should throw parse errors', function () {
    expect(function () {
      return parsePhoneNumber('8005553535', 'XX');
    }).to["throw"]('INVALID_COUNTRY');
    expect(function () {
      return parsePhoneNumber('+', 'RU');
    }).to["throw"]('NOT_A_NUMBER');
    expect(function () {
      return parsePhoneNumber('a', 'RU');
    }).to["throw"]('NOT_A_NUMBER');
    expect(function () {
      return parsePhoneNumber('1', 'RU');
    }).to["throw"]('TOO_SHORT');
    expect(function () {
      return parsePhoneNumber('+4');
    }).to["throw"]('TOO_SHORT');
    expect(function () {
      return parsePhoneNumber('+44');
    }).to["throw"]('TOO_SHORT');
    expect(function () {
      return parsePhoneNumber('+443');
    }).to["throw"]('TOO_SHORT');
    expect(function () {
      return parsePhoneNumber('+370');
    }).to["throw"]('TOO_SHORT');
    expect(function () {
      return parsePhoneNumber('88888888888888888888', 'RU');
    }).to["throw"]('TOO_LONG');
    expect(function () {
      return parsePhoneNumber('8 (800) 555 35 35');
    }).to["throw"]('INVALID_COUNTRY');
    expect(function () {
      return parsePhoneNumber('+9991112233');
    }).to["throw"]('INVALID_COUNTRY');
    expect(function () {
      return parsePhoneNumber('+9991112233', 'US');
    }).to["throw"]('INVALID_COUNTRY');
    expect(function () {
      return parsePhoneNumber('8005553535                                                                                                                                                                                                                                                 ', 'RU');
    }).to["throw"]('TOO_LONG');
  });
  it('should parse incorrect international phone numbers', function () {
    // Parsing national prefixes and carrier codes
    // is only required for local phone numbers
    // but some people don't understand that
    // and sometimes write international phone numbers
    // with national prefixes (or maybe even carrier codes).
    // http://ucken.blogspot.ru/2016/03/trunk-prefixes-in-skype4b.html
    // Google's original library forgives such mistakes
    // and so does this library, because it has been requested:
    // https://github.com/catamphetamine/libphonenumber-js/issues/127
    var phoneNumber; // For complete numbers it should strip national prefix.

    phoneNumber = parsePhoneNumber('+1 1877 215 5230');
    phoneNumber.nationalNumber.should.equal('8772155230');
    phoneNumber.country.should.equal('US'); // For complete numbers it should strip national prefix.

    phoneNumber = parsePhoneNumber('+7 8800 555 3535');
    phoneNumber.nationalNumber.should.equal('8005553535');
    phoneNumber.country.should.equal('RU'); // For incomplete numbers it shouldn't strip national prefix.

    phoneNumber = parsePhoneNumber('+7 8800 555 353');
    phoneNumber.nationalNumber.should.equal('8800555353');
    phoneNumber.country.should.equal('RU');
  });
});
//# sourceMappingURL=parsePhoneNumberWithError.test.js.map