text: "use strict";
  
  var _assert = _interopRequireDefault(require("assert"));
  
  var _index = _interopRequireWildcard(require("../index"));
  
  var _helper = _interopRequireDefault(require("./helper"));
  
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  
  var ERROR_WRONG_LENGTH_ID = 'form.errors.wrongLength';
  var ERROR_TOO_LONG_ID = 'form.errors.tooLong';
  var ERROR_TOO_SHORT_ID = 'form.errors.tooShort';
  
  function test(value, params) {
    return (0, _helper["default"])((0, _index.length)(params)(value));
  }
  
  describe('Validator: length', function () {
    it('should be invalid when `value.length` is < min', function () {
      _assert["default"].strictEqual(ERROR_TOO_SHORT_ID, test('foobar', {
        min: 7
      }));
  
      _assert["default"].strictEqual(ERROR_TOO_SHORT_ID, test('foobar', {
        minimum: 9
      }));
    });
    it('should be invalid when `value.length` is > max', function () {
      _assert["default"].strictEqual(ERROR_TOO_LONG_ID, test('f', {
        max: 0
      }));
  
      _assert["default"].strictEqual(ERROR_TOO_LONG_ID, test('foobar', {
        max: 5
      }));
  
      _assert["default"].strictEqual(ERROR_TOO_LONG_ID, test('foobar', {
        maximum: 2
      }));
    });
    it('should be invalid when `value.length` is not included in range', function () {
      _assert["default"].strictEqual(ERROR_TOO_SHORT_ID, test('f', {
        "in": [2, 6]
      }));
  
      _assert["default"].strictEqual(ERROR_TOO_LONG_ID, test('foobar', {
        "in": [0, 5]
      }));
  
      _assert["default"].strictEqual(ERROR_TOO_LONG_ID, test('foobar', {
        within: [5, 5]
      }));
    });
    it('should be invalid when `value.length` is != is', function () {
      _assert["default"].strictEqual(ERROR_WRONG_LENGTH_ID, test('foobar', {
        '=': 5
      }));
  
      _assert["default"].strictEqual(ERROR_WRONG_LENGTH_ID, test('foobar', {
        is: 7
      }));
    });
    it('should be valid when `value.length` is >= min', function () {
      _assert["default"].ok(!test('', {
        min: 0
      }));
  
      _assert["default"].ok(!test('foobar', {
        min: 0
      }));
  
      _assert["default"].ok(!test('foobar', {
        minimum: 5
      }));
    });
    it('should be valid when `value.length` is <= max', function () {
      _assert["default"].ok(!test('', {
        max: 0
      }));
  
      _assert["default"].ok(!test('foobar', {
        max: 6
      }));
  
      _assert["default"].ok(!test('foobar', {
        maximum: 10
      }));
    });
    it('should be valid when `value.length` is in range', function () {
      _assert["default"].ok(!test('', {
        "in": [0, 120]
      }));
  
      _assert["default"].ok(!test('foobar', {
        "in": [6, 8]
      }));
  
      _assert["default"].ok(!test('foobar', {
        within: [0, 6]
      }));
    });
    it('should be valid when `value.length` is = is', function () {
      _assert["default"].ok(!test('', {
        '=': 0
      }));
  
      _assert["default"].ok(!test('foobar', {
        '=': 6
      }));
  
      _assert["default"].ok(!test('foobar', {
        is: 6
      }));
    });
    it('should use formatMessage', function () {
      var defaultValue = _index["default"].formatMessage;
  
      _index["default"].formatMessage = function (msg) {
        return Object.assign({}, msg, {
          id: msg.id + '2'
        });
      };
  
      _assert["default"].strictEqual(ERROR_TOO_SHORT_ID + '2', test('foobar', {
        min: 7
      }));
  
      _assert["default"].strictEqual(ERROR_TOO_LONG_ID + '2', test('f', {
        max: 0
      }));
  
      _assert["default"].strictEqual(ERROR_WRONG_LENGTH_ID + '2', test('foobar', {
        is: 7
      }));
  
      _index["default"].formatMessage = defaultValue;
    });
  });