"use strict";

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

var _enzyme = require("enzyme");

var _autosizeInput = _interopRequireDefault(require("../autosize-input"));

var _styledComponents = require("../styled-components");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

describe('AutosizeInput component', function () {
  var props = {
    value: 'test',
    id: 'test-id'
  };

  var ref = _react.default.createRef();

  test('renders correctly', function () {
    // $FlowFixMe
    var wrapper = (0, _enzyme.mount)(_react.default.createElement(_autosizeInput.default, _extends({}, props, {
      inputRef: ref
    })));
    var renderedInput = wrapper.find(_styledComponents.StyledInput).first();
    var renderedSizer = wrapper.find(_styledComponents.StyledInputSizer).first();
    expect(renderedInput).toExist();
    expect(renderedInput.props()).toMatchObject(_objectSpread({
      $width: '5px'
    }, props, {
      $ref: ref
    }));
    expect(renderedSizer).toExist();
    expect(renderedSizer.props()).toMatchObject({
      children: props.value,
      $ref: wrapper.instance().sizerRef
    });
  });
  test('had correct initial state', function () {
    var props = {
      value: 'test'
    }; // $FlowFixMe

    var wrapper = (0, _enzyme.mount)(_react.default.createElement(_autosizeInput.default, props));
    expect(wrapper.state().inputWidth).toEqual(5);
  });
});