UNPKG

@wonderflow/react-components

Version:

UI components from Wonderflow's Wanda design system

42 lines (41 loc) 2.03 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { fireEvent, render } from '@testing-library/react'; import { Button, ButtonsGroup } from './button'; describe('<Button>', () => { test('it should render properly', () => { const { container } = render(_jsx(Button, { children: "Click me" })); expect(container).not.toBeNull(); }); test('it should render properly as different type', () => { const { container } = render(_jsx(Button, { as: "a", children: "Click me" })); expect(container).not.toBeNull(); }); test('it should render properly as busy', () => { const { container } = render(_jsx(Button, { busy: true, children: "Click me" })); expect(container).not.toBeNull(); }); test('it should render properly with icon', () => { const { container } = render(_jsx(Button, { icon: "bell", children: "Click me" })); expect(container).not.toBeNull(); }); test('it should render properly with dimension', () => { const { container } = render(_jsx(Button, { dimension: "big", children: "Click me" })); expect(container).not.toBeNull(); }); test('it should click properly', () => { const { container, getByTestId } = render(_jsx(Button, { children: "Click me" })); fireEvent.click(getByTestId('Button')); expect(container).not.toBeNull(); }); test('it should not click while disabled', () => { const { container, getByTestId } = render(_jsx(Button, { disabled: true, children: "Click me" })); fireEvent.click(getByTestId('Button')); expect(container).not.toBeNull(); }); }); describe('<Buttons Group>', () => { test('it should render properly', () => { const { container } = render(_jsxs(ButtonsGroup, { children: [_jsx(Button, { pressed: true, children: "Pressed" }), _jsx(Button, { children: "Click" }), _jsx(Button, { disabled: true, children: "Disabled" })] })); expect(container).not.toBeNull(); }); });