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_ID = 'form.errors.inclusion';
  
  function test(value, params) {
    return (0, _helper["default"])((0, _index.inclusion)(params)(value));
  }
  
  describe('Validator: inclusion', function () {
    it('should be invalid when `value` is not in the list', function () {
      _assert["default"].strictEqual(ERROR_ID, test(1, {
        "in": []
      }));
  
      _assert["default"].strictEqual(ERROR_ID, test('1', {
        "in": [2, 3, 4]
      }));
  
      _assert["default"].strictEqual(ERROR_ID, test('foo', {
        within: 'foobar'
      }));
  
      _assert["default"].strictEqual(ERROR_ID, test('FOO', {
        within: ['foobar'],
        caseSensitive: false
      }));
  
      _assert["default"].strictEqual(ERROR_ID, test('FOO', {
        within: ['foo'],
        caseSensitive: true
      }));
    });
    it('should be valid when `value` is in the list', function () {
      _assert["default"].ok(!test(1, {
        "in": [9, 8, '1']
      }));
  
      _assert["default"].ok(!test('1', {
        "in": [9, 8, 1]
      }));
  
      _assert["default"].ok(!test('foo', {
        within: 'foo'
      }));
  
      _assert["default"].ok(!test('foo', {
        within: ['bar', 'foo'],
        caseSensitive: true
      }));
  
      _assert["default"].ok(!test('FOO', {
        within: ['foo'],
        caseSensitive: false
      }));
  
      _assert["default"].ok(!test('fOo', {
        within: ['foo'],
        caseSensitive: false
      }));
    });
    it('should use default caseSensitive option', function () {
      var defaultValue = _index["default"].defaultOptions.caseSensitive;
      _index["default"].defaultOptions.caseSensitive = true;
  
      _assert["default"].ok(!test('foo', {
        within: 'foo'
      }));
  
      _index["default"].defaultOptions.caseSensitive = false;
  
      _assert["default"].ok(!test('foo', {
        within: 'FOO'
      }));
  
      _index["default"].defaultOptions.caseSensitive = defaultValue;
    });
    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_ID + '2', test('1', {
        "in": [2, 3, 4]
      }));
  
      _index["default"].formatMessage = defaultValue;
    });
  });