isValidPhoneNumber.test.js 1.1 KB

123456789101112131415161718192021222324252627
  1. import _isValidPhoneNumber from './isValidPhoneNumber.js';
  2. import metadata from '../metadata.min.json' assert { type: 'json' };
  3. function isValidPhoneNumber() {
  4. for (var _len = arguments.length, parameters = new Array(_len), _key = 0; _key < _len; _key++) {
  5. parameters[_key] = arguments[_key];
  6. }
  7. parameters.push(metadata);
  8. return _isValidPhoneNumber.apply(this, parameters);
  9. }
  10. describe('isValidPhoneNumber', function () {
  11. it('should detect whether a phone number is valid', function () {
  12. isValidPhoneNumber('8 (800) 555 35 35', 'RU').should.equal(true);
  13. isValidPhoneNumber('8 (800) 555 35 35 0', 'RU').should.equal(false);
  14. isValidPhoneNumber('Call: 8 (800) 555 35 35', 'RU').should.equal(false);
  15. isValidPhoneNumber('8 (800) 555 35 35', {
  16. defaultCountry: 'RU'
  17. }).should.equal(true);
  18. isValidPhoneNumber('+7 (800) 555 35 35').should.equal(true);
  19. isValidPhoneNumber('+7 1 (800) 555 35 35').should.equal(false);
  20. isValidPhoneNumber(' +7 (800) 555 35 35').should.equal(false);
  21. isValidPhoneNumber(' ').should.equal(false);
  22. });
  23. });
  24. //# sourceMappingURL=isValidPhoneNumber.test.js.map