"use strict";

var _react = _interopRequireDefault(require("react"));
var _noop = _interopRequireDefault(require("lodash/noop"));
var _enzyme = require("enzyme");
var _index = _interopRequireDefault(require("./index"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
/* eslint-env jest */

var colorPalettes = {
  colorPalettes: [{
    identifier: 'default HKS_colors',
    colors: [{
      identifier: 'red',
      hex_value: '#FF0000',
      title: 'red'
    }, {
      identifier: 'blue',
      hex_value: '#0000FF',
      title: 'blue'
    }, {
      identifier: 'black',
      hex_value: '#000000',
      title: 'black'
    }],
    title: 'HKS'
  }, {
    identifier: 'default Pantone_colors',
    colors: [{
      identifier: 'red',
      hex_value: '#FF0000',
      title: 'red'
    }, {
      identifier: 'black',
      hex_value: '#000000',
      title: 'black'
    }, {
      identifier: 'white',
      hex_value: '#FFFFFF',
      title: 'white'
    }, {
      identifier: 'blue',
      hex_value: '#0000FF',
      title: 'blue'
    }, {
      identifier: 'green',
      hex_value: '#00FF00',
      title: 'green'
    }],
    title: 'Pantone'
  }, {
    identifier: 'default RAL_colors',
    colors: [{
      identifier: 'red',
      hex_value: '#FF0000',
      title: 'red'
    }, {
      identifier: 'black',
      hex_value: '#000000',
      title: 'black'
    }, {
      identifier: 'white',
      hex_value: '#FFFFFF',
      title: 'white'
    }, {
      identifier: 'yellow',
      hex_value: '#FFFF00',
      title: 'yellow'
    }, {
      identifier: 'blue',
      hex_value: '#0000FF',
      title: 'blue'
    }, {
      identifier: 'green',
      hex_value: '#00FF00',
      title: 'green'
    }, {
      identifier: 'mint',
      hex_value: '#BBDDAA',
      title: 'mint'
    }, {
      identifier: 'violett',
      hex_value: '#AAAAFF',
      title: 'violett'
    }, {
      identifier: 'cyan',
      hex_value: '#00FFFF',
      title: 'cyan'
    }, {
      identifier: 'grey',
      hex_value: '#eeeeee',
      title: 'grey'
    }],
    title: 'RAL'
  }]
};
var color = {
  identifier: 'grey',
  hex_value: '#eeeeee',
  title: 'grey'
};
var usedColors = [{
  hex_value: '000000',
  identifier: 'black',
  palette: 'default',
  value: 'rgb(0, 0, 0)'
}];
it('renders correctly', function () {
  var tree = (0, _enzyme.render)( /*#__PURE__*/_react["default"].createElement(_index["default"], {
    colorPalettes: colorPalettes.colorPalettes,
    colorPalette: 'HKS',
    selectedColor: color,
    colorSelectClick: _noop["default"],
    closeColorPalettes: _noop["default"]
  }));
  expect(tree).toMatchSnapshot();
});
it('renders a boxed component with the boxed prop', function () {
  var tree = (0, _enzyme.render)( /*#__PURE__*/_react["default"].createElement(_index["default"], {
    width: "xs",
    colorPalettes: colorPalettes.colorPalettes,
    colorPalette: 'HKS',
    selectedColor: color,
    colorSelectClick: _noop["default"],
    closeColorPalettes: _noop["default"],
    boxed: true
  }));
  expect(tree).toMatchSnapshot();
});
it('calls the colorSelectClick callback when the user changes the color', function () {
  var onChangeHandler = jest.fn();
  var tree = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(_index["default"], {
    width: "xs",
    colorPalettes: colorPalettes.colorPalettes,
    colorPalette: 'HKS',
    customColor: '',
    selectedColor: color,
    colorSelectClick: onChangeHandler,
    closeColorPalettes: _noop["default"],
    usedColors: usedColors,
    palette: 'default'
  }));
  var input = tree.find('div[className^="ColorPalettes-usedColorWrapper"]');
  input.simulate('mousedown');
  expect(onChangeHandler).toHaveBeenCalled();
});