diff --git a/packages/react-core/src/components/ActionList/__tests__/ActionList.test.tsx b/packages/react-core/src/components/ActionList/__tests__/ActionList.test.tsx index ae5da51e036..b510293a7e0 100644 --- a/packages/react-core/src/components/ActionList/__tests__/ActionList.test.tsx +++ b/packages/react-core/src/components/ActionList/__tests__/ActionList.test.tsx @@ -1,14 +1,49 @@ -import * as React from 'react'; -import { render } from '@testing-library/react'; +import React from 'react'; +import { render, screen } from '@testing-library/react'; import { ActionList } from '../ActionList'; -describe('action list', () => { - test('renders successfully', () => { - const { asFragment } = render(test); - expect(asFragment()).toMatchSnapshot(); - }); - test('isIconList flag adds modifier', () => { - const { asFragment } = render(test); - expect(asFragment()).toMatchSnapshot(); - }); +test('Renders without children', () => { + render(); + expect(screen.getByTestId('action-list')).toBeVisible(); +}); + +test('Renders children', () => { + render(Test); + + expect(screen.getByText('Test')).toBeVisible(); +}); + +test('Renders with class pf-c-action-list', () => { + render(Test); + + expect(screen.getByText('Test')).toHaveClass('pf-c-action-list'); +}); + +test('Renders with custom class names provided via prop', () => { + render(Test); + + expect(screen.getByText('Test')).toHaveClass('custom-class'); +}); + +test('Does not render with class pf-m-icons by default', () => { + render(Test); + + expect(screen.getByText('Test')).not.toHaveClass('pf-m-icons'); +}); + +test('Renders with class pf-m-icons when isIconList is true', () => { + render(Test); + + expect(screen.getByText('Test')).toHaveClass('pf-m-icons'); +}); + +test('Renders with inherited element props spread to the component', () => { + render(Test); + + expect(screen.getByText('Test')).toHaveAccessibleName('Test label'); +}) + +test('Matches the snapshot', () => { + const { asFragment } = render(test); + expect(asFragment()).toMatchSnapshot(); }); diff --git a/packages/react-core/src/components/ActionList/__tests__/ActionListGroup.test.tsx b/packages/react-core/src/components/ActionList/__tests__/ActionListGroup.test.tsx index 4f1f2ddd74b..7279ae13985 100644 --- a/packages/react-core/src/components/ActionList/__tests__/ActionListGroup.test.tsx +++ b/packages/react-core/src/components/ActionList/__tests__/ActionListGroup.test.tsx @@ -1,10 +1,37 @@ -import * as React from 'react'; -import { render } from '@testing-library/react'; +import React from 'react'; +import { render, screen } from '@testing-library/react'; import { ActionListGroup } from '../ActionListGroup'; -describe('action list group', () => { - test('renders successfully', () => { - const { asFragment } = render(test); - expect(asFragment()).toMatchSnapshot(); - }); +test('Renders without children', () => { + render(); + expect(screen.getByTestId('action-list-group')).toBeVisible(); +}); + +test('Renders children', () => { + render(Test); + + expect(screen.getByText('Test')).toBeVisible(); +}); + +test('Renders with class pf-c-action-list__group', () => { + render(Test); + + expect(screen.getByText('Test')).toHaveClass('pf-c-action-list__group'); +}); + +test('Renders with custom class names provided via prop', () => { + render(Test); + + expect(screen.getByText('Test')).toHaveClass('custom-class'); +}); + +test('Renders with inherited element props spread to the component', () => { + render(Test); + + expect(screen.getByText('Test')).toHaveAccessibleName('Test label'); +}) + +test('Matches the snapshot', () => { + const { asFragment } = render(test); + expect(asFragment()).toMatchSnapshot(); }); diff --git a/packages/react-core/src/components/ActionList/__tests__/ActionListItem.test.tsx b/packages/react-core/src/components/ActionList/__tests__/ActionListItem.test.tsx index 7be807a1ecb..907051efc1e 100644 --- a/packages/react-core/src/components/ActionList/__tests__/ActionListItem.test.tsx +++ b/packages/react-core/src/components/ActionList/__tests__/ActionListItem.test.tsx @@ -1,10 +1,37 @@ -import * as React from 'react'; -import { render } from '@testing-library/react'; +import React from 'react'; +import { render, screen } from '@testing-library/react'; import { ActionListItem } from '../ActionListItem'; -describe('action list item', () => { - test('renders successfully', () => { - const { asFragment } = render(test); - expect(asFragment()).toMatchSnapshot(); - }); +test('Renders without children', () => { + render(); + expect(screen.getByTestId('action-list-item')).toBeVisible(); +}); + +test('Renders children', () => { + render(Test); + + expect(screen.getByText('Test')).toBeVisible(); +}); + +test('Renders with class pf-c-action-list__item', () => { + render(Test); + + expect(screen.getByText('Test')).toHaveClass('pf-c-action-list__item'); +}); + +test('Renders with custom class names provided via prop', () => { + render(Test); + + expect(screen.getByText('Test')).toHaveClass('custom-class'); +}); + +test('Renders with inherited element props spread to the component', () => { + render(Test); + + expect(screen.getByText('Test')).toHaveAccessibleName('Test label'); +}) + +test('Matches the snapshot', () => { + const { asFragment } = render(test); + expect(asFragment()).toMatchSnapshot(); }); diff --git a/packages/react-core/src/components/ActionList/__tests__/__snapshots__/ActionList.test.tsx.snap b/packages/react-core/src/components/ActionList/__tests__/__snapshots__/ActionList.test.tsx.snap index d010d4a0f0b..580055838e5 100644 --- a/packages/react-core/src/components/ActionList/__tests__/__snapshots__/ActionList.test.tsx.snap +++ b/packages/react-core/src/components/ActionList/__tests__/__snapshots__/ActionList.test.tsx.snap @@ -1,16 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`action list isIconList flag adds modifier 1`] = ` - -
- test -
-
-`; - -exports[`action list renders successfully 1`] = ` +exports[`Matches the snapshot 1`] = `