isValidPhoneNumber.test.js 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. "use strict";
  2. var _isValidPhoneNumber2 = _interopRequireDefault(require("./isValidPhoneNumber.js"));
  3. var _metadataMin = _interopRequireDefault(require("../metadata.min.json"));
  4. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5. function isValidPhoneNumber() {
  6. for (var _len = arguments.length, parameters = new Array(_len), _key = 0; _key < _len; _key++) {
  7. parameters[_key] = arguments[_key];
  8. }
  9. parameters.push(_metadataMin["default"]);
  10. return _isValidPhoneNumber2["default"].apply(this, parameters);
  11. }
  12. describe('isValidPhoneNumber', function () {
  13. it('should detect whether a phone number is valid', function () {
  14. isValidPhoneNumber('8 (800) 555 35 35', 'RU').should.equal(true);
  15. isValidPhoneNumber('8 (800) 555 35 35 0', 'RU').should.equal(false);
  16. isValidPhoneNumber('Call: 8 (800) 555 35 35', 'RU').should.equal(false);
  17. isValidPhoneNumber('8 (800) 555 35 35', {
  18. defaultCountry: 'RU'
  19. }).should.equal(true);
  20. isValidPhoneNumber('+7 (800) 555 35 35').should.equal(true);
  21. isValidPhoneNumber('+7 1 (800) 555 35 35').should.equal(false);
  22. isValidPhoneNumber(' +7 (800) 555 35 35').should.equal(false);
  23. isValidPhoneNumber(' ').should.equal(false);
  24. });
  25. });
  26. //# sourceMappingURL=isValidPhoneNumber.test.js.map