import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";

var _templateObject;

import React from 'react';
import { cleanup, render, screen } from '@testing-library/react';
import Badge from '../index';
import ConfigProvider from '../../config-provider';
describe('Badge', function () {
  afterEach(cleanup);
  it('should render dot shape badge', function () {
    render( /*#__PURE__*/React.createElement(Badge, {
      "data-testid": "badge-root"
    }));
    expect(screen.getByTestId('badge-root')).toBeTruthy();
    expect(screen.getByTestId('badge-root').className).toEqual('za-badge za-badge--dot');
  });
  it('should render rect shape badge with text', function () {
    render( /*#__PURE__*/React.createElement(Badge, {
      shape: "rect",
      text: "\u514D\u8D39",
      "data-testid": "badge-root"
    }));
    expect(screen.getByTestId('badge-root')).toBeTruthy();
    expect(screen.getByTestId('badge-root').className).toEqual('za-badge za-badge--rect');
    expect(screen.getByText('免费')).toBeTruthy();
    expect(screen.getByTestId('badge-root').firstChild.nodeName.toLowerCase()).toEqual('sup');
    expect(screen.getByText('免费').className).toEqual('za-badge__content');
  });
  it('should render radius shape badge with text', function () {
    render( /*#__PURE__*/React.createElement(Badge, {
      shape: "radius"
    }, "foo"));
    expect(screen.getByText('foo')).toBeTruthy();
    expect(screen.getByText('foo').className).toEqual('za-badge za-badge--radius za-badge--sup');
  });
  it('should render round shape badge with text', function () {
    render( /*#__PURE__*/React.createElement(Badge, {
      shape: "round",
      text: "99+"
    }));
    expect(screen.getByText('99+')).toBeTruthy();
    expect(screen.getByText('99+').className).toEqual('za-badge__content');
    expect(screen.getByText('99+').parentElement.className).toEqual('za-badge za-badge--round');
  });
  test.each(_templateObject || (_templateObject = _taggedTemplateLiteral(["\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;
    render( /*#__PURE__*/React.createElement(Badge, {
      "data-testid": "badge-root",
      className: className,
      shape: shape
    }));
    expect(screen.getByTestId('badge-root').className).toEqual(expected);
  });
  test('should use prefixCls from context', function () {
    render( /*#__PURE__*/React.createElement(ConfigProvider, {
      prefixCls: "zarm"
    }, /*#__PURE__*/React.createElement(Badge, {
      "data-testid": "badge-root"
    })));
    expect(screen.getByTestId('badge-root').className).toEqual('zarm-badge zarm-badge--dot');
  });
  test('should forward ref from parent', function () {
    var ref = /*#__PURE__*/React.createRef();
    render( /*#__PURE__*/React.createElement(Badge, {
      ref: ref
    }));
    expect(ref.current.nodeName.toLowerCase()).toEqual('span');
  });
  test('should render with default props', function () {
    var _render = render( /*#__PURE__*/React.createElement(Badge, null)),
        container = _render.container;

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