"use strict";

var _jsxRuntime = require("react/jsx-runtime");

var _enzyme = require("enzyme");

var _Item = require("../Item");

var _ItemModule = _interopRequireDefault(require("../Item.module.css"));

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

describe('Item Specs', function () {
  test('should render an Item with content', function () {
    var content = 'Hello Item';
    var item = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Item.Item, {
      children: content
    }));
    var expected = content;
    var actual = item.text();
    expect(actual).toBe(expected);
  });
  test('should support adding a `label`', function () {
    var expected = 'Item Label';
    var item = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Item.Item, {
      label: expected,
      children: "Hello Item"
    }));
    var actual = item.find(".".concat(_ItemModule["default"].label)).first().text();
    expect(actual).toBe(expected);
  });
  test('should support label with 0', function () {
    var item = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Item.Item, {
      label: 0,
      children: "Hello Item"
    }));
    var expected = '0';
    var actual = item.find(".".concat(_ItemModule["default"].label)).first().text();
    expect(actual).toBe(expected);
  });
  test('should support adding text as a child when a label is also set', function () {
    var expected = 'Hello Item';
    var item = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Item.Item, {
      label: "Item label",
      children: expected
    }));
    var actual = item.find(".".concat(_ItemModule["default"].content)).first().text();
    expect(actual).toBe(expected);
  });
  test('should support `slotBefore`', function () {
    var expected = 'slot before';
    var item = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Item.Item, {
      slotBefore: expected,
      children: "Hello Item"
    }));
    var actual = item.find(".".concat(_ItemModule["default"].slotBefore)).first().text();
    expect(actual).toBe(expected);
  });
  test('should support `slotAfter`', function () {
    var expected = 'slot after';
    var item = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Item.Item, {
      slotAfter: expected,
      children: "Hello Item"
    }));
    var actual = item.find(".".concat(_ItemModule["default"].slotAfter)).first().text();
    expect(actual).toBe(expected);
  });
  test('should support repositioning of the label', function () {
    var item = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Item.Item, {
      labelPosition: "above",
      label: "Item label",
      children: "Hello Item"
    }));
    var expected = _ItemModule["default"].labelAbove;
    var actual = item.find(".".concat(_ItemModule["default"].itemContent)).first().prop('className');
    expect(actual).toContain(expected);
  });
  test('should not include the selected class when not selected', function () {
    var item = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Item.Item, {
      children: "Hello Item"
    }));
    var expected = 'selected';
    var actual = item.find("div.".concat(_ItemModule["default"].item)).prop('className');
    expect(actual).not.toContain(expected);
  });
  test('should add the selected class when given the selected prop', function () {
    var item = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Item.Item, {
      selected: true,
      children: "Hello Item"
    }));
    var expected = 'selected';
    var actual = item.find("div.".concat(_ItemModule["default"].item)).prop('className');
    expect(actual).toContain(expected);
  });
  test('should apply small class when size prop is `small`', function () {
    var item = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Item.ItemBase, {
      size: "small",
      children: "Hello Item"
    }));
    var expected = 'small';
    var actual = item.first().prop('className');
    expect(actual).toBe(expected);
  });
  test('should apply large class by default', function () {
    var item = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Item.ItemBase, {
      children: "Hello Item"
    }));
    var expected = 'large';
    var actual = item.first().prop('className');
    expect(actual).toBe(expected);
  });
  test('should apply centered class when centered prop is true', function () {
    var item = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Item.ItemBase, {
      centered: true,
      children: "Hello Item"
    }));
    var expected = 'centered';
    var actual = item.first().prop('className');
    expect(actual).toContain(expected);
  });
  test('should support RTL text', function () {
    var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Item.ItemBase, {
      children: "Hello \u05DE\u05E6\u05D1 \u05EA\u05DE\u05D5\u05E0\u05D4"
    }));
    var expected = 'rtl';
    var actual = subject.find('.text').prop('style');
    expect(actual).toHaveProperty('direction', expected);
  });
});