"use strict";

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

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

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

var _react2 = require("@testing-library/react");

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

var _configProvider = _interopRequireDefault(require("../../config-provider"));

var _templateObject;

describe('Badge', function () {
  afterEach(_react2.cleanup);
  it('should render dot shape badge', function () {
    (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
      "data-testid": "badge-root"
    }));
    expect(_react2.screen.getByTestId('badge-root')).toBeTruthy();
    expect(_react2.screen.getByTestId('badge-root').className).toEqual('za-badge za-badge--dot');
  });
  it('should render rect shape badge with text', function () {
    (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
      shape: "rect",
      text: "\u514D\u8D39",
      "data-testid": "badge-root"
    }));
    expect(_react2.screen.getByTestId('badge-root')).toBeTruthy();
    expect(_react2.screen.getByTestId('badge-root').className).toEqual('za-badge za-badge--rect');
    expect(_react2.screen.getByText('免费')).toBeTruthy();
    expect(_react2.screen.getByTestId('badge-root').firstChild.nodeName.toLowerCase()).toEqual('sup');
    expect(_react2.screen.getByText('免费').className).toEqual('za-badge__content');
  });
  it('should render radius shape badge with text', function () {
    (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
      shape: "radius"
    }, "foo"));
    expect(_react2.screen.getByText('foo')).toBeTruthy();
    expect(_react2.screen.getByText('foo').className).toEqual('za-badge za-badge--radius za-badge--sup');
  });
  it('should render round shape badge with text', function () {
    (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
      shape: "round",
      text: "99+"
    }));
    expect(_react2.screen.getByText('99+')).toBeTruthy();
    expect(_react2.screen.getByText('99+').className).toEqual('za-badge__content');
    expect(_react2.screen.getByText('99+').parentElement.className).toEqual('za-badge za-badge--round');
  });
  test.each(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n    className         | shape       | expected\n    ", " | ", "    | ", "\n    ", " | ", "  | ", "\n    ", " | ", " | ", "\n    ", " | ", "   | ", "\n  "])), 'custom-badge', 'dot', 'za-badge za-badge--dot custom-badge', 'custom-badge', 'round', 'za-badge za-badge--round custom-badge', 'custom-badge', 'radius', 'za-badge za-badge--radius custom-badge', 'custom-badge', 'rect', 'za-badge za-badge--rect custom-badge')('should render with className - $className and shape - $shape', function (_ref) {
    var className = _ref.className,
        shape = _ref.shape,
        expected = _ref.expected;
    (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
      "data-testid": "badge-root",
      className: className,
      shape: shape
    }));
    expect(_react2.screen.getByTestId('badge-root').className).toEqual(expected);
  });
  test('should use prefixCls from context', function () {
    (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_configProvider.default, {
      prefixCls: "zarm"
    }, /*#__PURE__*/_react.default.createElement(_index.default, {
      "data-testid": "badge-root"
    })));
    expect(_react2.screen.getByTestId('badge-root').className).toEqual('zarm-badge zarm-badge--dot');
  });
  test('should forward ref from parent', function () {
    var ref = /*#__PURE__*/_react.default.createRef();

    (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
      ref: ref
    }));
    expect(ref.current.nodeName.toLowerCase()).toEqual('span');
  });
  test('should render with default props', function () {
    var _render = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, null)),
        container = _render.container;

    expect(container).toMatchSnapshot();
  });
});