validatePhoneNumberLength.test.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. "use strict";
  2. var _validatePhoneNumberLength2 = _interopRequireDefault(require("./validatePhoneNumberLength.js"));
  3. var _metadataMin = _interopRequireDefault(require("../metadata.min.json"));
  4. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5. function validatePhoneNumberLength() {
  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 _validatePhoneNumberLength2["default"].apply(this, parameters);
  11. }
  12. describe('validatePhoneNumberLength', function () {
  13. it('should detect whether a phone number length is valid', function () {
  14. // Not a phone number.
  15. validatePhoneNumberLength('+').should.equal('NOT_A_NUMBER');
  16. validatePhoneNumberLength('abcde').should.equal('NOT_A_NUMBER'); // No country supplied for a national number.
  17. validatePhoneNumberLength('123').should.equal('INVALID_COUNTRY'); // Too short while the number is not considered "viable"
  18. // by Google's `libphonenumber`.
  19. validatePhoneNumberLength('2', 'US').should.equal('TOO_SHORT');
  20. validatePhoneNumberLength('+1', 'US').should.equal('TOO_SHORT');
  21. validatePhoneNumberLength('+12', 'US').should.equal('TOO_SHORT'); // Test national (significant) number length.
  22. validatePhoneNumberLength('444 1 44', 'TR').should.equal('TOO_SHORT');
  23. expect(validatePhoneNumberLength('444 1 444', 'TR')).to.be.undefined;
  24. validatePhoneNumberLength('444 1 4444', 'TR').should.equal('INVALID_LENGTH');
  25. validatePhoneNumberLength('444 1 4444444444', 'TR').should.equal('TOO_LONG');
  26. });
  27. });
  28. //# sourceMappingURL=validatePhoneNumberLength.test.js.map