UNPKG

@zohodesk/dot

Version:

In this Library, we Provide Some Basic Components to Build Your Application

157 lines 4.69 kB
import React from 'react'; import { render } from '@testing-library/react'; import IconButton from "../IconButton.js"; describe('IconButton', () => { test('rendering the defult props', () => { const { asFragment } = render( /*#__PURE__*/React.createElement(IconButton, null)); expect(asFragment()).toMatchSnapshot(); }); const palette = ['primary', 'primaryFilled', 'default']; test.each(palette)('rendering the palette of- %s', palette => { const { asFragment } = render( /*#__PURE__*/React.createElement(IconButton, { palette: palette })); expect(asFragment()).toMatchSnapshot(); }); test.each(palette)('rendering the isActive true with palette of- %s', palette => { const { asFragment } = render( /*#__PURE__*/React.createElement(IconButton, { isActive: true, palette: palette })); expect(asFragment()).toMatchSnapshot(); }); const sizes = ['xsmall', 'small', 'medium', 'large', 'xlarge']; test.each(sizes)('rendering the size of- %s', size => { const { asFragment } = render( /*#__PURE__*/React.createElement(IconButton, { size: size })); expect(asFragment()).toMatchSnapshot(); }); const hoverType = ['default', 'border', 'bg']; test.each(hoverType)('rendering the hovertypes- %s', hoverType => { const { asFragment } = render( /*#__PURE__*/React.createElement(IconButton, { hoverType: hoverType })); expect(asFragment()).toMatchSnapshot(); }); test('rendering isNeedEffect is False', () => { const { asFragment } = render( /*#__PURE__*/React.createElement(IconButton, { isNeedEffect: false })); expect(asFragment()).toMatchSnapshot(); }); test('rendering ally', () => { const { asFragment } = render( /*#__PURE__*/React.createElement(IconButton, { a11y: { ariaLabel: 'ariaLabel', ariaControls: 'ariaControls', ariaLabelledby: 'ariaLabelledby', ariaHaspopup: true, ariaExpanded: true } })); expect(asFragment()).toMatchSnapshot(); }); test('rendering ally', () => { const { asFragment } = render( /*#__PURE__*/React.createElement(IconButton, { a11y: { ariaHaspopup: false, ariaExpanded: false } })); expect(asFragment()).toMatchSnapshot(); }); test('rendering needButtonTag', () => { const { asFragment } = render( /*#__PURE__*/React.createElement(IconButton, { needButtonTag: false })); expect(asFragment()).toMatchSnapshot(); }); test('rendering tourId', () => { const { asFragment } = render( /*#__PURE__*/React.createElement(IconButton, { tourId: "tourId" })); expect(asFragment()).toMatchSnapshot(); }); test('rendering in Icon', () => { const { asFragment } = render( /*#__PURE__*/React.createElement(IconButton, { iconName: "ZD-GN-infoStroke", isBold: true, iconSize: "13", iconClass: "iconClass" })); expect(asFragment()).toMatchSnapshot(); }); test('rendering in dataIsHtml is True', () => { const { asFragment } = render( /*#__PURE__*/React.createElement(IconButton, { dataIsHtml: true })); expect(asFragment()).toMatchSnapshot(); }); test('rendering in isDisabled is True', () => { const { asFragment } = render( /*#__PURE__*/React.createElement(IconButton, { isDisabled: true })); expect(asFragment()).toMatchSnapshot(); }); test('rendering in ClassName', () => { const { asFragment } = render( /*#__PURE__*/React.createElement(IconButton, { className: "IconButtonClass" })); expect(asFragment()).toMatchSnapshot(); }); test('rendering in title', () => { const { asFragment } = render( /*#__PURE__*/React.createElement(IconButton, { title: "IconTitle" })); expect(asFragment()).toMatchSnapshot(); }); test('eleRef prop is a function', () => { // Create a mock function const mockEleRef = jest.fn(); const { asFragment } = render( /*#__PURE__*/React.createElement(IconButton, { eleRef: mockEleRef })); expect(asFragment()).toMatchSnapshot(); }); test('Checking the "Children"', () => { const { asFragment } = render( /*#__PURE__*/React.createElement(IconButton, { customClass: "customClassButtonGroup" }, /*#__PURE__*/React.createElement("span", null, "Element 1"), /*#__PURE__*/React.createElement("span", null, "Element 2"), /*#__PURE__*/React.createElement("span", null, "Element 3"))); expect(asFragment()).toMatchSnapshot(); }); });