validatePhoneNumberLength.test.js 1.5 KB

1234567891011121314151617181920212223242526272829303132
  1. import _validatePhoneNumberLength from './validatePhoneNumberLength.js';
  2. import metadata from '../metadata.min.json' assert { type: 'json' };
  3. function validatePhoneNumberLength() {
  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 _validatePhoneNumberLength.apply(this, parameters);
  9. }
  10. describe('validatePhoneNumberLength', function () {
  11. it('should detect whether a phone number length is valid', function () {
  12. // Not a phone number.
  13. validatePhoneNumberLength('+').should.equal('NOT_A_NUMBER');
  14. validatePhoneNumberLength('abcde').should.equal('NOT_A_NUMBER'); // No country supplied for a national number.
  15. validatePhoneNumberLength('123').should.equal('INVALID_COUNTRY'); // Too short while the number is not considered "viable"
  16. // by Google's `libphonenumber`.
  17. validatePhoneNumberLength('2', 'US').should.equal('TOO_SHORT');
  18. validatePhoneNumberLength('+1', 'US').should.equal('TOO_SHORT');
  19. validatePhoneNumberLength('+12', 'US').should.equal('TOO_SHORT'); // Test national (significant) number length.
  20. validatePhoneNumberLength('444 1 44', 'TR').should.equal('TOO_SHORT');
  21. expect(validatePhoneNumberLength('444 1 444', 'TR')).to.be.undefined;
  22. validatePhoneNumberLength('444 1 4444', 'TR').should.equal('INVALID_LENGTH');
  23. validatePhoneNumberLength('444 1 4444444444', 'TR').should.equal('TOO_LONG');
  24. });
  25. });
  26. //# sourceMappingURL=validatePhoneNumberLength.test.js.map