checkNumberLength.test.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. "use strict";
  2. var _metadata2 = _interopRequireDefault(require("../metadata.js"));
  3. var _metadataMax = _interopRequireDefault(require("../../metadata.max.json"));
  4. var _metadataMin = _interopRequireDefault(require("../../test/metadata/1.0.0/metadata.min.json"));
  5. var _checkNumberLength = require("./checkNumberLength.js");
  6. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7. describe('checkNumberLength', function () {
  8. it('should check phone number length', function () {
  9. // Too short.
  10. checkNumberLength('800555353', 'FIXED_LINE', 'RU').should.equal('TOO_SHORT'); // Normal.
  11. checkNumberLength('8005553535', 'FIXED_LINE', 'RU').should.equal('IS_POSSIBLE'); // Too long.
  12. checkNumberLength('80055535355', 'FIXED_LINE', 'RU').should.equal('TOO_LONG'); // No such type.
  13. checkNumberLength('169454850', 'VOIP', 'AC').should.equal('INVALID_LENGTH'); // No such possible length.
  14. checkNumberLength('1694548', undefined, 'AD').should.equal('INVALID_LENGTH'); // FIXED_LINE_OR_MOBILE
  15. checkNumberLength('1694548', 'FIXED_LINE_OR_MOBILE', 'AD').should.equal('INVALID_LENGTH'); // No mobile phones.
  16. checkNumberLength('8123', 'FIXED_LINE_OR_MOBILE', 'TA').should.equal('IS_POSSIBLE'); // No "possible lengths" for "mobile".
  17. checkNumberLength('81234567', 'FIXED_LINE_OR_MOBILE', 'SZ').should.equal('IS_POSSIBLE');
  18. });
  19. it('should work for old metadata', function () {
  20. var _oldMetadata = new _metadata2["default"](_metadataMin["default"]);
  21. _oldMetadata.country('RU');
  22. (0, _checkNumberLength.checkNumberLengthForType)('8005553535', 'FIXED_LINE', _oldMetadata).should.equal('IS_POSSIBLE');
  23. });
  24. });
  25. function checkNumberLength(number, type, country) {
  26. var _metadata = new _metadata2["default"](_metadataMax["default"]);
  27. _metadata.country(country);
  28. return (0, _checkNumberLength.checkNumberLengthForType)(number, type, _metadata);
  29. }
  30. //# sourceMappingURL=checkNumberLength.test.js.map