+exports[`Pagination component render custom start end 1`] = `
+
+
`;
-exports[`component render empty per page options 1`] = `
-
+exports[`Pagination component render empty per page options 1`] = `
+
-
-`;
-
-exports[`component render indeterminate count (no item count) 1`] = `
-
-
-
- 1
- -
- 10
-
-
- of
-
-
- 0
-
-
-
-
+
`;
-exports[`component render last page 1`] = `
-
+exports[`Pagination component render last page 1`] = `
+
-
+
`;
-exports[`component render limited number of pages 1`] = `
-
+exports[`Pagination component render limited number of pages 1`] = `
+
-
+
`;
-exports[`component render no items 1`] = `
-
-
-
-`;
-
-exports[`component render should render correctly bottom 1`] = `
-
+exports[`Pagination component render should render correctly bottom 1`] = `
+
-
+
`;
-exports[`component render should render correctly bottom sticky 1`] = `
-
+exports[`Pagination component render should render correctly bottom sticky 1`] = `
+
-
+
`;
-exports[`component render should render correctly compact 1`] = `
-
+exports[`Pagination component render should render correctly compact 1`] = `
+
-
+
`;
-exports[`component render should render correctly disabled 1`] = `
-
+exports[`Pagination component render should render correctly disabled 1`] = `
+
-
+
`;
-exports[`component render should render correctly sticky 1`] = `
-
+exports[`Pagination component render should render correctly sticky 1`] = `
+
-
+
`;
-exports[`component render should render correctly top 1`] = `
-
+exports[`Pagination component render should render correctly top 1`] = `
+
-
+
`;
-exports[`component render titles 1`] = `
-
+exports[`Pagination component render titles 1`] = `
+
-`;
-
-exports[`component render toggleTemplate toggle text with function 1`] = `
-
-
-
- 1
- -
- 10
- of many
-
-
-
-`;
-
-exports[`component render toggleTemplate toggle text with string 1`] = `
-
- I am a string
-
+
`;
-exports[`component render up drop direction 1`] = `
-
+exports[`Pagination component render up drop direction 1`] = `
+
+
`;
-exports[`component render zero results 1`] = `
-
+exports[`Pagination component render zero results 1`] = `
+
-
+
`;
diff --git a/packages/react-core/src/components/Radio/__tests__/Generated/Radio.test.tsx b/packages/react-core/src/components/Radio/__tests__/Generated/Radio.test.tsx
deleted file mode 100644
index ef8271b40f6..00000000000
--- a/packages/react-core/src/components/Radio/__tests__/Generated/Radio.test.tsx
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * This test was generated
- */
-import * as React from 'react';
-import { render } from '@testing-library/react';
-import { Radio } from '../../Radio';
-// any missing imports can usually be resolved by adding them here
-import {} from '../..';
-
-it('Radio should match snapshot (auto-generated)', () => {
- const view = render(
-
ReactNode }
- name={'string'}
- onChange={() => {}}
- aria-label={'string'}
- description={
ReactNode
}
- />
- );
- expect(view.container).toMatchSnapshot();
-});
diff --git a/packages/react-core/src/components/Radio/__tests__/Generated/__snapshots__/Radio.test.tsx.snap b/packages/react-core/src/components/Radio/__tests__/Generated/__snapshots__/Radio.test.tsx.snap
deleted file mode 100644
index 0d18ea20c20..00000000000
--- a/packages/react-core/src/components/Radio/__tests__/Generated/__snapshots__/Radio.test.tsx.snap
+++ /dev/null
@@ -1,36 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`Radio should match snapshot (auto-generated) 1`] = `
-
-
-
-
- ReactNode
-
-
-
-
-
- ReactNode
-
-
-
-
-`;
diff --git a/packages/react-core/src/components/Radio/__tests__/Radio.test.tsx b/packages/react-core/src/components/Radio/__tests__/Radio.test.tsx
index a703d758250..b2b04371821 100644
--- a/packages/react-core/src/components/Radio/__tests__/Radio.test.tsx
+++ b/packages/react-core/src/components/Radio/__tests__/Radio.test.tsx
@@ -1,96 +1,90 @@
-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 userEvent from '@testing-library/user-event';
+import '@testing-library/jest-dom';
+
import { Radio } from '../Radio';
const props = {
onChange: jest.fn()
};
-describe('Radio check component', () => {
+describe('Radio', () => {
test('controlled', () => {
- const view = render(
);
- expect(view.container).toMatchSnapshot();
+ const { asFragment } = render(
);
+ expect(asFragment()).toMatchSnapshot();
});
test('uncontrolled', () => {
- const view = render(
);
- expect(view.container).toMatchSnapshot();
+ const { asFragment } = render(
);
+ expect(asFragment()).toMatchSnapshot();
});
test('isDisabled', () => {
- const view = render(
);
- expect(view.container).toMatchSnapshot();
+ const { asFragment } = render(
);
+ expect(asFragment()).toMatchSnapshot();
});
test('isLabelBeforeButton', () => {
- const view = render(
);
- expect(view.container).toMatchSnapshot();
+ const { asFragment } = render(
);
+ expect(asFragment()).toMatchSnapshot();
});
test('isLabelWrapped', () => {
- const view = render(
);
- expect(view.container).toMatchSnapshot();
+ const { asFragment } = render(
);
+ expect(asFragment()).toMatchSnapshot();
});
test('label is string', () => {
- const view = render(
);
- expect(view.container).toMatchSnapshot();
+ const { asFragment } = render(
);
+ expect(asFragment()).toMatchSnapshot();
});
test('label is function', () => {
const functionLabel = () =>
Header ;
- const view = render(
);
- expect(view.container).toMatchSnapshot();
+ const { asFragment } = render(
);
+ expect(asFragment()).toMatchSnapshot();
});
test('label is node', () => {
- const view = render(
Header} id="check" isChecked aria-label="check" name="check" />);
- expect(view.container).toMatchSnapshot();
+ const { asFragment } = render(Header} id="check" isChecked aria-label="check" name="check" />);
+ expect(asFragment()).toMatchSnapshot();
});
test('passing class', () => {
- const view = render(
-
- );
- expect(view.container).toMatchSnapshot();
+ const { asFragment } = render( );
+ expect(asFragment()).toMatchSnapshot();
});
test('passing HTML attribute', () => {
- const view = render(
-
- );
- expect(view.container).toMatchSnapshot();
+ const { asFragment } = render( );
+ expect(asFragment()).toMatchSnapshot();
});
test('Radio passes value and event to onChange handler', () => {
- const newValue = true;
- const event = {
- currentTarget: { checked: newValue }
- };
- const view = shallow( );
- view.find('input').simulate('change', event);
- expect(props.onChange).toBeCalledWith(newValue, event);
+ render( );
+
+ userEvent.click(screen.getByRole('radio'));
+ expect(props.onChange).toHaveBeenCalledWith(true, expect.any(Object));
});
test('Radio description', () => {
- const view = shallow( );
- const descriptionEl = view.find('span[className="pf-c-radio__description"]');
- expect(descriptionEl.length).toBe(1);
- expect(descriptionEl.text()).toBe('Text description...');
+ render( );
+ expect(screen.getByText('Text description...')).toBeInTheDocument();
});
test('Radio body', () => {
- const view = shallow( );
- const bodyEl = view.find('span[className="pf-c-radio__body"]');
- expect(bodyEl.length).toBe(1);
- expect(bodyEl.text()).toBe('Text body...');
+ render( );
+ expect(screen.getByText('Text body...')).toBeInTheDocument();
});
test('should throw console error when no id is given', () => {
const myMock = jest.fn();
global.console = { ...global.console, error: myMock };
- shallow( );
+
+ render( );
+
expect(myMock).toBeCalled();
});
});
diff --git a/packages/react-core/src/components/Radio/__tests__/__snapshots__/Radio.test.tsx.snap b/packages/react-core/src/components/Radio/__tests__/__snapshots__/Radio.test.tsx.snap
index 08414720a01..4c97d87e65f 100644
--- a/packages/react-core/src/components/Radio/__tests__/__snapshots__/Radio.test.tsx.snap
+++ b/packages/react-core/src/components/Radio/__tests__/__snapshots__/Radio.test.tsx.snap
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`Radio check component controlled 1`] = `
-
+exports[`Radio controlled 1`] = `
+
@@ -18,11 +18,11 @@ exports[`Radio check component controlled 1`] = `
type="radio"
/>
-
+
`;
-exports[`Radio check component isDisabled 1`] = `
-
+exports[`Radio isDisabled 1`] = `
+
@@ -39,11 +39,11 @@ exports[`Radio check component isDisabled 1`] = `
type="radio"
/>
-
+
`;
-exports[`Radio check component isLabelBeforeButton 1`] = `
-
+exports[`Radio isLabelBeforeButton 1`] = `
+
@@ -64,11 +64,11 @@ exports[`Radio check component isLabelBeforeButton 1`] = `
type="radio"
/>
-
+
`;
-exports[`Radio check component isLabelWrapped 1`] = `
-
+exports[`Radio isLabelWrapped 1`] = `
+
-
+
`;
-exports[`Radio check component label is function 1`] = `
-
+exports[`Radio label is function 1`] = `
+
@@ -117,11 +117,11 @@ exports[`Radio check component label is function 1`] = `
-
+
`;
-exports[`Radio check component label is node 1`] = `
-
+exports[`Radio label is node 1`] = `
+
@@ -145,11 +145,11 @@ exports[`Radio check component label is node 1`] = `
-
+
`;
-exports[`Radio check component label is string 1`] = `
-
+exports[`Radio label is string 1`] = `
+
@@ -171,11 +171,11 @@ exports[`Radio check component label is string 1`] = `
Label
-
+
`;
-exports[`Radio check component passing HTML attribute 1`] = `
-
+exports[`Radio passing HTML attribute 1`] = `
+
@@ -198,11 +198,11 @@ exports[`Radio check component passing HTML attribute 1`] = `
label
-
+
`;
-exports[`Radio check component passing class 1`] = `
-
+exports[`Radio passing class 1`] = `
+
@@ -224,11 +224,11 @@ exports[`Radio check component passing class 1`] = `
label
-
+
`;
-exports[`Radio check component uncontrolled 1`] = `
-
+exports[`Radio uncontrolled 1`] = `
+
@@ -244,5 +244,5 @@ exports[`Radio check component uncontrolled 1`] = `
type="radio"
/>
-
+
`;
diff --git a/packages/react-core/src/components/SearchInput/__tests__/SearchInput.test.tsx b/packages/react-core/src/components/SearchInput/__tests__/SearchInput.test.tsx
index a3f436f2506..7fc87c75105 100644
--- a/packages/react-core/src/components/SearchInput/__tests__/SearchInput.test.tsx
+++ b/packages/react-core/src/components/SearchInput/__tests__/SearchInput.test.tsx
@@ -1,6 +1,9 @@
import React from 'react';
-import { render } from '@testing-library/react';
-import { mount } from 'enzyme';
+
+import { render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import '@testing-library/jest-dom';
+
import { SearchInput } from '../SearchInput';
import { FormGroup } from '../../Form';
import { Button } from '../../Button';
@@ -15,76 +18,92 @@ const props = {
onSearch: jest.fn()
};
-test('simple search input', () => {
- const view = render( );
- expect(view.container).toMatchSnapshot();
-});
+describe('SearchInput', () => {
+ test('simple search input', () => {
+ const { asFragment } = render( );
+ expect(asFragment()).toMatchSnapshot();
+ });
-test('search input with hint', () => {
- const view = render( );
- expect(view.container).toMatchSnapshot();
-});
+ test('search input with hint', () => {
+ const { asFragment } = render( );
+ expect(asFragment()).toMatchSnapshot();
+ });
-test('result count', () => {
- const view = mount( );
- expect(view.find('.pf-c-badge')).toMatchSnapshot();
-});
+ test('result count', () => {
+ render( );
+ expect(screen.getByTestId('test-id').querySelector('.pf-c-badge')).toBeInTheDocument();
+ });
-test('navigable search results', () => {
- const view = mount(
- );
- expect(view.find('.pf-c-search-input__nav')).toMatchSnapshot();
- expect(view.find('.pf-c-badge')).toMatchSnapshot();
-
- view.find('.pf-c-button').at(0).simulate('click', {});
- expect(props.onPreviousClick).toBeCalled();
- view.find('.pf-c-button').at(1).simulate('click', {});
- expect(props.onNextClick).toBeCalled();
- view.find('.pf-c-button').at(2).simulate('click', {});
- expect(props.onClear).toBeCalled();
-});
+ test('navigable search results', () => {
+ render( );
-test('hide clear button', () => {
- const { onClear, ...testProps } = props;
- const view = mount(
-
- );
- expect(view.find('.pf-c-search-input__clear').length).toBe(0);
-});
+ const input = screen.getByTestId('test-id');
+ expect(input.querySelector('.pf-c-search-input__nav')).toBeInTheDocument();
+ expect(input.querySelector('.pf-c-badge')).toBeInTheDocument();
-test('advanced search', () => {
- const view = mount(
-
- );
- view.find('.pf-c-button').at(2).simulate('click', {});
- expect(props.onSearch).toBeCalled();
- expect(view.find('input')).toMatchSnapshot();
-});
+ userEvent.click(screen.getByRole('button', { name: 'Previous' }));
+ expect(props.onPreviousClick).toBeCalled();
+
+ userEvent.click(screen.getByRole('button', { name: 'Next' }));
+ expect(props.onNextClick).toBeCalled();
+
+ userEvent.click(screen.getByRole('button', { name: 'Reset' }));
+ expect(props.onClear).toBeCalled();
+ });
+
+ test('hide clear button', () => {
+ const { onClear, ...testProps } = props;
+
+ render( );
+ expect(screen.queryByRole('button', { name: 'Reset' })).not.toBeInTheDocument();
+ });
+
+ test('advanced search', () => {
+ const { asFragment } = render(
+
+ );
+
+ userEvent.click(screen.getByRole('button', { name: 'Search' }));
+
+ expect(props.onSearch).toBeCalled();
+ expect(asFragment()).toMatchSnapshot();
+ });
+
+ test('advanced search with custom attributes', () => {
+ const { asFragment } = render(
+
+ } iconPosition="right">
+ Link
+
+
+ }
+ value="username:player firstname:john"
+ onChange={props.onChange}
+ onSearch={props.onSearch}
+ onClear={props.onClear}
+ />
+ );
+
+ userEvent.click(screen.getByRole('button', { name: 'Search' }));
-test('advanced search with custom attributes', () => {
- const view = mount(
- } iconPosition="right">Link}
- value='username:player firstname:john'
- onChange={props.onChange}
- onSearch={props.onSearch}
- onClear={props.onClear}
- />
- );
- view.find('.pf-c-button').at(2).simulate('click', {});
- expect(props.onSearch).toBeCalled();
- expect(view.find('input')).toMatchSnapshot();
+ expect(props.onSearch).toBeCalled();
+ expect(asFragment()).toMatchSnapshot();
+ });
});
diff --git a/packages/react-core/src/components/SearchInput/__tests__/__snapshots__/SearchInput.test.tsx.snap b/packages/react-core/src/components/SearchInput/__tests__/__snapshots__/SearchInput.test.tsx.snap
index d14bd74a411..2ebb5456932 100644
--- a/packages/react-core/src/components/SearchInput/__tests__/__snapshots__/SearchInput.test.tsx.snap
+++ b/packages/react-core/src/components/SearchInput/__tests__/__snapshots__/SearchInput.test.tsx.snap
@@ -1,156 +1,249 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`advanced search 1`] = `
-
-`;
-
-exports[`advanced search with custom attributes 1`] = `
-
-`;
-
-exports[`navigable search results 1`] = `
-
-
+
+
+`;
+
+exports[`SearchInput advanced search with custom attributes 1`] = `
+
+
+
+
`;
-exports[`search input with hint 1`] = `
-
+exports[`SearchInput search input with hint 1`] = `
+
@@ -300,11 +393,11 @@ exports[`search input with hint 1`] = `
-