import * as React from 'react'; import { render, screen } from '@testing-library/react'; import { Sidebar } from '../Sidebar'; test('Renders without children', () => { render(
); expect(screen.getByTestId('sidebar').firstChild).toBeVisible(); }); test('Renders children', () => { render(Test); expect(screen.getByText('Test')).toBeVisible(); }); test('Renders with only class name pf-v5-c-sidebar by default', () => { render(Test); expect(screen.getByText('Test').parentElement).toHaveClass('pf-v5-c-sidebar', { exact: true }); }); test('Renders with class name pf-v5-c-sidebar', () => { render(Test); expect(screen.getByText('Test').parentElement).toHaveClass('pf-v5-c-sidebar'); }); test('Renders with custom class name when className prop is provided', () => { render(Test); expect(screen.getByText('Test').parentElement).toHaveClass('custom-class'); }); test('Renders with class name pf-m-no-background when hasNoBackground prop is passed', () => { render(Test); expect(screen.getByText('Test').parentElement).toHaveClass('pf-m-no-background'); }); test('Renders with class name pf-m-border when hasBorder prop is passed', () => { render(Test); expect(screen.getByText('Test')).toHaveClass('pf-m-border'); }); test('Renders with class name pf-m-stack when "stack" is passed to orientation prop', () => { render(Test); expect(screen.getByText('Test').parentElement).toHaveClass('pf-m-stack'); }); test('Renders with class name pf-m-split when "split" is passed to orientation prop', () => { render(Test); expect(screen.getByText('Test').parentElement).toHaveClass('pf-m-split'); }); test('Renders with class name pf-m-panel-right when isPanelRight prop is passed', () => { render(Test); expect(screen.getByText('Test').parentElement).toHaveClass('pf-m-panel-right'); }); test('Renders with class name pf-m-gutter when hasGutter prop is passed', () => { render(Test); expect(screen.getByText('Test').parentElement).toHaveClass('pf-m-gutter'); }); test('Renders with class name pf-m-sidebar__main by default for child component', () => { render(Test); expect(screen.getByText('Test')).toHaveClass('pf-v5-c-sidebar__main'); }); test('Renders with inherited element props spread to the component', () => { render(Test); expect(screen.getByText('Test').parentElement).toHaveAccessibleName('Test label'); }); test('Matches the snapshot', () => { const { asFragment } = render(Test); expect(asFragment()).toMatchSnapshot(); });