"use strict";

var _react = _interopRequireDefault(require("react"));

var _enzyme = _interopRequireWildcard(require("enzyme"));

var _enzymeAdapterReact = _interopRequireDefault(require("enzyme-adapter-react-16"));

var _Form = require("../Form");

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 }; }

_enzyme.default.configure({
  adapter: new _enzymeAdapterReact.default()
});

describe('Form', function () {
  describe('Field', function () {
    it('should render required sign when field is required', function () {
      var wrapper = (0, _enzyme.mount)(_react.default.createElement(_Form.Field, {
        required: true
      }));
      expect(wrapper.find('span.form-group-required-sign')).toHaveLength(1);
    });
    it('should not render required sign when field is not required', function () {
      var wrapper = (0, _enzyme.mount)(_react.default.createElement(_Form.Field, null));
      expect(wrapper.find('span.form-group-required-sign')).toHaveLength(0);
    });
  });
  describe('Choice Input', function () {
    it('should render required sign when field is required', function () {
      var wrapper = (0, _enzyme.mount)(_react.default.createElement(_Form.ChoiceInput, {
        required: true
      }));
      expect(wrapper.find('span.form-group-required-sign')).toHaveLength(1);
    });
    it('should not render required sign when field is not required', function () {
      var wrapper = (0, _enzyme.mount)(_react.default.createElement(_Form.ChoiceInput, null));
      expect(wrapper.find('span.form-group-required-sign')).toHaveLength(0);
    });
    it('should use id as htmlFor on label when id is passed', function () {
      var wrapper = (0, _enzyme.mount)(_react.default.createElement(_Form.ChoiceInput, {
        id: "test-id"
      }));
      expect(wrapper.find('label[htmlFor="test-id"]')).toHaveLength(1);
      expect(wrapper.find('input[id="test-id"]')).toHaveLength(1);
    });
  });
  describe('TextField', function () {
    it('should use id as htmlFor on label when id is passed', function () {
      var wrapper = (0, _enzyme.mount)(_react.default.createElement(_Form.TextField, {
        id: "test-id"
      }));
      expect(wrapper.find('label[htmlFor="test-id"]')).toHaveLength(1);
      expect(wrapper.find('input[id="test-id"]')).toHaveLength(1);
    });
  });
  describe('Field', function () {
    it('should use id as htmlFor on label when id is passed', function () {
      var wrapper = (0, _enzyme.mount)(_react.default.createElement(_Form.Field, {
        htmlFor: "test-id"
      }));
      expect(wrapper.find('label[htmlFor="test-id"]')).toHaveLength(1);
    });
  });
  describe('SelectField', function () {
    it('should use id as htmlFor on label when id is passed', function () {
      var wrapper = (0, _enzyme.mount)(_react.default.createElement(_Form.SelectField, {
        id: "test-id"
      }));
      expect(wrapper.find('label[htmlFor="test-id"]')).toHaveLength(1);
      expect(wrapper.find('Select').at(0).prop('id')).toBe('test-id');
    });
  });
});