"use strict";

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

var _index = _interopRequireDefault(require("../index"));

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

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

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('Select', function () {
  var testOptions = [{
    value: 'chocolate',
    label: 'Chocolate'
  }, {
    value: 'strawberry',
    label: 'Strawberry'
  }, {
    value: 'vanilla',
    label: 'Vanilla'
  }];
  test('should pass options to React Select', function () {
    var shallowWrapper = (0, _enzyme.shallow)(_react.default.createElement(_index.default, {
      options: testOptions
    }));
    expect(shallowWrapper.find('.vs-default-react-select').prop("options")).toBe(testOptions);
  });
  test('should have the vs-input-error classname when an error is passed', function () {
    var shallowWrapper = (0, _enzyme.shallow)(_react.default.createElement(_index.default, {
      options: testOptions,
      error: true
    }));
    expect(shallowWrapper.find('.vs-default-react-select').hasClass('vs-input-error')).toBe(true);
  });
  test('should pass additional arbitrary parameters to react select', function () {
    var shallowWrapper = (0, _enzyme.shallow)(_react.default.createElement(_index.default, {
      options: testOptions,
      className: "additional-classname",
      otherProp: 'another prop'
    }));
    expect(shallowWrapper.find('.vs-default-react-select').hasClass('additional-classname')).toBe(true);
    expect(shallowWrapper.find('.vs-default-react-select').prop("otherProp")).toBe("another prop");
  });
  test('should isDisabled to React Select when given disabled', function () {
    var shallowWrapper = (0, _enzyme.shallow)(_react.default.createElement(_index.default, {
      options: testOptions,
      disabled: true
    }));
    expect(shallowWrapper.find('.vs-default-react-select').prop("isDisabled")).toBe(true);
  });
});