"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

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

var _enzyme = require("enzyme");

var _ = _interopRequireDefault(require("."));

describe('ColorPicker', function () {
  it('should display the ColorPicker element', function () {
    var node = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(_["default"], null));
    expect(node.hasClass('ColorPicker')).toBe(true);
  });
  it('should propgate changes to parent component', function () {
    var spy = jest.fn();
    var node = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(_["default"], {
      onChange: spy
    }));
    var input = node.find('input');
    input.simulate('change', {
      target: {
        value: '123'
      }
    });
    expect(spy).toHaveBeenCalledWith({
      target: {
        value: '123'
      }
    });
  });
  it('should set color via prop', function () {
    var node = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(_["default"], {
      color: '#000'
    }));
    var input = node.find('input');
    expect(input.prop('value')).toStrictEqual('#000');
  });
  it('should set color internally', function () {
    var node = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(_["default"], null));
    var input = node.find('input');
    input.simulate('change', {
      target: {
        value: '#000'
      }
    });
    setTimeout(function () {
      expect(input.prop('value')).toStrictEqual('#000');
    }, 100);
  });
});