diff --git a/packages/react-core/src/components/EmptyState/__tests__/EmptyState.test.tsx b/packages/react-core/src/components/EmptyState/__tests__/EmptyState.test.tsx
index db4aabdf63c..da0e6a508f1 100644
--- a/packages/react-core/src/components/EmptyState/__tests__/EmptyState.test.tsx
+++ b/packages/react-core/src/components/EmptyState/__tests__/EmptyState.test.tsx
@@ -1,6 +1,8 @@
-import * as React from 'react';
-import { render } from '@testing-library/react';
-import { shallow } from 'enzyme';
+import React from 'react';
+
+import { render, screen } from '@testing-library/react';
+import "@testing-library/jest-dom";
+
import AddressBookIcon from '@patternfly/react-icons/dist/esm/icons/address-book-icon';
import { EmptyState, EmptyStateVariant } from '../EmptyState';
import { EmptyStateBody } from '../EmptyStateBody';
@@ -12,8 +14,8 @@ import { Title, TitleSizes } from '../../Title';
describe('EmptyState', () => {
test('Main', () => {
- const view = render(
-
+ render(
+
HTTP Proxies
@@ -28,58 +30,59 @@ describe('EmptyState', () => {
);
- expect(view.container).toMatchSnapshot();
+ expect(screen.getByTestId('empty-state-test-id').outerHTML).toMatchSnapshot();
});
test('Main variant large', () => {
- const view = render(
-
- EmptyState large
+ render(
+
+
+ EmptyState large
+
);
- expect(view.container).toMatchSnapshot();
+ expect(screen.getByTestId('empty-state-test-id').outerHTML).toMatchSnapshot();
});
test('Main variant small', () => {
- const view = render(
-
- EmptyState small
+ render(
+
+
+ EmptyState small
+
);
- expect(view.container).toMatchSnapshot();
+ expect(screen.getByTestId('empty-state-test-id').outerHTML).toMatchSnapshot();
});
test('Main variant xs', () => {
- const view = render(
-
- EmptyState small
+ render(
+
+
+ EmptyState small
+
);
- expect(view.container).toMatchSnapshot();
+ expect(screen.getByTestId('empty-state-test-id').outerHTML).toMatchSnapshot();
});
test('Body', () => {
- const view = shallow( );
- expect(view.props().className).toBe('pf-c-empty-state__body custom-empty-state-body');
- expect(view.props().id).toBe('empty-state-1');
+ render( );
+ expect(screen.getByTestId('body-test-id')).toHaveClass('custom-empty-state-body pf-c-empty-state__body');
});
test('Secondary Action', () => {
- const view = shallow( );
- expect(view.props().className).toBe('pf-c-empty-state__secondary custom-empty-state-secondary');
- expect(view.props().id).toBe('empty-state-2');
+ render( );
+ expect(screen.getByTestId('actions-test-id')).toHaveClass('custom-empty-state-secondary pf-c-empty-state__secondary');
});
test('Icon', () => {
- const view = shallow(
-
- );
- expect(view.props().className).toBe('pf-c-empty-state__icon custom-empty-state-icon');
- expect(view.props().id).toBe('empty-state-icon');
+ render( );
+ expect(screen.getByTestId('icon-test-id').outerHTML).toContain('pf-c-empty-state__icon');
});
test('Wrap icon in a div', () => {
- const view = shallow(
+ const view = render(
{
id="empty-state-icon"
/>
);
- expect(view.find('div').props().className).toBe('pf-c-empty-state__icon custom-empty-state-icon');
- expect(view.find('AddressBookIcon').length).toBe(1);
- });
+
+ expect(view.container.querySelector('div')).toHaveClass('pf-c-empty-state__icon custom-empty-state-icon');
+ expect(view.container.querySelector('svg')).toBeInTheDocument();
+ })
test('Primary div', () => {
- const view = shallow(
-
+ render(
+
Link
);
- expect(view.props().className).toBe('pf-c-empty-state__primary custom-empty-state-prim-cls');
- expect(view.props().id).toBe('empty-state-prim-id');
+ expect(screen.getByTestId('primary-test-id').className).toContain('pf-c-empty-state__primary');
});
test('Full height', () => {
- const view = render(
-
- EmptyState large
+ render(
+
+
+ EmptyState large
+
);
- expect(view.container).toMatchSnapshot();
+ expect(screen.getByTestId('empty-state-test-id').outerHTML).toMatchSnapshot();
});
-
});
diff --git a/packages/react-core/src/components/EmptyState/__tests__/__snapshots__/EmptyState.test.tsx.snap b/packages/react-core/src/components/EmptyState/__tests__/__snapshots__/EmptyState.test.tsx.snap
index 8b7122c5d8d..15091741a23 100644
--- a/packages/react-core/src/components/EmptyState/__tests__/__snapshots__/EmptyState.test.tsx.snap
+++ b/packages/react-core/src/components/EmptyState/__tests__/__snapshots__/EmptyState.test.tsx.snap
@@ -1,136 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`EmptyState Full height 1`] = `
-
-
-
-
- EmptyState large
-
-
-
-
-`;
+exports[`EmptyState Full height 1`] = `""`;
-exports[`EmptyState Main 1`] = `
-
-
-
-
- HTTP Proxies
-
-
- Defining HTTP Proxies that exist on your network allows you to perform various actions through those proxies.
-
-
- New HTTP Proxy
-
-
-
- Learn more about this in the documentation.
-
-
-
-
-
-`;
+exports[`EmptyState Main 1`] = `"HTTP Proxies Defining HTTP Proxies that exist on your network allows you to perform various actions through those proxies.
New HTTP Proxy Learn more about this in the documentation.
"`;
-exports[`EmptyState Main variant large 1`] = `
-
-
-
-
- EmptyState large
-
-
-
-
-`;
+exports[`EmptyState Main variant large 1`] = `""`;
-exports[`EmptyState Main variant small 1`] = `
-
-
-
-
- EmptyState small
-
-
-
-
-`;
+exports[`EmptyState Main variant small 1`] = `""`;
-exports[`EmptyState Main variant xs 1`] = `
-
-
-
-
- EmptyState small
-
-
-
-
-`;
+exports[`EmptyState Main variant xs 1`] = `""`;
diff --git a/packages/react-core/src/components/Form/__tests__/FormGroup.test.tsx b/packages/react-core/src/components/Form/__tests__/FormGroup.test.tsx
index 069429232f9..051c79f1cc9 100644
--- a/packages/react-core/src/components/Form/__tests__/FormGroup.test.tsx
+++ b/packages/react-core/src/components/Form/__tests__/FormGroup.test.tsx
@@ -1,192 +1,217 @@
import React from 'react';
+
+import { render, screen } from '@testing-library/react';
+import '@testing-library/jest-dom';
+
+import { ValidatedOptions } from '../../../helpers/constants';
import { FormGroup } from '../FormGroup';
import { Form } from '../Form';
-import { render } from '@testing-library/react';
-import { mount } from 'enzyme';
-import { ValidatedOptions } from '../../../helpers/constants';
-describe('FormGroup component', () => {
+describe('FormGroup', () => {
const returnFunction = () => label
;
test('should render default form group variant', () => {
- const view = render(
+ const { asFragment } = render(
);
- expect(view.container).toMatchSnapshot();
+ expect(asFragment()).toMatchSnapshot();
});
test('should render inline form group variant', () => {
- const view = mount(
+ render(
);
- expect(view).toMatchSnapshot();
- expect(view.find('.pf-c-form__group-control').prop('className')).toMatch(/pf-m-inline/);
+ expect(screen.getByLabelText('label').parentElement).toHaveClass('pf-m-inline');
});
test('should render no padding-top form group variant', () => {
- const view = mount(
-
+ render(
+
);
- expect(view.find('.pf-c-form__group-label').prop('className')).toMatch(/no-padding-top/);
+ expect(screen.getByTestId('form-group-test-id').firstElementChild).toHaveClass('pf-m-no-padding-top');
});
test('should render form group variant with required label', () => {
- const view = render(
+ const { asFragment } = render(
);
- expect(view.container).toMatchSnapshot();
+ expect(asFragment()).toMatchSnapshot();
});
test('should render form group variant with node label', () => {
- const view = render(
+ const { asFragment } = render(
Header}>
);
- expect(view.container).toMatchSnapshot();
+ expect(asFragment()).toMatchSnapshot();
});
test('should render form group with additonal label info', () => {
- const view = render(
+ const { asFragment } = render(
Header} labelInfo="more info">
);
- expect(view.container).toMatchSnapshot();
+ expect(asFragment()).toMatchSnapshot();
});
test('should render form group variant with function label', () => {
- const view = render(
+ render(
);
- expect(view.container).toMatchSnapshot();
+
+ expect(screen.getByText('label')).toBeInTheDocument();
});
test('should render form group variant with node helperText', () => {
- const view = render(
+ render(
Header}>
);
- expect(view.container).toMatchSnapshot();
+
+ expect(screen.getByRole('heading', { name: 'Header' })).toBeInTheDocument();
});
test('should render form group variant with function helperText', () => {
- const view = render(
+ render(
);
- expect(view.container).toMatchSnapshot();
+
+ expect(screen.getByText('label')).toBeInTheDocument();
});
test('should render horizontal form group variant', () => {
- const view = render(
+ const { asFragment } = render(
);
- expect(view.container).toMatchSnapshot();
+ expect(asFragment()).toMatchSnapshot();
});
test('should render stacked horizontal form group variant', () => {
- const view = render(
+ const { asFragment } = render(
);
- expect(view.container).toMatchSnapshot();
+ expect(asFragment()).toMatchSnapshot();
});
test('should render helper text above input', () => {
- const view = render(
+ const { asFragment } = render(
);
- expect(view.container).toMatchSnapshot();
+ expect(asFragment()).toMatchSnapshot();
});
test('should render form group variant without label', () => {
- const view = render(
+ const { asFragment } = render(
);
- expect(view.container).toMatchSnapshot();
- });
-
- test('should render form group required variant', () => {
- const view = render(
-
-
-
- );
- expect(view.container).toMatchSnapshot();
+ expect(asFragment()).toMatchSnapshot();
});
test('should render form group invalid variant', () => {
- const view = render(
-
+ const { asFragment } = render(
+
);
- expect(view.container).toMatchSnapshot();
+ expect(asFragment()).toMatchSnapshot();
});
test('should render form group validated success variant', () => {
- const view = mount(
-
+ const { asFragment } = render(
+
);
- expect(view.find('.pf-c-form__helper-text.pf-m-success').length).toBe(1);
- expect(view).toMatchSnapshot();
+
+ expect(screen.getByTestId('form-group-test-id').querySelector('input + div')).toHaveClass('pf-m-success');
+ expect(asFragment()).toMatchSnapshot();
});
test('should render form group validated error variant', () => {
- const view = render(
-
+ const { asFragment } = render(
+
);
- expect(view.container).toMatchSnapshot();
+ expect(asFragment()).toMatchSnapshot();
});
test('should render form group validated warning variant', () => {
- const view = mount(
-
+ const { asFragment } = render(
+
);
- expect(view.find('.pf-c-form__helper-text.pf-m-warning').length).toBe(1);
- expect(view).toMatchSnapshot();
+
+ expect(screen.getByTestId('form-group-test-id').querySelector('input + div')).toHaveClass('pf-m-warning');
+ expect(asFragment()).toMatchSnapshot();
});
test('should render correctly when label is not a string with Children = Array', () => {
- const view = render(
+ const { asFragment } = render(
);
- expect(view.container).toMatchSnapshot();
+ expect(asFragment()).toMatchSnapshot();
});
});
diff --git a/packages/react-core/src/components/Form/__tests__/FormHelperText.test.tsx b/packages/react-core/src/components/Form/__tests__/FormHelperText.test.tsx
index fab912424b4..fe06f8e3764 100644
--- a/packages/react-core/src/components/Form/__tests__/FormHelperText.test.tsx
+++ b/packages/react-core/src/components/Form/__tests__/FormHelperText.test.tsx
@@ -1,36 +1,50 @@
import React from 'react';
-import { FormHelperText } from '../FormHelperText';
-import { render } from '@testing-library/react';
-import { shallow } from 'enzyme';
+
+import { render, screen } from '@testing-library/react';
+import '@testing-library/jest-dom';
+
import { ExclamationCircleIcon } from '@patternfly/react-icons';
+import { FormHelperText } from '../FormHelperText';
-test('renders with PatternFly Core styles', () => {
- const view = render( );
- expect(view.container).toMatchSnapshot();
-});
+describe('FormHelperText', () => {
+ test('renders with PatternFly Core styles', () => {
+ render(
+
+ test
+
+ );
+ expect(screen.getByText('test').outerHTML).toMatchSnapshot();
+ });
-test('renders with icon', () => {
- const view = render( } />);
- expect(view.container).toMatchSnapshot();
-});
+ test('renders with icon', () => {
+ render(
+ }>
+ test
+
+ );
+ expect(screen.getByText('test').outerHTML).toMatchSnapshot();
+ });
-test('className is added to the root element', () => {
- const view = shallow( );
- expect(view.prop('className')).toMatchSnapshot();
-});
+ test('className is added to the root element', () => {
+ render(test );
+ expect(screen.getByText('test').outerHTML).toMatchSnapshot();
+ });
-test('extra props are spread to the root element', () => {
- const testId = 'login-body';
- const view = shallow( );
- expect(view.prop('data-testid')).toBe(testId);
-});
+ test('extra props are spread to the root element', () => {
+ const testId = 'login-body';
+ render(test );
+ expect(screen.getByTestId(testId)).toBeInTheDocument();
+ });
+
+ test('LoginFooterItem with custom node', () => {
+ const CustomNode = () => My custom node
;
+
+ render(
+
+
+
+ );
-test('LoginFooterItem with custom node', () => {
- const CustomNode = () => My custom node
;
- const view = render(
-
-
-
- );
- expect(view.container).toMatchSnapshot();
+ expect(screen.getByText('My custom node').parentElement.outerHTML).toMatchSnapshot();
+ });
});
diff --git a/packages/react-core/src/components/Form/__tests__/__snapshots__/FormGroup.test.tsx.snap b/packages/react-core/src/components/Form/__tests__/__snapshots__/FormGroup.test.tsx.snap
index 27c6ff5b20b..a1cf9815318 100644
--- a/packages/react-core/src/components/Form/__tests__/__snapshots__/FormGroup.test.tsx.snap
+++ b/packages/react-core/src/components/Form/__tests__/__snapshots__/FormGroup.test.tsx.snap
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`FormGroup component should render correctly when label is not a string with Children = Array 1`] = `
-
-
+
`;
-exports[`FormGroup component should render default form group variant 1`] = `
-
+exports[`FormGroup should render default form group variant 1`] = `
+
@@ -73,11 +72,11 @@ exports[`FormGroup component should render default form group variant 1`] = `
-
+
`;
-exports[`FormGroup component should render form group invalid variant 1`] = `
-
+exports[`FormGroup should render form group invalid variant 1`] = `
+
@@ -111,11 +110,11 @@ exports[`FormGroup component should render form group invalid variant 1`] = `
-
+
`;
-exports[`FormGroup component should render form group required variant 1`] = `
-
-
+
`;
-exports[`FormGroup component should render form group validated error variant 1`] = `
-
+exports[`FormGroup should render form group validated success variant 1`] = `
+
-`;
-
-exports[`FormGroup component should render form group validated success variant 1`] = `
-
-
-
+
`;
-exports[`FormGroup component should render form group validated warning variant 1`] = `
-
+exports[`FormGroup should render form group validated warning variant 1`] = `
+
-
-`;
-
-exports[`FormGroup component should render form group variant with function helperText 1`] = `
-
-`;
-
-exports[`FormGroup component should render form group variant with function label 1`] = `
-
-`;
-
-exports[`FormGroup component should render form group variant with node helperText 1`] = `
-
+
`;
-exports[`FormGroup component should render form group variant with node label 1`] = `
-
-
+
`;
-exports[`FormGroup component should render form group variant with required label 1`] = `
-
-
+
`;
-exports[`FormGroup component should render form group variant without label 1`] = `
-
-
+
`;
-exports[`FormGroup component should render form group with additonal label info 1`] = `
-
-
+
`;
-exports[`FormGroup component should render helper text above input 1`] = `
-
+exports[`FormGroup should render helper text above input 1`] = `
+
-
+
`;
-exports[`FormGroup component should render horizontal form group variant 1`] = `
-
+exports[`FormGroup should render horizontal form group variant 1`] = `
+
-
-`;
-
-exports[`FormGroup component should render inline form group variant 1`] = `
-
-
-
-
-
- label
-
-
-
-
-
-
-
- this is helper text
-
-
-
-
+
`;
-exports[`FormGroup component should render stacked horizontal form group variant 1`] = `
-
+exports[`FormGroup should render stacked horizontal form group variant 1`] = `
+
-
+
`;
diff --git a/packages/react-core/src/components/Form/__tests__/__snapshots__/FormHelperText.test.tsx.snap b/packages/react-core/src/components/Form/__tests__/__snapshots__/FormHelperText.test.tsx.snap
index dbc6e7aecc1..82d21073646 100644
--- a/packages/react-core/src/components/Form/__tests__/__snapshots__/FormHelperText.test.tsx.snap
+++ b/packages/react-core/src/components/Form/__tests__/__snapshots__/FormHelperText.test.tsx.snap
@@ -1,49 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`LoginFooterItem with custom node 1`] = `
-
-
-
- My custom node
-
-
-
-`;
+exports[`FormHelperText LoginFooterItem with custom node 1`] = `"
My custom node
"`;
-exports[`className is added to the root element 1`] = `"pf-c-form__helper-text pf-m-hidden extra-class"`;
+exports[`FormHelperText className is added to the root element 1`] = `"test
"`;
-exports[`renders with PatternFly Core styles 1`] = `
-
-`;
+exports[`FormHelperText renders with PatternFly Core styles 1`] = `"test
"`;
-exports[`renders with icon 1`] = `
-
-`;
+exports[`FormHelperText renders with icon 1`] = `" test
"`;
diff --git a/packages/react-core/src/components/FormSelect/__tests__/FormSelect.test.tsx b/packages/react-core/src/components/FormSelect/__tests__/FormSelect.test.tsx
index 78edfd8a310..7b984bc210b 100644
--- a/packages/react-core/src/components/FormSelect/__tests__/FormSelect.test.tsx
+++ b/packages/react-core/src/components/FormSelect/__tests__/FormSelect.test.tsx
@@ -1,6 +1,10 @@
import React from 'react';
-import { render } from '@testing-library/react';
-import { shallow } from 'enzyme';
+
+import { render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import '@testing-library/jest-dom';
+
+import { Form } from '../../Form';
import { FormSelect } from '../FormSelect';
import { FormSelectOption } from '../FormSelectOption';
import { FormSelectOptionGroup } from '../FormSelectOptionGroup';
@@ -49,136 +53,141 @@ const groupedProps = {
value: '2'
};
-test('Simple FormSelect input', () => {
- const view = render(
-
- {props.options.map((option, index) => (
-
- ))}
-
- );
- expect(view.container).toMatchSnapshot();
-});
+describe('FormSelect', () => {
+ test('Simple FormSelect input', () => {
+ render(
+
+ {props.options.map((option, index) => (
+
+ ))}
+
+ );
+ expect(screen.getByLabelText('simple FormSelect').outerHTML).toMatchSnapshot();
+ });
-test('Grouped FormSelect input', () => {
- const view = render(
-
- {groupedProps.groups.map((group, index) => (
-
- {group.options.map((option, i) => (
-
- ))}
-
- ))}
-
- );
- expect(view.container).toMatchSnapshot();
-});
+ test('Grouped FormSelect input', () => {
+ render(
+
+ {groupedProps.groups.map((group, index) => (
+
+ {group.options.map((option, i) => (
+
+ ))}
+
+ ))}
+
+ );
+ expect(screen.getByLabelText('grouped FormSelect').outerHTML).toMatchSnapshot();
+ });
-test('Disabled FormSelect input ', () => {
- const view = render(
-
-
-
- );
- expect(view.container).toMatchSnapshot();
-});
+ test('Disabled FormSelect input ', () => {
+ render(
+
+
+
+ );
+ expect(screen.getByLabelText('disabled FormSelect').outerHTML).toMatchSnapshot();
+ });
-test('FormSelect input with aria-label does not generate console error', () => {
- const myMock = jest.fn() as any;
- global.console = { error: myMock } as any;
- const view = render(
-
-
-
- );
- expect(view.container).toMatchSnapshot();
- expect(myMock).not.toBeCalled();
-});
+ test('FormSelect input with aria-label does not generate console error', () => {
+ const myMock = jest.fn() as any;
+ global.console = { error: myMock } as any;
-test('FormSelect input with id does not generate console error', () => {
- const myMock = jest.fn() as any;
- global.console = { error: myMock } as any;
- const view = render(
-
-
-
- );
- expect(view.container).toMatchSnapshot();
- expect(myMock).not.toBeCalled();
-});
+ render(
+
+
+
+ );
-test('FormSelect input with no aria-label or id generates console error', () => {
- const myMock = jest.fn() as any;
- global.console = { error: myMock } as any;
- const view = render(
-
-
-
- );
- expect(view.container).toMatchSnapshot();
- expect(myMock).toBeCalled();
-});
+ expect(screen.getByLabelText('label').outerHTML).toMatchSnapshot();
+ expect(myMock).not.toBeCalled();
+ });
-test('invalid FormSelect input', () => {
- const view = render(
-
-
-
- );
- expect(view.container).toMatchSnapshot();
-});
+ test('FormSelect input with id does not generate console error', () => {
+ const myMock = jest.fn() as any;
+ global.console = { error: myMock } as any;
-test('validated success FormSelect input', () => {
- const view = shallow(
-
-
-
- );
- expect(view.find('.pf-c-form-control.pf-m-success').length).toBe(1);
- expect(view).toMatchSnapshot();
-});
+ render(
+
+
+
+ );
-test('validated error FormSelect input', () => {
- const view = render(
-
-
-
- );
- expect(view.container).toMatchSnapshot();
-});
+ expect(screen.getByLabelText('label').outerHTML).toMatchSnapshot();
+ expect(myMock).not.toBeCalled();
+ });
-test('validated warning FormSelect input', () => {
- const view = shallow(
-
-
-
- );
- expect(view.find('.pf-c-form-control.pf-m-warning').length).toBe(1);
- expect(view).toMatchSnapshot();
-});
+ test('FormSelect input with no aria-label or id generates console error', () => {
+ const myMock = jest.fn() as any;
+ global.console = { error: myMock } as any;
+ render(
+
+
+
+ );
-test('required FormSelect input', () => {
- const view = render(
-
-
-
- );
- expect(view.container).toMatchSnapshot();
-});
+ expect(screen.getByTestId('test-id').outerHTML).toMatchSnapshot();
+ expect(myMock).toBeCalled();
+ });
+
+ test('invalid FormSelect input', () => {
+ render(
+
+
+
+ );
+ expect(screen.getByLabelText('invalid FormSelect').outerHTML).toMatchSnapshot();
+ });
+
+ test('validated success FormSelect input', () => {
+ render(
+
+
+
+ );
+
+ const formSelect = screen.getByLabelText('validated FormSelect');
+
+ expect(formSelect.className).toContain('pf-m-success');
+ expect(formSelect.outerHTML).toMatchSnapshot();
+ });
+
+ test('validated warning FormSelect input', () => {
+ render(
+
+
+
+ );
+
+ const formSelect = screen.getByLabelText('validated FormSelect');
+
+ expect(formSelect.className).toContain('pf-m-warning');
+ expect(formSelect.outerHTML).toMatchSnapshot();
+ });
+
+ test('required FormSelect input', () => {
+ render(
+
+
+
+ );
+
+ expect(screen.getByLabelText('required FormSelect')).toHaveAttribute('required');
+ });
+
+ test('FormSelect passes value and event to onChange handler', () => {
+ const myMock = jest.fn();
+
+ render(
+
+
+
+ );
+
+ userEvent.selectOptions(screen.getByLabelText('Some label'), 'Mr');
-test('FormSelect passes value and event to onChange handler', () => {
- const myMock = jest.fn();
- const newValue = 1;
- const event = {
- currentTarget: { value: newValue }
- };
- const view = shallow(
-
-
-
- );
- view.find('select').simulate('change', event);
- expect(myMock).toBeCalledWith(newValue, event);
+ expect(myMock).toBeCalled();
+ expect(myMock.mock.calls[0][0]).toEqual('mr');
+ });
});
diff --git a/packages/react-core/src/components/FormSelect/__tests__/__snapshots__/FormSelect.test.tsx.snap b/packages/react-core/src/components/FormSelect/__tests__/__snapshots__/FormSelect.test.tsx.snap
index f3fa9800fc4..2cf1a416d87 100644
--- a/packages/react-core/src/components/FormSelect/__tests__/__snapshots__/FormSelect.test.tsx.snap
+++ b/packages/react-core/src/components/FormSelect/__tests__/__snapshots__/FormSelect.test.tsx.snap
@@ -1,311 +1,19 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`Disabled FormSelect input 1`] = `
-
-
-
- Mr
-
-
-
-`;
+exports[`FormSelect Disabled FormSelect input 1`] = `"Mr "`;
-exports[`FormSelect input with aria-label does not generate console error 1`] = `
-
-
-
- Mr
-
-
-
-`;
+exports[`FormSelect FormSelect input with aria-label does not generate console error 1`] = `"Mr "`;
-exports[`FormSelect input with id does not generate console error 1`] = `
-
-
-
- Mr
-
-
-
-`;
+exports[`FormSelect FormSelect input with id does not generate console error 1`] = `"Mr "`;
-exports[`FormSelect input with no aria-label or id generates console error 1`] = `
-
-
-
- Mr
-
-
-
-`;
+exports[`FormSelect FormSelect input with no aria-label or id generates console error 1`] = `"Mr "`;
-exports[`Grouped FormSelect input 1`] = `
-
-
-
-
- The First Option
-
-
- Second option is selected by default
-
-
-
-
- The Third Option
-
-
- The Fourth option
-
-
-
-
- The Fifth Option
-
-
- The Sixth option
-
-
-
-
-`;
+exports[`FormSelect Grouped FormSelect input 1`] = `"The First Option Second option is selected by default The Third Option The Fourth option The Fifth Option The Sixth option "`;
-exports[`Simple FormSelect input 1`] = `
-
-
-
- Please Choose
-
-
- Mr
-
-
- Miss
-
-
- Mrs
-
-
- Ms
-
-
- Dr
-
-
- Other
-
-
-
-`;
+exports[`FormSelect Simple FormSelect input 1`] = `"Please Choose Mr Miss Mrs Ms Dr Other "`;
-exports[`invalid FormSelect input 1`] = `
-
-
-
- Mr
-
-
-
-`;
+exports[`FormSelect invalid FormSelect input 1`] = `"Mr "`;
-exports[`required FormSelect input 1`] = `
-
-
-
- Mr
-
-
-
-`;
+exports[`FormSelect validated success FormSelect input 1`] = `"Mr "`;
-exports[`validated error FormSelect input 1`] = `
-
-
-
- Mr
-
-
-
-`;
-
-exports[`validated success FormSelect input 1`] = `
-
-
-
-`;
-
-exports[`validated warning FormSelect input 1`] = `
-
-
-
-`;
+exports[`FormSelect validated warning FormSelect input 1`] = `"Mr "`;
diff --git a/packages/react-core/src/components/InputGroup/__tests__/InputGroup.test.tsx b/packages/react-core/src/components/InputGroup/__tests__/InputGroup.test.tsx
index e896ac9d975..b040974b2eb 100644
--- a/packages/react-core/src/components/InputGroup/__tests__/InputGroup.test.tsx
+++ b/packages/react-core/src/components/InputGroup/__tests__/InputGroup.test.tsx
@@ -1,47 +1,23 @@
import React from 'react';
-import { shallow } from 'enzyme';
+
+import { render, screen } from '@testing-library/react';
+
import { InputGroup } from '../InputGroup';
-import { InputGroupText, InputGroupTextVariant } from '../InputGroupText';
import { Button } from '../../Button';
import { TextInput } from '../../TextInput';
-test('InputGroupText', () => {
- const view = shallow(
-
- @
-
- );
- expect(view.find('span')).toHaveLength(1);
- const spanProps = view.find('span').props();
- expect(spanProps.className).toEqual(expect.stringContaining('inpt-grp-text'));
- expect(spanProps.className).toEqual(expect.stringContaining('pf-m-plain'));
- expect(spanProps.id).toBe('email-npt-grp');
- expect(view.text()).toBe('@');
-});
-
-test('InputGroup', () => {
- const view = shallow(
-
-
-
- );
-
- expect(view.find('div')).toHaveLength(1);
- const divProps = view.find('div').props();
- expect(divProps.className).toEqual(expect.stringContaining('text-verify-cls'));
- expect(divProps.id).toBe('text-1');
-});
-
-test('add aria-describedby to form-control if one of the non form-controls has id', () => {
- // In this test, TextInput is a form-control component and Button is not.
- // If Button has an id props, this should be used in aria-describedby.
- const view = shallow(
-
-
-
- hello
-
-
- );
- expect(view.find(TextInput).props()['aria-describedby']).toBe('button-id');
+describe('InputGroup', () => {
+ test('add aria-describedby to form-control if one of the non form-controls has id', () => {
+ // In this test, TextInput is a form-control component and Button is not.
+ // If Button has an id props, this should be used in aria-describedby.
+ render(
+
+
+
+ hello
+
+
+ );
+ expect(screen.getByLabelText('some text').getAttribute('aria-describedby')).toEqual('button-id');
+ });
});
diff --git a/packages/react-core/src/components/InputGroup/__tests__/InputGroupText.test.tsx b/packages/react-core/src/components/InputGroup/__tests__/InputGroupText.test.tsx
new file mode 100644
index 00000000000..de445aa93cf
--- /dev/null
+++ b/packages/react-core/src/components/InputGroup/__tests__/InputGroupText.test.tsx
@@ -0,0 +1,17 @@
+import React from 'react';
+
+import { render, screen } from '@testing-library/react';
+import '@testing-library/jest-dom';
+
+import { InputGroupText, InputGroupTextVariant } from '../InputGroupText';
+
+describe('InputGroupText', () => {
+ test('renders', () => {
+ render(
+
+ @
+
+ );
+ expect(screen.getByText('@')).toBeInTheDocument();
+ });
+});
diff --git a/packages/react-core/src/components/Label/__tests__/Label.test.tsx b/packages/react-core/src/components/Label/__tests__/Label.test.tsx
index 52a04f6198f..5f34065ce53 100644
--- a/packages/react-core/src/components/Label/__tests__/Label.test.tsx
+++ b/packages/react-core/src/components/Label/__tests__/Label.test.tsx
@@ -1,84 +1,143 @@
import React from 'react';
-import { render } from '@testing-library/react';
-import { shallow, mount } from 'enzyme';
+
+import { render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import '@testing-library/jest-dom';
+
import { Label } from '../Label';
-test('label', () => {
- const view = render(Something );
- expect(view.container).toMatchSnapshot();
- const outline = render(Something );
- expect(outline).toMatchSnapshot();
- const compact = render(Something );
- expect(compact).toMatchSnapshot();
-});
+const labelColors = ['blue', 'cyan', 'green', 'orange', 'purple', 'red', 'grey'];
-test('label with href', () => {
- const view = render(Something );
- expect(view.container).toMatchSnapshot();
- const outline = render(
-
- Something
-
- );
- expect(outline).toMatchSnapshot();
-});
+describe('Label', () => {
+ test('renders', () => {
+ render(Something );
+ expect(screen.getByTestId('label-test-id').outerHTML).toMatchSnapshot();
+ });
-test('label with close button', () => {
- const view = render(Something );
- expect(view.container).toMatchSnapshot();
- const outline = render(
-
- Something
-
- );
- expect(outline).toMatchSnapshot();
-});
+ test('renders with outline variant', () => {
+ render(
+
+ Something
+
+ );
+ expect(screen.getByTestId('label-test-id').outerHTML).toMatchSnapshot();
+ });
-['blue', 'cyan', 'green', 'orange', 'purple', 'red', 'grey'].forEach(
- (color: string) =>
+ test('renders with isCompact', () => {
+ render(
+
+ Something
+
+ );
+ expect(screen.getByTestId('label-test-id').outerHTML).toMatchSnapshot();
+ });
+
+ test('label with href', () => {
+ render(
+
+ Something
+
+ );
+ expect(screen.getByTestId('label-test-id').outerHTML).toMatchSnapshot();
+ });
+
+ test('label with href with outline variant', () => {
+ render(
+
+ Something
+
+ );
+ expect(screen.getByTestId('label-test-id').outerHTML).toMatchSnapshot();
+ });
+
+ test('label with close button', () => {
+ render(
+
+ Something
+
+ );
+
+ expect(screen.getByTestId('label-test-id').outerHTML).toMatchSnapshot();
+ });
+
+ test('label with close button and outline variant', () => {
+ render(
+
+ Something
+
+ );
+ expect(screen.getByTestId('label-test-id').outerHTML).toMatchSnapshot();
+ });
+
+ labelColors.forEach((color: string) =>
test(`label with ${color} color`, () => {
- const view = render(Something );
- expect(view.container).toMatchSnapshot();
- const outline = render(
-
+ render(
+
Something
);
- expect(outline.container).toMatchSnapshot();
+ expect(screen.getByTestId('label-test-id').outerHTML).toMatchSnapshot();
})
-);
-
-test('label with additional class name', () => {
- const view = render(Something );
- expect(view.container).toMatchSnapshot();
-});
+ );
-test('label with additional class name and props', () => {
- const view = render(
-
- Something
-
+ labelColors.forEach((color: string) =>
+ test(`label with ${color} color with outline variant`, () => {
+ render(
+
+ Something
+
+ );
+ expect(screen.getByTestId('label-test-id').outerHTML).toMatchSnapshot();
+ })
);
- expect(view.container).toMatchSnapshot();
-});
-test('label with truncation', () => {
- const view = render(Something very very very very very long that should be truncated );
- expect(view.container).toMatchSnapshot();
-});
+ test('label with additional class name', () => {
+ render(
+
+ Something
+
+ );
+ expect(screen.getByTestId('label-test-id').outerHTML).toMatchSnapshot();
+ });
+
+ test('label with additional class name and props', () => {
+ render(
+
+ Something
+
+ );
+ expect(screen.getByTestId('label-test-id').outerHTML).toMatchSnapshot();
+ });
+
+ test('label with truncation', () => {
+ render(
+
+ Something very very very very very long that should be truncated
+
+ );
+ expect(screen.getByTestId('label-test-id').outerHTML).toMatchSnapshot();
+ });
+
+ test('editable label', () => {
+ render(
+
+ Something
+
+ );
+
+ const button = screen.getByRole('button', { name: 'Something' });
+
+ expect(button).toBeInTheDocument();
+ expect(screen.getByTestId('label-test-id').outerHTML).toMatchSnapshot();
-test('editable label', () => {
- const view = mount(
- Something );
- const button = view.find('button.pf-c-label__content');
- expect(button.length).toBe(1);
- expect(view).toMatchSnapshot();
-
- button.simulate('click');
- const clickedButton = view.find('button.pf-c-label__content');
- expect(clickedButton.length).toBe(0);
- expect(view).toMatchSnapshot();
+ userEvent.click(button);
+ expect(screen.queryByRole('button', { name: 'Something' })).toBeNull();
+ expect(screen.getByTestId('label-test-id').outerHTML).toMatchSnapshot();
+ });
});
diff --git a/packages/react-core/src/components/Label/__tests__/__snapshots__/Label.test.tsx.snap b/packages/react-core/src/components/Label/__tests__/__snapshots__/Label.test.tsx.snap
index a31e1e4cf12..79dc610f496 100644
--- a/packages/react-core/src/components/Label/__tests__/__snapshots__/Label.test.tsx.snap
+++ b/packages/react-core/src/components/Label/__tests__/__snapshots__/Label.test.tsx.snap
@@ -1,855 +1,53 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`editable label 1`] = `
-
-
-
- Something
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-`;
+exports[`Label editable label 1`] = `"Something "`;
-exports[`editable label 2`] = `
-
-
-
-
-
-`;
+exports[`Label editable label 2`] = `" "`;
-exports[`label 1`] = `
-
-
-
- Something
-
-
-
-`;
+exports[`Label label with additional class name 1`] = `"Something "`;
-exports[`label 2`] = `
-Object {
- "asFragment": [Function],
- "baseElement":
-
-
-
- Something
-
-
-
-
-
-
- Something
-
-
-
- ,
- "container":
-
-
- Something
-
-
-
,
- "debug": [Function],
- "findAllByAltText": [Function],
- "findAllByDisplayValue": [Function],
- "findAllByLabelText": [Function],
- "findAllByPlaceholderText": [Function],
- "findAllByRole": [Function],
- "findAllByTestId": [Function],
- "findAllByText": [Function],
- "findAllByTitle": [Function],
- "findByAltText": [Function],
- "findByDisplayValue": [Function],
- "findByLabelText": [Function],
- "findByPlaceholderText": [Function],
- "findByRole": [Function],
- "findByTestId": [Function],
- "findByText": [Function],
- "findByTitle": [Function],
- "getAllByAltText": [Function],
- "getAllByDisplayValue": [Function],
- "getAllByLabelText": [Function],
- "getAllByPlaceholderText": [Function],
- "getAllByRole": [Function],
- "getAllByTestId": [Function],
- "getAllByText": [Function],
- "getAllByTitle": [Function],
- "getByAltText": [Function],
- "getByDisplayValue": [Function],
- "getByLabelText": [Function],
- "getByPlaceholderText": [Function],
- "getByRole": [Function],
- "getByTestId": [Function],
- "getByText": [Function],
- "getByTitle": [Function],
- "queryAllByAltText": [Function],
- "queryAllByDisplayValue": [Function],
- "queryAllByLabelText": [Function],
- "queryAllByPlaceholderText": [Function],
- "queryAllByRole": [Function],
- "queryAllByTestId": [Function],
- "queryAllByText": [Function],
- "queryAllByTitle": [Function],
- "queryByAltText": [Function],
- "queryByDisplayValue": [Function],
- "queryByLabelText": [Function],
- "queryByPlaceholderText": [Function],
- "queryByRole": [Function],
- "queryByTestId": [Function],
- "queryByText": [Function],
- "queryByTitle": [Function],
- "rerender": [Function],
- "unmount": [Function],
-}
-`;
+exports[`Label label with additional class name and props 1`] = `"Something "`;
-exports[`label 3`] = `
-Object {
- "asFragment": [Function],
- "baseElement":
-
-
-
- Something
-
-
-
-
-
-
- Something
-
-
-
-
-
-
- Something
-
-
-
- ,
- "container":
-
-
- Something
-
-
-
,
- "debug": [Function],
- "findAllByAltText": [Function],
- "findAllByDisplayValue": [Function],
- "findAllByLabelText": [Function],
- "findAllByPlaceholderText": [Function],
- "findAllByRole": [Function],
- "findAllByTestId": [Function],
- "findAllByText": [Function],
- "findAllByTitle": [Function],
- "findByAltText": [Function],
- "findByDisplayValue": [Function],
- "findByLabelText": [Function],
- "findByPlaceholderText": [Function],
- "findByRole": [Function],
- "findByTestId": [Function],
- "findByText": [Function],
- "findByTitle": [Function],
- "getAllByAltText": [Function],
- "getAllByDisplayValue": [Function],
- "getAllByLabelText": [Function],
- "getAllByPlaceholderText": [Function],
- "getAllByRole": [Function],
- "getAllByTestId": [Function],
- "getAllByText": [Function],
- "getAllByTitle": [Function],
- "getByAltText": [Function],
- "getByDisplayValue": [Function],
- "getByLabelText": [Function],
- "getByPlaceholderText": [Function],
- "getByRole": [Function],
- "getByTestId": [Function],
- "getByText": [Function],
- "getByTitle": [Function],
- "queryAllByAltText": [Function],
- "queryAllByDisplayValue": [Function],
- "queryAllByLabelText": [Function],
- "queryAllByPlaceholderText": [Function],
- "queryAllByRole": [Function],
- "queryAllByTestId": [Function],
- "queryAllByText": [Function],
- "queryAllByTitle": [Function],
- "queryByAltText": [Function],
- "queryByDisplayValue": [Function],
- "queryByLabelText": [Function],
- "queryByPlaceholderText": [Function],
- "queryByRole": [Function],
- "queryByTestId": [Function],
- "queryByText": [Function],
- "queryByTitle": [Function],
- "rerender": [Function],
- "unmount": [Function],
-}
-`;
+exports[`Label label with blue color 1`] = `"Something "`;
-exports[`label with additional class name 1`] = `
-
-
-
- Something
-
-
-
-`;
+exports[`Label label with blue color with outline variant 1`] = `"Something "`;
-exports[`label with additional class name and props 1`] = `
-
-
-
- Something
-
-
-
-`;
+exports[`Label label with close button 1`] = `"Something "`;
-exports[`label with blue color 1`] = `
-
-
-
- Something
-
-
-
-`;
+exports[`Label label with close button and outline variant 1`] = `"Something "`;
-exports[`label with blue color 2`] = `
-
-
-
- Something
-
-
-
-`;
+exports[`Label label with cyan color 1`] = `"Something "`;
-exports[`label with close button 1`] = `
-
-
-
- Something
-
-
-
-
-
-
-
-
-`;
+exports[`Label label with cyan color with outline variant 1`] = `"Something "`;
-exports[`label with close button 2`] = `
-Object {
- "asFragment": [Function],
- "baseElement":
-
-
-
- Something
-
-
-
-
-
-
-
-
-
-
-
- Something
-
-
-
-
-
-
-
-
- ,
- "container":
-
-
- Something
-
-
-
-
-
-
-
-
,
- "debug": [Function],
- "findAllByAltText": [Function],
- "findAllByDisplayValue": [Function],
- "findAllByLabelText": [Function],
- "findAllByPlaceholderText": [Function],
- "findAllByRole": [Function],
- "findAllByTestId": [Function],
- "findAllByText": [Function],
- "findAllByTitle": [Function],
- "findByAltText": [Function],
- "findByDisplayValue": [Function],
- "findByLabelText": [Function],
- "findByPlaceholderText": [Function],
- "findByRole": [Function],
- "findByTestId": [Function],
- "findByText": [Function],
- "findByTitle": [Function],
- "getAllByAltText": [Function],
- "getAllByDisplayValue": [Function],
- "getAllByLabelText": [Function],
- "getAllByPlaceholderText": [Function],
- "getAllByRole": [Function],
- "getAllByTestId": [Function],
- "getAllByText": [Function],
- "getAllByTitle": [Function],
- "getByAltText": [Function],
- "getByDisplayValue": [Function],
- "getByLabelText": [Function],
- "getByPlaceholderText": [Function],
- "getByRole": [Function],
- "getByTestId": [Function],
- "getByText": [Function],
- "getByTitle": [Function],
- "queryAllByAltText": [Function],
- "queryAllByDisplayValue": [Function],
- "queryAllByLabelText": [Function],
- "queryAllByPlaceholderText": [Function],
- "queryAllByRole": [Function],
- "queryAllByTestId": [Function],
- "queryAllByText": [Function],
- "queryAllByTitle": [Function],
- "queryByAltText": [Function],
- "queryByDisplayValue": [Function],
- "queryByLabelText": [Function],
- "queryByPlaceholderText": [Function],
- "queryByRole": [Function],
- "queryByTestId": [Function],
- "queryByText": [Function],
- "queryByTitle": [Function],
- "rerender": [Function],
- "unmount": [Function],
-}
-`;
+exports[`Label label with green color 1`] = `"Something "`;
-exports[`label with cyan color 1`] = `
-
-
-
- Something
-
-
-
-`;
+exports[`Label label with green color with outline variant 1`] = `"Something "`;
-exports[`label with cyan color 2`] = `
-
-
-
- Something
-
-
-
-`;
+exports[`Label label with grey color 1`] = `"Something "`;
-exports[`label with green color 1`] = `
-
-
-
- Something
-
-
-
-`;
+exports[`Label label with grey color with outline variant 1`] = `"Something "`;
-exports[`label with green color 2`] = `
-
-
-
- Something
-
-
-
-`;
+exports[`Label label with href 1`] = `"Something "`;
-exports[`label with grey color 1`] = `
-
-
-
- Something
-
-
-
-`;
+exports[`Label label with href with outline variant 1`] = `"Something "`;
-exports[`label with grey color 2`] = `
-
-
-
- Something
-
-
-
-`;
+exports[`Label label with orange color 1`] = `"Something "`;
-exports[`label with href 1`] = `
-
-`;
+exports[`Label label with orange color with outline variant 1`] = `"Something "`;
-exports[`label with href 2`] = `
-Object {
- "asFragment": [Function],
- "baseElement":
-
-
- ,
- "container": ,
- "debug": [Function],
- "findAllByAltText": [Function],
- "findAllByDisplayValue": [Function],
- "findAllByLabelText": [Function],
- "findAllByPlaceholderText": [Function],
- "findAllByRole": [Function],
- "findAllByTestId": [Function],
- "findAllByText": [Function],
- "findAllByTitle": [Function],
- "findByAltText": [Function],
- "findByDisplayValue": [Function],
- "findByLabelText": [Function],
- "findByPlaceholderText": [Function],
- "findByRole": [Function],
- "findByTestId": [Function],
- "findByText": [Function],
- "findByTitle": [Function],
- "getAllByAltText": [Function],
- "getAllByDisplayValue": [Function],
- "getAllByLabelText": [Function],
- "getAllByPlaceholderText": [Function],
- "getAllByRole": [Function],
- "getAllByTestId": [Function],
- "getAllByText": [Function],
- "getAllByTitle": [Function],
- "getByAltText": [Function],
- "getByDisplayValue": [Function],
- "getByLabelText": [Function],
- "getByPlaceholderText": [Function],
- "getByRole": [Function],
- "getByTestId": [Function],
- "getByText": [Function],
- "getByTitle": [Function],
- "queryAllByAltText": [Function],
- "queryAllByDisplayValue": [Function],
- "queryAllByLabelText": [Function],
- "queryAllByPlaceholderText": [Function],
- "queryAllByRole": [Function],
- "queryAllByTestId": [Function],
- "queryAllByText": [Function],
- "queryAllByTitle": [Function],
- "queryByAltText": [Function],
- "queryByDisplayValue": [Function],
- "queryByLabelText": [Function],
- "queryByPlaceholderText": [Function],
- "queryByRole": [Function],
- "queryByTestId": [Function],
- "queryByText": [Function],
- "queryByTitle": [Function],
- "rerender": [Function],
- "unmount": [Function],
-}
-`;
+exports[`Label label with purple color 1`] = `"Something "`;
-exports[`label with orange color 1`] = `
-
-
-
- Something
-
-
-
-`;
+exports[`Label label with purple color with outline variant 1`] = `"Something "`;
-exports[`label with orange color 2`] = `
-
-
-
- Something
-
-
-
-`;
+exports[`Label label with red color 1`] = `"Something "`;
-exports[`label with purple color 1`] = `
-
-
-
- Something
-
-
-
-`;
+exports[`Label label with red color with outline variant 1`] = `"Something "`;
-exports[`label with purple color 2`] = `
-
-
-
- Something
-
-
-
-`;
+exports[`Label label with truncation 1`] = `"Something very very very very very long that should be truncated "`;
-exports[`label with red color 1`] = `
-
-
-
- Something
-
-
-
-`;
+exports[`Label renders 1`] = `"Something "`;
-exports[`label with red color 2`] = `
-
-
-
- Something
-
-
-
-`;
+exports[`Label renders with isCompact 1`] = `"Something "`;
-exports[`label with truncation 1`] = `
-
-
-
-
- Something very very very very very long that should be truncated
-
-
-
-
-`;
+exports[`Label renders with outline variant 1`] = `"Something "`;
diff --git a/packages/react-core/src/components/LabelGroup/__tests__/LabelGroup.test.tsx b/packages/react-core/src/components/LabelGroup/__tests__/LabelGroup.test.tsx
index 2c21ca8a777..f56cc15c2c7 100644
--- a/packages/react-core/src/components/LabelGroup/__tests__/LabelGroup.test.tsx
+++ b/packages/react-core/src/components/LabelGroup/__tests__/LabelGroup.test.tsx
@@ -1,40 +1,41 @@
import React from 'react';
-import { render } from '@testing-library/react';
-import { shallow, mount } from 'enzyme';
+
+import { render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+
import { Label } from '../../Label';
import { LabelGroup } from '../index';
describe('LabelGroup', () => {
test('label group default', () => {
- const view = render(
+ const { asFragment } = render(
1.1
);
-
- expect(view.container).toMatchSnapshot();
+ expect(asFragment()).toMatchSnapshot();
});
test('label group with category', () => {
- const view = render(
+ const { asFragment } = render(
1.1
);
- expect(view.container).toMatchSnapshot();
+ expect(asFragment()).toMatchSnapshot();
});
test('label group with closable category', () => {
- const view = render(
+ const { asFragment } = render(
1.1
);
- expect(view.container).toMatchSnapshot();
+ expect(asFragment()).toMatchSnapshot();
});
test('label group expanded', () => {
- const view = mount(
+ render(
1
2
@@ -42,28 +43,31 @@ describe('LabelGroup', () => {
4
);
- const overflowButton = view.find('.pf-m-overflow .pf-c-label__content');
- expect(overflowButton.text()).toBe('1 more');
- overflowButton.simulate('click');
- expect(overflowButton.text()).toBe('Show Less');
+ const showMoreButton = screen.getByRole('button');
+
+ expect(showMoreButton.textContent).toBe('1 more');
+
+ userEvent.click(showMoreButton);
+ expect(showMoreButton.textContent).toBe('Show Less');
});
test('label group will not render if no children passed', () => {
- const view = shallow( );
- expect(view.html()).toBeNull();
+ render( );
+ expect(screen.queryByTestId('label-group-test-id')).toBeNull();
});
+ // TODO, fix test - no tooltip shows up with this categoryName.zzw
test('label group with category and tooltip', () => {
- const view = render(
+ const { asFragment } = render(
1.1
);
- expect(view.container).toMatchSnapshot();
+ expect(asFragment()).toMatchSnapshot();
});
test('label group compact', () => {
- const view = render(
+ const { asFragment } = render(
1
2
@@ -71,6 +75,6 @@ describe('LabelGroup', () => {
4
);
- expect(view.container).toMatchSnapshot();
+ expect(asFragment()).toMatchSnapshot();
});
});
diff --git a/packages/react-core/src/components/LabelGroup/__tests__/__snapshots__/LabelGroup.test.tsx.snap b/packages/react-core/src/components/LabelGroup/__tests__/__snapshots__/LabelGroup.test.tsx.snap
index 1e91b8aad43..429740d5209 100644
--- a/packages/react-core/src/components/LabelGroup/__tests__/__snapshots__/LabelGroup.test.tsx.snap
+++ b/packages/react-core/src/components/LabelGroup/__tests__/__snapshots__/LabelGroup.test.tsx.snap
@@ -1,14 +1,13 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`LabelGroup label group compact 1`] = `
-
+
`;
exports[`LabelGroup label group default 1`] = `
-
+
`;
exports[`LabelGroup label group with category 1`] = `
-
+
@@ -141,11 +139,11 @@ exports[`LabelGroup label group with category 1`] = `
-
+
`;
exports[`LabelGroup label group with category and tooltip 1`] = `
-
+
@@ -180,11 +178,11 @@ exports[`LabelGroup label group with category and tooltip 1`] = `
-
+
`;
exports[`LabelGroup label group with closable category 1`] = `
-
+
@@ -248,5 +246,5 @@ exports[`LabelGroup label group with closable category 1`] = `
-
+
`;
diff --git a/packages/react-core/src/components/LoginPage/LoginFooterItem.tsx b/packages/react-core/src/components/LoginPage/LoginFooterItem.tsx
index dce59d61046..236d32f2953 100644
--- a/packages/react-core/src/components/LoginPage/LoginFooterItem.tsx
+++ b/packages/react-core/src/components/LoginPage/LoginFooterItem.tsx
@@ -12,8 +12,6 @@ export interface LoginFooterItemProps extends React.HTMLProps
}
export const LoginFooterItem: React.FunctionComponent = ({
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- className = '',
children = null,
href = '#',
target = '_blank',
diff --git a/packages/react-core/src/components/LoginPage/__tests__/LoginFooterItem.test.tsx b/packages/react-core/src/components/LoginPage/__tests__/LoginFooterItem.test.tsx
index dfe7f972cbc..3f5e97080bb 100644
--- a/packages/react-core/src/components/LoginPage/__tests__/LoginFooterItem.test.tsx
+++ b/packages/react-core/src/components/LoginPage/__tests__/LoginFooterItem.test.tsx
@@ -1,31 +1,30 @@
-import * as React from 'react';
-import { render } from '@testing-library/react';
-import { shallow } from 'enzyme';
+import React from 'react';
+
+import { render, screen } from '@testing-library/react';
+import "@testing-library/jest-dom";
import { LoginFooterItem } from '../LoginFooterItem';
-test('renders with PatternFly Core styles', () => {
- const view = render( );
- expect(view.container).toMatchSnapshot();
-});
+describe('LoginFooterItem', () => {
+ test('renders with PatternFly Core styles', () => {
+ const { asFragment } = render( );
+ expect(asFragment()).toMatchSnapshot();
+ });
-test('className is added to the root element', () => {
- const view = shallow( );
- expect(view.prop('className')).toMatchSnapshot();
-});
+ test('className is added to the root element', () => {
+ render( );
+ expect(screen.getByRole('link')).toHaveClass('extra-class');
+ });
-test('extra props are spread to the root element', () => {
- const testId = 'login-body';
- const view = shallow( );
- expect(view.prop('data-testid')).toBe(testId);
-});
+ test('with custom node', () => {
+ const CustomNode = () => My custom node
;
+
+ render(
+
+
+
+ );
-test('LoginFooterItem with custom node', () => {
- const CustomNode = () => My custom node
;
- const view = render(
-
-
-
- );
- expect(view.container).toMatchSnapshot();
+ expect(screen.getByText('My custom node')).toBeInTheDocument();
+ });
});
diff --git a/packages/react-core/src/components/LoginPage/__tests__/LoginForm.test.tsx b/packages/react-core/src/components/LoginPage/__tests__/LoginForm.test.tsx
index f9f8402aa79..fd16a2bb2fb 100644
--- a/packages/react-core/src/components/LoginPage/__tests__/LoginForm.test.tsx
+++ b/packages/react-core/src/components/LoginPage/__tests__/LoginForm.test.tsx
@@ -1,41 +1,48 @@
-import * as React from 'react';
-import { render } from '@testing-library/react';
-import { shallow } from 'enzyme';
-
+import React from 'react';
+import { render, screen } from '@testing-library/react';
import { LoginForm } from '../LoginForm';
+import userEvent from '@testing-library/user-event';
-test('should render Login form', () => {
- const view = render( );
- expect(view.container).toMatchSnapshot();
-});
+describe('LoginForm', () => {
+ test('should render Login form', () => {
+ render( );
+ expect(screen.getByTestId('form-test-id').outerHTML).toMatchSnapshot();
+ });
-test('should call onChangeUsername callback', () => {
- const mockFn = jest.fn();
- const view = shallow( );
- view.find('#pf-login-username-id').simulate('change');
- expect(mockFn).toHaveBeenCalled();
-});
+ test('should call onChangeUsername callback', () => {
+ const mockFn = jest.fn();
-test('should call onChangePassword callback', () => {
- const mockFn = jest.fn();
- const view = shallow( );
- view.find('#pf-login-password-id').simulate('change');
- expect(mockFn).toHaveBeenCalled();
-});
+ render( );
-test('should call onChangeRememberMe callback', () => {
- const mockFn = jest.fn();
- const view = shallow( );
- view.find('#pf-login-remember-me-id').simulate('change');
- expect(mockFn).toHaveBeenCalled();
-});
+ userEvent.type(screen.getByText('Username'), 'updatedUserName');
+ expect(mockFn).toHaveBeenCalled();
+ });
-test('LoginForm with rememberMeLabel', () => {
- const view = render( );
- expect(view.container).toMatchSnapshot();
-});
+ test('should call onChangePassword callback', () => {
+ const mockFn = jest.fn();
+
+ render( );
+
+ userEvent.type(screen.getByText('Password'), 'updatedPassword');
+ expect(mockFn).toHaveBeenCalled();
+ });
+
+ test('should call onChangeRememberMe callback', () => {
+ const mockFn = jest.fn();
+
+ render( );
+
+ userEvent.click(screen.getByLabelText('Remember me'));
+ expect(mockFn).toHaveBeenCalled();
+ });
+
+ test('LoginForm with rememberMeLabel', () => {
+ render( );
+ expect(screen.getByTestId('form-test-id').outerHTML).toMatchSnapshot();
+ });
-test('LoginForm with show password', () => {
- const view = render( );
- expect(view.container).toMatchSnapshot();
+ test('LoginForm with show password', () => {
+ render( );
+ expect(screen.getByTestId('form-test-id').outerHTML).toMatchSnapshot();
+ });
});
diff --git a/packages/react-core/src/components/LoginPage/__tests__/LoginMainBody.test.tsx b/packages/react-core/src/components/LoginPage/__tests__/LoginMainBody.test.tsx
index a54ff076b63..eef9ed826f8 100644
--- a/packages/react-core/src/components/LoginPage/__tests__/LoginMainBody.test.tsx
+++ b/packages/react-core/src/components/LoginPage/__tests__/LoginMainBody.test.tsx
@@ -1,21 +1,15 @@
import * as React from 'react';
-import { render } from '@testing-library/react';
-import { shallow } from 'enzyme';
-
+import { render, screen } from '@testing-library/react';
import { LoginMainBody } from '../LoginMainBody';
-test('renders with PatternFly Core styles', () => {
- const view = render( );
- expect(view.container).toMatchSnapshot();
-});
-
-test('className is added to the root element', () => {
- const view = shallow( );
- expect(view.prop('className')).toMatchSnapshot();
-});
+describe('LoginMainBody', () => {
+ test('renders with PatternFly Core styles', () => {
+ render( );
+ expect(screen.getByTestId('test-id').outerHTML).toMatchSnapshot();
+ });
-test('extra props are spread to the root element', () => {
- const testId = 'login-body';
- const view = shallow( );
- expect(view.prop('data-testid')).toBe(testId);
+ test('className is added to the root element', () => {
+ render( );
+ expect(screen.getByTestId('test-id').outerHTML).toMatchSnapshot();
+ });
});
diff --git a/packages/react-core/src/components/LoginPage/__tests__/LoginMainFooter.test.tsx b/packages/react-core/src/components/LoginPage/__tests__/LoginMainFooter.test.tsx
index 2c391514ac1..37c3e9bc7af 100644
--- a/packages/react-core/src/components/LoginPage/__tests__/LoginMainFooter.test.tsx
+++ b/packages/react-core/src/components/LoginPage/__tests__/LoginMainFooter.test.tsx
@@ -1,21 +1,15 @@
-import * as React from 'react';
-import { render } from '@testing-library/react';
-import { shallow } from 'enzyme';
-
+import React from 'react';
+import { render, screen } from '@testing-library/react';
import { LoginMainFooter } from '../LoginMainFooter';
-test('renders with PatternFly Core styles', () => {
- const view = render( );
- expect(view.container).toMatchSnapshot();
-});
-
-test('className is added to the root element', () => {
- const view = shallow( );
- expect(view.prop('className')).toMatchSnapshot();
-});
+describe('LoginMainFooter', () => {
+ test('renders with PatternFly Core styles', () => {
+ render( );
+ expect(screen.getByTestId('test-id').outerHTML).toMatchSnapshot();
+ });
-test('extra props are spread to the root element', () => {
- const testId = 'login-body';
- const view = shallow( );
- expect(view.prop('data-testid')).toBe(testId);
+ test('className is added to the root element', () => {
+ render( );
+ expect(screen.getByTestId('test-id').outerHTML).toMatchSnapshot();
+ });
});
diff --git a/packages/react-core/src/components/LoginPage/__tests__/LoginMainFooterBandItem.test.tsx b/packages/react-core/src/components/LoginPage/__tests__/LoginMainFooterBandItem.test.tsx
index d447bb4f6f8..c433fd9f733 100644
--- a/packages/react-core/src/components/LoginPage/__tests__/LoginMainFooterBandItem.test.tsx
+++ b/packages/react-core/src/components/LoginPage/__tests__/LoginMainFooterBandItem.test.tsx
@@ -1,31 +1,30 @@
-import * as React from 'react';
-import { render } from '@testing-library/react';
-import { shallow } from 'enzyme';
+import React from 'react';
+
+import { render, screen } from '@testing-library/react';
+import "@testing-library/jest-dom";
import { LoginMainFooterBandItem } from '../LoginMainFooterBandItem';
-test('renders with PatternFly Core styles', () => {
- const view = render( );
- expect(view.container).toMatchSnapshot();
-});
+describe('LoginMainFooterBandItem', () => {
+ test('renders with PatternFly Core styles', () => {
+ const { asFragment } = render( );
+ expect(asFragment()).toMatchSnapshot();
+ });
-test('className is added to the root element', () => {
- const view = shallow( );
- expect(view.prop('className')).toMatchSnapshot();
-});
+ test('className is added to the root element', () => {
+ render(test );
+ expect(screen.getByText('test')).toHaveClass('extra-class');
+ });
-test('extra props are spread to the root element', () => {
- const testId = 'login-body';
- const view = shallow( );
- expect(view.prop('data-testid')).toBe(testId);
-});
+ test('with custom node', () => {
+ const CustomNode = () => My custom node
;
+
+ render(
+
+
+
+ );
-test('LoginFooterItem with custom node', () => {
- const CustomNode = () => My custom node
;
- const view = render(
-
-
-
- );
- expect(view.container).toMatchSnapshot();
+ expect(screen.getByText('My custom node')).toBeInTheDocument();
+ });
});
diff --git a/packages/react-core/src/components/LoginPage/__tests__/LoginMainFooterLinksItem.test.tsx b/packages/react-core/src/components/LoginPage/__tests__/LoginMainFooterLinksItem.test.tsx
index 2b31f95f25b..761da7a7f93 100644
--- a/packages/react-core/src/components/LoginPage/__tests__/LoginMainFooterLinksItem.test.tsx
+++ b/packages/react-core/src/components/LoginPage/__tests__/LoginMainFooterLinksItem.test.tsx
@@ -1,31 +1,27 @@
import * as React from 'react';
-import { render } from '@testing-library/react';
-import { shallow } from 'enzyme';
-
+import { render, screen } from '@testing-library/react';
import { LoginMainFooterLinksItem } from '../LoginMainFooterLinksItem';
-test('renders with PatternFly Core styles', () => {
- const view = render( );
- expect(view.container).toMatchSnapshot();
-});
+describe('LoginMainFooterLinksItem', () => {
+ test('renders with PatternFly Core styles', () => {
+ render( );
+ expect(screen.getByRole('listitem').outerHTML).toMatchSnapshot();
+ });
-test('className is added to the root element', () => {
- const view = shallow( );
- expect(view.prop('className')).toMatchSnapshot();
-});
+ test('className is added to the root element', () => {
+ render( );
+ expect(screen.getByRole('listitem').outerHTML).toMatchSnapshot();
+ });
-test('extra props are spread to the root element', () => {
- const testId = 'login-body';
- const view = shallow( );
- expect(view.prop('data-testid')).toBe(testId);
-});
+ test('with custom node', () => {
+ const CustomNode = () => My custom node
;
+
+ render(
+
+
+
+ );
-test('LoginFooterItem with custom node', () => {
- const CustomNode = () => My custom node
;
- const view = render(
-
-
-
- );
- expect(view.container).toMatchSnapshot();
+ expect(screen.getByRole('listitem').outerHTML).toMatchSnapshot();
+ });
});
diff --git a/packages/react-core/src/components/LoginPage/__tests__/LoginMainHeader.test.tsx b/packages/react-core/src/components/LoginPage/__tests__/LoginMainHeader.test.tsx
index eb3b70bde56..3be240cad84 100644
--- a/packages/react-core/src/components/LoginPage/__tests__/LoginMainHeader.test.tsx
+++ b/packages/react-core/src/components/LoginPage/__tests__/LoginMainHeader.test.tsx
@@ -1,26 +1,20 @@
import * as React from 'react';
-import { render } from '@testing-library/react';
-import { shallow } from 'enzyme';
-
+import { render, screen } from '@testing-library/react';
import { LoginMainHeader } from '../LoginMainHeader';
-test('renders with PatternFly Core styles', () => {
- const view = render( );
- expect(view.container).toMatchSnapshot();
-});
+describe('LoginMainHeader', () => {
+ test('renders with PatternFly Core styles', () => {
+ render( );
+ expect(screen.getByTestId('test-id').outerHTML).toMatchSnapshot();
+ });
-test('className is added to the root element', () => {
- const view = shallow( );
- expect(view.prop('className')).toMatchSnapshot();
-});
-
-test('extra props are spread to the root element', () => {
- const testId = 'login-header';
- const view = shallow( );
- expect(view.prop('data-testid')).toBe(testId);
-});
+ test('className is added to the root element', () => {
+ render( );
+ expect(screen.getByTestId('test-id').outerHTML).toMatchSnapshot();
+ });
-test('title and subtitle are rendered correctly', () => {
- const view = shallow( );
- expect(view.prop('className')).toMatchSnapshot();
+ test('title and subtitle are rendered correctly', () => {
+ render( );
+ expect(screen.getByTestId('test-id').outerHTML).toMatchSnapshot();
+ });
});
diff --git a/packages/react-core/src/components/LoginPage/__tests__/__snapshots__/LoginFooterItem.test.tsx.snap b/packages/react-core/src/components/LoginPage/__tests__/__snapshots__/LoginFooterItem.test.tsx.snap
index cc4745abf2a..54d2814d5db 100644
--- a/packages/react-core/src/components/LoginPage/__tests__/__snapshots__/LoginFooterItem.test.tsx.snap
+++ b/packages/react-core/src/components/LoginPage/__tests__/__snapshots__/LoginFooterItem.test.tsx.snap
@@ -1,20 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`LoginFooterItem with custom node 1`] = `
-
-`;
-
-exports[`className is added to the root element 1`] = `undefined`;
-
-exports[`renders with PatternFly Core styles 1`] = `
-
+exports[`LoginFooterItem renders with PatternFly Core styles 1`] = `
+
-
+
`;
diff --git a/packages/react-core/src/components/LoginPage/__tests__/__snapshots__/LoginForm.test.tsx.snap b/packages/react-core/src/components/LoginPage/__tests__/__snapshots__/LoginForm.test.tsx.snap
index 6f9fda4ab09..48b25a592da 100644
--- a/packages/react-core/src/components/LoginPage/__tests__/__snapshots__/LoginForm.test.tsx.snap
+++ b/packages/react-core/src/components/LoginPage/__tests__/__snapshots__/LoginForm.test.tsx.snap
@@ -1,419 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`LoginForm with rememberMeLabel 1`] = `
-
-`;
+exports[`LoginForm LoginForm with rememberMeLabel 1`] = `""`;
-exports[`LoginForm with show password 1`] = `
-
-`;
+exports[`LoginForm LoginForm with show password 1`] = `""`;
-exports[`should render Login form 1`] = `
-
-`;
+exports[`LoginForm should render Login form 1`] = `""`;
diff --git a/packages/react-core/src/components/LoginPage/__tests__/__snapshots__/LoginMainBody.test.tsx.snap b/packages/react-core/src/components/LoginPage/__tests__/__snapshots__/LoginMainBody.test.tsx.snap
index 43e95fd3153..3eaa9966c6b 100644
--- a/packages/react-core/src/components/LoginPage/__tests__/__snapshots__/LoginMainBody.test.tsx.snap
+++ b/packages/react-core/src/components/LoginPage/__tests__/__snapshots__/LoginMainBody.test.tsx.snap
@@ -1,11 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`className is added to the root element 1`] = `"pf-c-login__main-body extra-class"`;
+exports[`LoginMainBody className is added to the root element 1`] = `"
"`;
-exports[`renders with PatternFly Core styles 1`] = `
-
-`;
+exports[`LoginMainBody renders with PatternFly Core styles 1`] = `"
"`;
diff --git a/packages/react-core/src/components/LoginPage/__tests__/__snapshots__/LoginMainFooter.test.tsx.snap b/packages/react-core/src/components/LoginPage/__tests__/__snapshots__/LoginMainFooter.test.tsx.snap
index 691fa946927..239a9fcb245 100644
--- a/packages/react-core/src/components/LoginPage/__tests__/__snapshots__/LoginMainFooter.test.tsx.snap
+++ b/packages/react-core/src/components/LoginPage/__tests__/__snapshots__/LoginMainFooter.test.tsx.snap
@@ -1,11 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`className is added to the root element 1`] = `"pf-c-login__main-footer extra-class"`;
+exports[`LoginMainFooter className is added to the root element 1`] = `"
"`;
-exports[`renders with PatternFly Core styles 1`] = `
-
-`;
+exports[`LoginMainFooter renders with PatternFly Core styles 1`] = `"
"`;
diff --git a/packages/react-core/src/components/LoginPage/__tests__/__snapshots__/LoginMainFooterBandItem.test.tsx.snap b/packages/react-core/src/components/LoginPage/__tests__/__snapshots__/LoginMainFooterBandItem.test.tsx.snap
index 5caa06a9007..27796c14ec0 100644
--- a/packages/react-core/src/components/LoginPage/__tests__/__snapshots__/LoginMainFooterBandItem.test.tsx.snap
+++ b/packages/react-core/src/components/LoginPage/__tests__/__snapshots__/LoginMainFooterBandItem.test.tsx.snap
@@ -1,23 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`LoginFooterItem with custom node 1`] = `
-
-
-
- My custom node
-
-
-
-`;
-
-exports[`className is added to the root element 1`] = `"pf-c-login__main-footer-band-item extra-class"`;
-
-exports[`renders with PatternFly Core styles 1`] = `
-
+exports[`LoginMainFooterBandItem renders with PatternFly Core styles 1`] = `
+
-
+
`;
diff --git a/packages/react-core/src/components/LoginPage/__tests__/__snapshots__/LoginMainFooterLinksItem.test.tsx.snap b/packages/react-core/src/components/LoginPage/__tests__/__snapshots__/LoginMainFooterLinksItem.test.tsx.snap
index 01c4c3c1f43..f9a4b26f2d3 100644
--- a/packages/react-core/src/components/LoginPage/__tests__/__snapshots__/LoginMainFooterLinksItem.test.tsx.snap
+++ b/packages/react-core/src/components/LoginPage/__tests__/__snapshots__/LoginMainFooterLinksItem.test.tsx.snap
@@ -1,35 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`LoginFooterItem with custom node 1`] = `
-
-`;
+exports[`LoginMainFooterLinksItem className is added to the root element 1`] = `" "`;
-exports[`className is added to the root element 1`] = `"pf-c-login__main-footer-links-item extra-class"`;
+exports[`LoginMainFooterLinksItem renders with PatternFly Core styles 1`] = `" "`;
-exports[`renders with PatternFly Core styles 1`] = `
-
-`;
+exports[`LoginMainFooterLinksItem with custom node 1`] = `"My custom node
"`;
diff --git a/packages/react-core/src/components/LoginPage/__tests__/__snapshots__/LoginMainHeader.test.tsx.snap b/packages/react-core/src/components/LoginPage/__tests__/__snapshots__/LoginMainHeader.test.tsx.snap
index 85ad972c289..f5b57281a0a 100644
--- a/packages/react-core/src/components/LoginPage/__tests__/__snapshots__/LoginMainHeader.test.tsx.snap
+++ b/packages/react-core/src/components/LoginPage/__tests__/__snapshots__/LoginMainHeader.test.tsx.snap
@@ -1,16 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`className is added to the root element 1`] = `"pf-c-login__main-header extra-class"`;
+exports[`LoginMainHeader className is added to the root element 1`] = `""`;
-exports[`renders with PatternFly Core styles 1`] = `
-
-
-
-`;
+exports[`LoginMainHeader renders with PatternFly Core styles 1`] = `""`;
-exports[`title and subtitle are rendered correctly 1`] = `"pf-c-login__main-header"`;
+exports[`LoginMainHeader title and subtitle are rendered correctly 1`] = `"Log in to your account Use LDAP credentials
"`;