"use strict";

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

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

var _enzyme = require("enzyme");

var _enzymeToJson = require("enzyme-to-json");

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

describe("components/Dropdown/DropdownBlockLink", function () {
  it("should render as a `div`", function () {
    var component = (0, _enzyme.shallow)(_react["default"].createElement(_index["default"], null, "foo"));
    expect(component.type()).toBe("div");
  });
  it("should render children", function () {
    var component = (0, _enzyme.shallow)(_react["default"].createElement(_index["default"], null, "foo"));
    expect(component.text()).toBe("foo");
  });
  it("should render with test section", function () {
    var component = (0, _enzyme.shallow)(_react["default"].createElement(_index["default"], {
      testSection: "goose"
    }, "foo"));
    expect(component.is('[data-test-section="goose"]')).toBe(true);
  });
  it("should render with a track id", function () {
    var component = (0, _enzyme.shallow)(_react["default"].createElement(_index["default"], {
      trackId: "goose"
    }, "foo"));
    expect(component.is('[data-track-id="goose"]')).toBe(true);
  });
  it("should render with a min width", function () {
    var component = (0, _enzyme.shallow)(_react["default"].createElement(_index["default"], {
      minWidth: "300px"
    }, "foo"));
    expect(component.prop("style")).toEqual({
      minWidth: "300px"
    });
  });
  it("should render with link styling by default", function () {
    var component = (0, _enzyme.shallow)(_react["default"].createElement(_index["default"], null, "foo"));
    expect(component.prop("className")).toEqual("link oui-dropdown__block-link");
  });
  it("should render with link styling if prop passed as true", function () {
    var component = (0, _enzyme.shallow)(_react["default"].createElement(_index["default"], {
      isLink: true
    }, "foo"));
    expect(component.prop("className")).toEqual("link oui-dropdown__block-link");
  });
  it("should render with link styling if prop passed as false", function () {
    var component = (0, _enzyme.shallow)(_react["default"].createElement(_index["default"], {
      isLink: false
    }, "foo"));
    expect(component.prop("className")).toEqual("isSelected");
  });
  it("should call function that is passed in as `onClick` after click", function () {
    var obj = {
      func: function func() {
        return null;
      }
    };
    spyOn(obj, "func").and.stub();
    var component = (0, _enzyme.shallow)(_react["default"].createElement(_index["default"], {
      onClick: obj.func
    }, "Hello!"));
    component.simulate("click");
    expect(obj.func).toHaveBeenCalled();
  });
  it("should call function that is passed in as `onMouseEnter`", function () {
    var onClickMock = jest.fn();
    var onMouseEnterMock = jest.fn();
    var component = (0, _enzyme.shallow)(_react["default"].createElement(_index["default"], {
      onClick: onClickMock,
      onMouseEnter: onMouseEnterMock
    }, "Hello!"));
    component.simulate("mouseenter");
    expect(onMouseEnterMock).toHaveBeenCalled();
  });
  it("should call function that is passed in as `onMouseLeave`", function () {
    var onClickMock = jest.fn();
    var onMouseLeaveMock = jest.fn();
    var component = (0, _enzyme.shallow)(_react["default"].createElement(_index["default"], {
      onClick: onClickMock,
      onMouseLeave: onMouseLeaveMock
    }, "Hello!"));
    component.simulate("mouseleave");
    expect(onMouseLeaveMock).toHaveBeenCalled();
  });
  it("should add a checkbox when isMultiSelect is true", function () {
    var component = (0, _enzyme.shallow)(_react["default"].createElement(_index["default"], {
      isMultiSelect: true
    }, "foo"));
    expect(component.find("Checkbox").length).toBe(1);
  });
  it("should add a checked checkbox when isItemSelected is true", function () {
    var component = (0, _enzyme.mount)(_react["default"].createElement(_index["default"], {
      isItemSelected: true,
      isMultiSelect: true
    }, "foo"));
    expect((0, _enzymeToJson.mountToJson)(component)).toMatchSnapshot();
  });
});