>) =>
+ render({ui} );
-test('Simple Nav List', () => {
- const view = mount(
-
-
- {props.items.map(item => (
-
- {item.label}
-
- ))}
-
- ,
- { context }
- );
- expect(view).toMatchSnapshot();
-});
+describe('Nav', () => {
+ beforeEach(() => {
+ window.location.hash = '#link1';
+ });
-test('Expandable Nav List', () => {
- const view = mount(
-
-
-
+ test('Default Nav List', () => {
+ const { asFragment } = renderNav(
+
+
{props.items.map(item => (
-
+
{item.label}
))}
-
-
- ,
- { context }
- );
- expect(view).toMatchSnapshot();
-});
-
-test('Expandable Nav verify onExpand', () => {
- const onExpandSpy = jest.fn();
- const view = mount(
-
-
-
+
+
+ );
+ expect(asFragment()).toMatchSnapshot();
+ });
+
+ test('Dark Nav List', () => {
+ const { asFragment } = renderNav(
+
+
{props.items.map(item => (
-
+
{item.label}
))}
-
-
- ,
- { context }
- );
- const btn = view.find('button');
- btn.simulate('click');
- expect(onExpandSpy).toBeCalled();
-});
-
-test('Expandable Nav List - Trigger toggle', () => {
- window.location.hash = '#link2';
- const view = mount(
-
-
-
+
+
+ );
+ expect(asFragment()).toMatchSnapshot();
+ });
+
+ test('Default Nav List - Trigger item active update', () => {
+ const { asFragment } = renderNav(
+
+
{props.items.map(item => (
{item.label}
))}
-
-
- ,
- { context }
- );
- view
- .find('li.expandable-group')
- .first()
- .simulate('click');
- expect(view).toMatchSnapshot();
-});
+
+
+ );
+
+ userEvent.click(screen.getByText('Link 2'));
+ expect(asFragment()).toMatchSnapshot();
+ });
+
+ test('Expandable Nav List', () => {
+ const { asFragment } = renderNav(
+
+
+
+ {props.items.map(item => (
+
+ {item.label}
+
+ ))}
+
+
+
+ );
+ expect(asFragment()).toMatchSnapshot();
+ });
-test('Expandable Nav List with aria label', () => {
- const view = mount(
-
-
-
+ test('Expandable Nav verify onExpand', () => {
+ const onExpand = jest.fn();
+
+ renderNav(
+
+
+
+ {props.items.map(item => (
+
+ {item.label}
+
+ ))}
+
+
+
+ );
+
+ userEvent.click(screen.getByRole('button'));
+ expect(onExpand).toBeCalled();
+ });
+
+ test('Expandable Nav List - Trigger toggle', () => {
+ window.location.hash = '#link2';
+
+ const { asFragment } = renderNav(
+
+
+
+ {props.items.map(item => (
+
+ {item.label}
+
+ ))}
+
+
+
+ );
+
+ userEvent.click(screen.getByText('Section 1'));
+ expect(asFragment()).toMatchSnapshot();
+ });
+
+ test('Expandable Nav List with aria label', () => {
+ const { asFragment } = renderNav(
+
+
+
+ {props.items.map(item => (
+
+ {item.label}
+
+ ))}
+
+
+
+ );
+ expect(asFragment()).toMatchSnapshot();
+ });
+
+ test('Nav Grouped List', () => {
+ const { asFragment } = renderNav(
+
+
+
+ {props.items.map(item => (
+
+ {item.label}
+
+ ))}
+
+
+
+
+ {props.items.map(item => (
+
+ {item.label}
+
+ ))}
+
+
+
+ );
+ expect(asFragment()).toMatchSnapshot();
+ });
+
+ test('Horizontal Nav List', () => {
+ const { asFragment } = renderNav(
+
+
{props.items.map(item => (
{item.label}
))}
-
-
- ,
- { context }
- );
- expect(view).toMatchSnapshot();
-});
-
-test('Nav Grouped List', () => {
- const view = mount(
-
-
+
+
+ );
+ expect(asFragment()).toMatchSnapshot();
+ });
+
+ test('Horizontal SubNav List', () => {
+ const { asFragment } = renderNav(
+
{props.items.map(item => (
-
+
{item.label}
))}
-
-
+
+ );
+ expect(asFragment()).toMatchSnapshot();
+ });
+
+ test('Tertiary Nav List', () => {
+ const { asFragment } = renderNav(
+
{props.items.map(item => (
-
+
{item.label}
))}
-
- ,
- { context }
- );
- expect(view).toMatchSnapshot();
-});
-
-test('Horizontal Nav List', () => {
- const view = mount(
-
-
- {props.items.map(item => (
-
- {item.label}
-
- ))}
-
- ,
- { context }
- );
- expect(view).toMatchSnapshot();
-});
-
-test('Horizontal SubNav List', () => {
- const view = mount(
-
-
- {props.items.map(item => (
-
- {item.label}
-
- ))}
-
- ,
- { context }
- );
- expect(view).toMatchSnapshot();
-});
-
-test('Tertiary Nav List', () => {
- const view = mount(
-
-
- {props.items.map(item => (
-
- {item.label}
+
+ );
+ expect(asFragment()).toMatchSnapshot();
+ });
+
+ test('Nav List with custom item nodes', () => {
+ const { asFragment } = renderNav(
+
+
+
+ My custom node
- ))}
-
- ,
- { context }
- );
- expect(view).toMatchSnapshot();
-});
-
-test('Nav List with custom item nodes', () => {
- const view = mount(
-
-
-
- My custom node
-
-
- ,
- { context }
- );
- expect(view).toMatchSnapshot();
+
+
+ );
+ expect(asFragment()).toMatchSnapshot();
+ });
});
diff --git a/packages/react-core/src/components/Nav/__tests__/__snapshots__/Nav.test.tsx.snap b/packages/react-core/src/components/Nav/__tests__/__snapshots__/Nav.test.tsx.snap
index b928bd8cba3..8c75986cf41 100644
--- a/packages/react-core/src/components/Nav/__tests__/__snapshots__/Nav.test.tsx.snap
+++ b/packages/react-core/src/components/Nav/__tests__/__snapshots__/Nav.test.tsx.snap
@@ -1,1950 +1,1098 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`Dark Nav List 1`] = `
-
+exports[`Nav Dark Nav List 1`] = `
+
-
-
-
+ Link 4
+
+
+
-
+
`;
-exports[`Default Nav List - Trigger item active update 1`] = `
-
+exports[`Nav Default Nav List - Trigger item active update 1`] = `
+
-
-
-
+ Link 4
+
+
+
-
+
`;
-exports[`Default Nav List 1`] = `
-
+exports[`Nav Default Nav List 1`] = `
+
-
-
-
+ Link 4
+
+
+
-
+
`;
-exports[`Expandable Nav List - Trigger toggle 1`] = `
-
+exports[`Nav Expandable Nav List - Trigger toggle 1`] = `
+
-
-
-
-
-
- Section 1
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
-
-
-
-
+ Link 1
+
+
+
+
+ Link 2
+
+
+
+
+ Link 3
+
+
+
+
+ Link 4
+
+
+
+
+
+
-
+
`;
-exports[`Expandable Nav List 1`] = `
-
+exports[`Nav Expandable Nav List 1`] = `
+
-
-
-
-
-
- Section 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-`;
-
-exports[`Expandable Nav List with aria label 1`] = `
-
-
-
-
-
-
-
-
-
+ Link 4
+
+
+
+
+
+
-
+
`;
-exports[`Horizontal Nav List 1`] = `
-
+exports[`Nav Expandable Nav List with aria label 1`] = `
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ Link 2
+
+
+
+
+ Link 3
+
+
+
+
+ Link 4
+
+
+
+
+
+
-
+
`;
-exports[`Horizontal SubNav List 1`] = `
-
+exports[`Nav Horizontal Nav List 1`] = `
+
-
-
-
-
-
-
-
-
-
+
+
+
-
+
+
-
-
-
-
-
-
-
+ Link 4
+
+
+
+
+
+
+
+
-
+
`;
-exports[`Nav Grouped List 1`] = `
-
+exports[`Nav Horizontal SubNav List 1`] = `
+
-
-
-
-
+
+
+
-
-`;
-
-exports[`Nav List with custom item nodes 1`] = `
-
-
-
-
+
+
-
-
-
-
-
-
-
+
+
-
-
-
- My custom node
-
-
-
-
-
+
+
-
-
-
-
-
-
-
+ Link 4
+
+
+
+
+
+
+
+
-
+
`;
-exports[`Simple Nav List 1`] = `
-
+exports[`Nav Nav Grouped List 1`] = `
+
-
+
+ Section 1
+
-
-
-
-`;
-
-exports[`Tertiary Nav List 1`] = `
-
-
-
+
-
-
-
-
-
-
-
+ Section 2
+
-
+
+
+`;
+
+exports[`Nav Nav List with custom item nodes 1`] = `
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+ My custom node
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`Nav Tertiary Nav List 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
`;
diff --git a/packages/react-core/src/components/NotificationDrawer/__tests__/NotificationDrawer.test.tsx b/packages/react-core/src/components/NotificationDrawer/__tests__/NotificationDrawer.test.tsx
index 449d60b9f88..41681a7c446 100644
--- a/packages/react-core/src/components/NotificationDrawer/__tests__/NotificationDrawer.test.tsx
+++ b/packages/react-core/src/components/NotificationDrawer/__tests__/NotificationDrawer.test.tsx
@@ -1,20 +1,18 @@
import React from 'react';
-import { NotificationDrawer } from '../NotificationDrawer';
-import { render } from '@testing-library/react';
-import { shallow } from 'enzyme';
-test('renders with PatternFly Core styles', () => {
- const view = render( );
- expect(view.container).toMatchSnapshot();
-});
+import { render, screen } from '@testing-library/react';
+import "@testing-library/jest-dom";
-test('className is added to the root element', () => {
- const view = shallow( );
- expect(view.prop('className')).toMatchSnapshot();
-});
+import { NotificationDrawer } from '../NotificationDrawer';
+
+describe('NotificationDrawer', () => {
+ test('renders with PatternFly Core styles', () => {
+ const { asFragment } = render( );
+ expect(asFragment()).toMatchSnapshot();
+ });
-test('extra props are spread to the root element', () => {
- const testId = 'notification-drawer';
- const view = shallow( );
- expect(view.prop('data-testid')).toBe(testId);
+ test('className is added to the root element', () => {
+ render( );
+ expect(screen.getByTestId('test-id')).toHaveClass('extra-class');
+ });
});
diff --git a/packages/react-core/src/components/NotificationDrawer/__tests__/NotificationDrawerBody.test.tsx b/packages/react-core/src/components/NotificationDrawer/__tests__/NotificationDrawerBody.test.tsx
index 5168dd24261..c12da82340e 100644
--- a/packages/react-core/src/components/NotificationDrawer/__tests__/NotificationDrawerBody.test.tsx
+++ b/packages/react-core/src/components/NotificationDrawer/__tests__/NotificationDrawerBody.test.tsx
@@ -1,20 +1,18 @@
import React from 'react';
-import { NotificationDrawerBody } from '../NotificationDrawerBody';
-import { render } from '@testing-library/react';
-import { shallow } from 'enzyme';
-test('renders with PatternFly Core styles', () => {
- const view = render( );
- expect(view.container).toMatchSnapshot();
-});
+import { render, screen } from '@testing-library/react';
+import "@testing-library/jest-dom";
-test('className is added to the root element', () => {
- const view = shallow( );
- expect(view.prop('className')).toMatchSnapshot();
-});
+import { NotificationDrawerBody } from '../NotificationDrawerBody';
+
+describe('NotificationDrawerBody', () => {
+ test('renders with PatternFly Core styles', () => {
+ const { asFragment } = render( );
+ expect(asFragment()).toMatchSnapshot();
+ });
-test('extra props are spread to the root element', () => {
- const testId = 'notification-drawer';
- const view = shallow( );
- expect(view.prop('data-testid')).toBe(testId);
+ test('className is added to the root element', () => {
+ render( );
+ expect(screen.getByTestId('test-id')).toHaveClass('extra-class');
+ });
});
diff --git a/packages/react-core/src/components/NotificationDrawer/__tests__/NotificationDrawerGroup.test.tsx b/packages/react-core/src/components/NotificationDrawer/__tests__/NotificationDrawerGroup.test.tsx
index 5cb52df7a8f..417e753d06b 100644
--- a/packages/react-core/src/components/NotificationDrawer/__tests__/NotificationDrawerGroup.test.tsx
+++ b/packages/react-core/src/components/NotificationDrawer/__tests__/NotificationDrawerGroup.test.tsx
@@ -1,34 +1,28 @@
import React from 'react';
-import { NotificationDrawerGroup } from '../NotificationDrawerGroup';
-import { render } from '@testing-library/react';
-import { shallow } from 'enzyme';
-test('renders with PatternFly Core styles', () => {
- const view = render( );
- expect(view.container).toMatchSnapshot();
-});
+import { render, screen } from '@testing-library/react';
+import "@testing-library/jest-dom";
-test('className is added to the root element', () => {
- const view = shallow(
-
- );
- expect(view.prop('className')).toMatchSnapshot();
-});
+import { NotificationDrawerGroup } from '../NotificationDrawerGroup';
-test('extra props are spread to the root element', () => {
- const testId = 'notification-drawer';
- const view = shallow(
-
- );
- expect(view.prop('data-testid')).toBe(testId);
-});
+describe('NotificationDrawerGroup', () => {
+ test('renders with PatternFly Core styles', () => {
+ const { asFragment } = render( );
+ expect(asFragment()).toMatchSnapshot();
+ });
-test('drawer group with isExpanded applied ', () => {
- const view = render( );
- expect(view.container).toMatchSnapshot();
-});
+ test('className is added to the root element', () => {
+ render( );
+ expect(screen.getByTestId('test-id')).toHaveClass('extra-class');
+ });
+
+ test('drawer group with isExpanded applied ', () => {
+ const { asFragment } = render( );
+ expect(asFragment()).toMatchSnapshot();
+ });
-test('drawer group with isRead applied ', () => {
- const view = render( );
- expect(view.container).toMatchSnapshot();
+ test('drawer group with isRead applied ', () => {
+ const { asFragment } = render( );
+ expect(asFragment()).toMatchSnapshot();
+ });
});
diff --git a/packages/react-core/src/components/NotificationDrawer/__tests__/NotificationDrawerGroupList.test.tsx b/packages/react-core/src/components/NotificationDrawer/__tests__/NotificationDrawerGroupList.test.tsx
index eb824401d78..55104200325 100644
--- a/packages/react-core/src/components/NotificationDrawer/__tests__/NotificationDrawerGroupList.test.tsx
+++ b/packages/react-core/src/components/NotificationDrawer/__tests__/NotificationDrawerGroupList.test.tsx
@@ -1,20 +1,18 @@
import React from 'react';
-import { NotificationDrawerGroupList } from '../NotificationDrawerGroupList';
-import { render } from '@testing-library/react';
-import { shallow } from 'enzyme';
-test('renders with PatternFly Core styles', () => {
- const view = render( );
- expect(view.container).toMatchSnapshot();
-});
+import { render, screen } from '@testing-library/react';
+import "@testing-library/jest-dom";
-test('className is added to the root element', () => {
- const view = shallow( );
- expect(view.prop('className')).toMatchSnapshot();
-});
+import { NotificationDrawerGroupList } from '../NotificationDrawerGroupList';
+
+describe('NotificationDrawerGroupList', () => {
+ test('renders with PatternFly Core styles', () => {
+ const { asFragment } = render( );
+ expect(asFragment()).toMatchSnapshot();
+ });
-test('extra props are spread to the root element', () => {
- const testId = 'notification-drawer';
- const view = shallow( );
- expect(view.prop('data-testid')).toBe(testId);
+ test('className is added to the root element', () => {
+ render( );
+ expect(screen.getByTestId('test-id')).toHaveClass('extra-class');
+ });
});
diff --git a/packages/react-core/src/components/NotificationDrawer/__tests__/NotificationDrawerHeader.test.tsx b/packages/react-core/src/components/NotificationDrawer/__tests__/NotificationDrawerHeader.test.tsx
index 67b4645c50a..7c450b42288 100644
--- a/packages/react-core/src/components/NotificationDrawer/__tests__/NotificationDrawerHeader.test.tsx
+++ b/packages/react-core/src/components/NotificationDrawer/__tests__/NotificationDrawerHeader.test.tsx
@@ -1,35 +1,33 @@
import React from 'react';
-import { NotificationDrawerHeader } from '../NotificationDrawerHeader';
-import { render } from '@testing-library/react';
-import { shallow } from 'enzyme';
-test('renders with PatternFly Core styles', () => {
- const view = render( );
- expect(view.container).toMatchSnapshot();
-});
+import { render, screen } from '@testing-library/react';
+import "@testing-library/jest-dom";
-test('className is added to the root element', () => {
- const view = shallow( );
- expect(view.prop('className')).toMatchSnapshot();
-});
+import { NotificationDrawerHeader } from '../NotificationDrawerHeader';
-test('extra props are spread to the root element', () => {
- const testId = 'notification-drawer';
- const view = shallow( );
- expect(view.prop('data-testid')).toBe(testId);
-});
+describe('NotificationDrawerHeader', () => {
+ test('renders with PatternFly Core styles', () => {
+ const { asFragment } = render( );
+ expect(asFragment()).toMatchSnapshot();
+ });
-test('drawer header with count applied', () => {
- const view = render( );
- expect(view.container).toMatchSnapshot();
-});
+ test('className is added to the root element', () => {
+ render( );
+ expect(screen.getByText('Notifications').parentElement).toHaveClass('extra-class');
+ });
-test('drawer header with title applied', () => {
- const view = render( );
- expect(view.container).toMatchSnapshot();
-});
+ test('drawer header with count applied', () => {
+ const { asFragment } = render( );
+ expect(asFragment()).toMatchSnapshot();
+ });
+
+ test('drawer header with title applied', () => {
+ const { asFragment } = render( );
+ expect(asFragment()).toMatchSnapshot();
+ });
-test('drawer header with custom unread text applied', () => {
- const view = render( );
- expect(view.container).toMatchSnapshot();
+ test('drawer header with custom unread text applied', () => {
+ const { asFragment } = render( );
+ expect(asFragment()).toMatchSnapshot();
+ });
});
diff --git a/packages/react-core/src/components/NotificationDrawer/__tests__/NotificationDrawerList.test.tsx b/packages/react-core/src/components/NotificationDrawer/__tests__/NotificationDrawerList.test.tsx
index 203e698dc94..3b467611f76 100644
--- a/packages/react-core/src/components/NotificationDrawer/__tests__/NotificationDrawerList.test.tsx
+++ b/packages/react-core/src/components/NotificationDrawer/__tests__/NotificationDrawerList.test.tsx
@@ -1,25 +1,23 @@
import React from 'react';
-import { NotificationDrawerList } from '../NotificationDrawerList';
-import { render } from '@testing-library/react';
-import { shallow } from 'enzyme';
-test('renders with PatternFly Core styles', () => {
- const view = render( );
- expect(view.container).toMatchSnapshot();
-});
+import { render, screen } from '@testing-library/react';
+import "@testing-library/jest-dom";
-test('className is added to the root element', () => {
- const view = shallow( );
- expect(view.prop('className')).toMatchSnapshot();
-});
+import { NotificationDrawerList } from '../NotificationDrawerList';
-test('extra props are spread to the root element', () => {
- const testId = 'notification-drawer';
- const view = shallow( );
- expect(view.prop('data-testid')).toBe(testId);
-});
+describe('NotificationDrawerList', () => {
+ test('renders with PatternFly Core styles', () => {
+ const { asFragment } = render( );
+ expect(asFragment()).toMatchSnapshot();
+ });
+
+ test('className is added to the root element', () => {
+ render( );
+ expect(screen.getByRole('list')).toHaveClass('extra-class');
+ });
-test('drawer list with hidden applied ', () => {
- const view = render( );
- expect(view.container).toMatchSnapshot();
+ test('drawer list with hidden applied ', () => {
+ const { asFragment } = render( );
+ expect(asFragment()).toMatchSnapshot();
+ });
});
diff --git a/packages/react-core/src/components/NotificationDrawer/__tests__/NotificationDrawerListItem.test.tsx b/packages/react-core/src/components/NotificationDrawer/__tests__/NotificationDrawerListItem.test.tsx
index a4c62cc2d52..0da008b18a0 100644
--- a/packages/react-core/src/components/NotificationDrawer/__tests__/NotificationDrawerListItem.test.tsx
+++ b/packages/react-core/src/components/NotificationDrawer/__tests__/NotificationDrawerListItem.test.tsx
@@ -1,35 +1,28 @@
import React from 'react';
-import { NotificationDrawerListItem } from '../NotificationDrawerListItem';
-import { render } from '@testing-library/react';
-import { shallow } from 'enzyme';
-test('renders with PatternFly Core styles', () => {
- const view = render( );
- expect(view.container).toMatchSnapshot();
-});
+import { render, screen } from '@testing-library/react';
+import "@testing-library/jest-dom";
-test('className is added to the root element', () => {
- const view = shallow( );
- expect(view.prop('className')).toMatchSnapshot();
-});
+import { NotificationDrawerListItem } from '../NotificationDrawerListItem';
-test('extra props are spread to the root element', () => {
- const testId = 'notification-drawer';
- const view = shallow( );
- expect(view.prop('data-testid')).toBe(testId);
-});
+describe('NotificationDrawerListItem', () => {
+ test('renders with PatternFly Core styles', () => {
+ const { asFragment } = render( );
+ expect(asFragment()).toMatchSnapshot();
+ });
-test('drawer list item with isHoverable applied ', () => {
- const view = shallow( );
- expect(view.prop('className')).toMatch(/hoverable/);
-});
+ test('className is added to the root element', () => {
+ render( );
+ expect(screen.getByRole('listitem')).toHaveClass('extra-class');
+ });
-test('drawer list item with isRead applied ', () => {
- const view = shallow( );
- expect(view.prop('className')).toMatch(/read/);
-});
+ test('drawer list item with isHoverable applied', () => {
+ render( );
+ expect(screen.getByRole('listitem')).toHaveClass('pf-m-hoverable');
+ });
-test('drawer list item with tabIndex value applied ', () => {
- const view = shallow( );
- expect(view.prop('tabIndex')).toBe(4);
+ test('drawer list item with isRead applied', () => {
+ render( );
+ expect(screen.getByRole('listitem')).toHaveClass('pf-m-read');
+ });
});
diff --git a/packages/react-core/src/components/NotificationDrawer/__tests__/NotificationDrawerListItemBody.test.tsx b/packages/react-core/src/components/NotificationDrawer/__tests__/NotificationDrawerListItemBody.test.tsx
index b9e51ae5c77..1b72cd602d3 100644
--- a/packages/react-core/src/components/NotificationDrawer/__tests__/NotificationDrawerListItemBody.test.tsx
+++ b/packages/react-core/src/components/NotificationDrawer/__tests__/NotificationDrawerListItemBody.test.tsx
@@ -1,19 +1,23 @@
import React from 'react';
+
+import { render, screen } from '@testing-library/react';
+import "@testing-library/jest-dom";
+
import { NotificationDrawerListItemBody } from '../NotificationDrawerListItemBody';
-import { render } from '@testing-library/react';
-import { shallow } from 'enzyme';
-test('renders with PatternFly Core styles', () => {
- const view = render( );
- expect(view.container).toMatchSnapshot();
-});
+describe('NotificationDrawerListItemBody', () => {
+ 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.getByTestId('test-id')).toHaveClass('extra-class');
+ });
-test('list item body with timestamp property applied ', () => {
- const view = render( );
- expect(view.container).toMatchSnapshot();
+ test('list item body with timestamp property applied', () => {
+ const { asFragment } = render( );
+ expect(asFragment()).toMatchSnapshot();
+ });
});
diff --git a/packages/react-core/src/components/NotificationDrawer/__tests__/NotificationDrawerListItemHeader.test.tsx b/packages/react-core/src/components/NotificationDrawer/__tests__/NotificationDrawerListItemHeader.test.tsx
index 0910895b56f..952399dfde5 100644
--- a/packages/react-core/src/components/NotificationDrawer/__tests__/NotificationDrawerListItemHeader.test.tsx
+++ b/packages/react-core/src/components/NotificationDrawer/__tests__/NotificationDrawerListItemHeader.test.tsx
@@ -1,35 +1,40 @@
import React from 'react';
-import { render } from '@testing-library/react';
-import { mount } from 'enzyme';
+
+import { render, screen } from '@testing-library/react';
+import "@testing-library/jest-dom";
+
import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
import { NotificationDrawerListItemHeader } from '../NotificationDrawerListItemHeader';
-test('renders with PatternFly Core styles', () => {
- const view = render( );
- expect(view.container).toMatchSnapshot();
-});
+describe('NotificationDrawerListItemHeader', () => {
+ test('renders with PatternFly Core styles', () => {
+ const { asFragment } = render( );
+ expect(asFragment()).toMatchSnapshot();
+ });
-test('className is added to the root element', () => {
- const view = mount( );
- expect(view.prop('className')).toMatchSnapshot();
-});
+ test('className is added to the root element', () => {
+ render( );
+ expect(screen.getByTestId('test-id')).toHaveClass('extra-class');
+ });
-test('list item header with custom icon applied ', () => {
- const view = render( } />);
- expect(view.container).toMatchSnapshot();
-});
+ test('list item header with custom icon applied ', () => {
+ const { asFragment } = render( } />);
+ expect(asFragment()).toMatchSnapshot();
+ });
-test('list item header with srTitle applied ', () => {
- const view = render( );
- expect(view.container).toMatchSnapshot();
-});
+ test('list item header with srTitle applied ', () => {
+ const { asFragment } = render( );
+ expect(asFragment()).toMatchSnapshot();
+ });
-test('list item header with variant applied ', () => {
- const view = render( );
- expect(view.container).toMatchSnapshot();
-});
+ test('list item header with variant applied ', () => {
+ const { asFragment } = render( );
+ expect(asFragment()).toMatchSnapshot();
+ });
+
+ test('list item header with truncateTitle', () => {
+ render( );
-test('list item header with truncateTitle', () => {
- const view = mount( );
- expect(view.find('h2').prop('className')).toContain('pf-m-truncate');
+ expect(screen.getByText('Pod quit unexpectedly')).toHaveClass('pf-m-truncate');
+ });
});
diff --git a/packages/react-core/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawer.test.tsx.snap b/packages/react-core/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawer.test.tsx.snap
index 72dfeaeb338..93e6ed349f1 100644
--- a/packages/react-core/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawer.test.tsx.snap
+++ b/packages/react-core/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawer.test.tsx.snap
@@ -1,11 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`className is added to the root element 1`] = `"extra-class"`;
-
-exports[`renders with PatternFly Core styles 1`] = `
-
+exports[`NotificationDrawer renders with PatternFly Core styles 1`] = `
+
-
+
`;
diff --git a/packages/react-core/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerBody.test.tsx.snap b/packages/react-core/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerBody.test.tsx.snap
index 429acc53973..56f23755eb1 100644
--- a/packages/react-core/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerBody.test.tsx.snap
+++ b/packages/react-core/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerBody.test.tsx.snap
@@ -1,11 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`className is added to the root element 1`] = `"pf-c-notification-drawer__body extra-class"`;
-
-exports[`renders with PatternFly Core styles 1`] = `
-
+exports[`NotificationDrawerBody renders with PatternFly Core styles 1`] = `
+
-
+
`;
diff --git a/packages/react-core/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerGroup.test.tsx.snap b/packages/react-core/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerGroup.test.tsx.snap
index c2d4c5a7b9d..bd3d9190c9f 100644
--- a/packages/react-core/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerGroup.test.tsx.snap
+++ b/packages/react-core/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerGroup.test.tsx.snap
@@ -1,9 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`className is added to the root element 1`] = `"pf-c-notification-drawer__group extra-class"`;
-
-exports[`drawer group with isExpanded applied 1`] = `
-
+exports[`NotificationDrawerGroup drawer group with isExpanded applied 1`] = `
+
@@ -46,11 +44,11 @@ exports[`drawer group with isExpanded applied 1`] = `
-
+
`;
-exports[`drawer group with isRead applied 1`] = `
-
+exports[`NotificationDrawerGroup drawer group with isRead applied 1`] = `
+
@@ -93,11 +91,11 @@ exports[`drawer group with isRead applied 1`] = `
-
+
`;
-exports[`renders with PatternFly Core styles 1`] = `
-
+exports[`NotificationDrawerGroup renders with PatternFly Core styles 1`] = `
+
@@ -140,5 +138,5 @@ exports[`renders with PatternFly Core styles 1`] = `
-
+
`;
diff --git a/packages/react-core/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerGroupList.test.tsx.snap b/packages/react-core/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerGroupList.test.tsx.snap
index 52b09fd3cab..a20d9593373 100644
--- a/packages/react-core/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerGroupList.test.tsx.snap
+++ b/packages/react-core/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerGroupList.test.tsx.snap
@@ -1,11 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`className is added to the root element 1`] = `"pf-c-notification-drawer__group-list extra-class"`;
-
-exports[`renders with PatternFly Core styles 1`] = `
-
+exports[`NotificationDrawerGroupList renders with PatternFly Core styles 1`] = `
+
-
+
`;
diff --git a/packages/react-core/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerHeader.test.tsx.snap b/packages/react-core/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerHeader.test.tsx.snap
index 33dc45b7c8b..4d32c4552a1 100644
--- a/packages/react-core/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerHeader.test.tsx.snap
+++ b/packages/react-core/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerHeader.test.tsx.snap
@@ -1,15 +1,13 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`className is added to the root element 1`] = `"pf-c-notification-drawer__header extra-class"`;
-
-exports[`drawer header with count applied 1`] = `
-
+exports[`NotificationDrawerHeader drawer header with count applied 1`] = `
+
-
+
`;
-exports[`drawer header with custom unread text applied 1`] = `
-
+exports[`NotificationDrawerHeader drawer header with custom unread text applied 1`] = `
+
-
+
`;
-exports[`drawer header with title applied 1`] = `
-
+exports[`NotificationDrawerHeader drawer header with title applied 1`] = `
+
-
+
`;
-exports[`renders with PatternFly Core styles 1`] = `
-
+exports[`NotificationDrawerHeader renders with PatternFly Core styles 1`] = `
+
-
+
`;
diff --git a/packages/react-core/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerList.test.tsx.snap b/packages/react-core/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerList.test.tsx.snap
index adff919c683..6d038cd1eec 100644
--- a/packages/react-core/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerList.test.tsx.snap
+++ b/packages/react-core/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerList.test.tsx.snap
@@ -1,19 +1,18 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`className is added to the root element 1`] = `"pf-c-notification-drawer__list extra-class"`;
-
-exports[`drawer list with hidden applied 1`] = `
-
+exports[`NotificationDrawerList drawer list with hidden applied 1`] = `
+
-
+
`;
-exports[`renders with PatternFly Core styles 1`] = `
-
+exports[`NotificationDrawerList renders with PatternFly Core styles 1`] = `
+
-
+
`;
diff --git a/packages/react-core/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerListItem.test.tsx.snap b/packages/react-core/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerListItem.test.tsx.snap
index fd9ac5b87ce..29ec2562743 100644
--- a/packages/react-core/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerListItem.test.tsx.snap
+++ b/packages/react-core/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerListItem.test.tsx.snap
@@ -1,12 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`className is added to the root element 1`] = `"pf-c-notification-drawer__list-item pf-m-hoverable pf-m-default extra-class"`;
-
-exports[`renders with PatternFly Core styles 1`] = `
-
+exports[`NotificationDrawerListItem renders with PatternFly Core styles 1`] = `
+
-
+
`;
diff --git a/packages/react-core/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerListItemBody.test.tsx.snap b/packages/react-core/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerListItemBody.test.tsx.snap
index 3949f0ddeb4..b29d178f40a 100644
--- a/packages/react-core/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerListItemBody.test.tsx.snap
+++ b/packages/react-core/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerListItemBody.test.tsx.snap
@@ -1,9 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`className is added to the root element 1`] = `undefined`;
-
-exports[`list item body with timestamp property applied 1`] = `
-
+exports[`NotificationDrawerListItemBody list item body with timestamp property applied 1`] = `
+
@@ -12,13 +10,13 @@ exports[`list item body with timestamp property applied 1`] = `
>
5 minutes ago
-
+
`;
-exports[`renders with PatternFly Core styles 1`] = `
-
+exports[`NotificationDrawerListItemBody renders with PatternFly Core styles 1`] = `
+
-
+
`;
diff --git a/packages/react-core/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerListItemHeader.test.tsx.snap b/packages/react-core/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerListItemHeader.test.tsx.snap
index fb79d3981b5..f3f21499d45 100644
--- a/packages/react-core/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerListItemHeader.test.tsx.snap
+++ b/packages/react-core/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerListItemHeader.test.tsx.snap
@@ -1,9 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`className is added to the root element 1`] = `"extra-class"`;
-
-exports[`list item header with custom icon applied 1`] = `
-
+exports[`NotificationDrawerListItemHeader list item header with custom icon applied 1`] = `
+
-
+
`;
-exports[`list item header with srTitle applied 1`] = `
-
+exports[`NotificationDrawerListItemHeader list item header with srTitle applied 1`] = `
+
-
+
`;
-exports[`list item header with variant applied 1`] = `
-
+exports[`NotificationDrawerListItemHeader list item header with variant applied 1`] = `
+
-
+
`;
-exports[`renders with PatternFly Core styles 1`] = `
-
+exports[`NotificationDrawerListItemHeader renders with PatternFly Core styles 1`] = `
+
-
+
`;
diff --git a/packages/react-core/src/components/OverflowMenu/__tests__/OverflowMenu.test.tsx b/packages/react-core/src/components/OverflowMenu/__tests__/OverflowMenu.test.tsx
index 8c976e064f7..304376131f7 100644
--- a/packages/react-core/src/components/OverflowMenu/__tests__/OverflowMenu.test.tsx
+++ b/packages/react-core/src/components/OverflowMenu/__tests__/OverflowMenu.test.tsx
@@ -1,43 +1,46 @@
import * as React from 'react';
-import { render } from '@testing-library/react';
-import { mount } from 'enzyme';
+
+import { render, screen } from '@testing-library/react';
+import '@testing-library/jest-dom';
+
import styles from '@patternfly/react-styles/css/components/OverflowMenu/overflow-menu';
import { OverflowMenu } from '../OverflowMenu';
describe('OverflowMenu', () => {
test('md', () => {
- const view = mount( );
- expect(view.find(`.${styles.overflowMenu}`).length).toBe(1);
- expect(view).toMatchSnapshot();
+ render( );
+ expect(screen.getByTestId('test-id')).toHaveClass(styles.overflowMenu);
});
test('lg', () => {
- const view = render( );
- expect(view.container).toMatchSnapshot();
+ const { asFragment } = render( );
+ expect(asFragment()).toMatchSnapshot();
});
test('xl', () => {
- const view = render( );
- expect(view.container).toMatchSnapshot();
+ const { asFragment } = render( );
+ expect(asFragment()).toMatchSnapshot();
});
test('basic', () => {
- const view = render(
+ const { asFragment } = render(
BASIC
);
- expect(view.container).toMatchSnapshot();
+ expect(asFragment()).toMatchSnapshot();
});
test('should warn on bad props', () => {
const myMock = jest.fn() as any;
global.console = { error: myMock } as any;
+
render(
-
+
BASIC
);
+
expect(myMock).toBeCalled();
});
});
diff --git a/packages/react-core/src/components/OverflowMenu/__tests__/OverflowMenuControl.test.tsx b/packages/react-core/src/components/OverflowMenu/__tests__/OverflowMenuControl.test.tsx
index 0d45d266679..6edf01544d2 100644
--- a/packages/react-core/src/components/OverflowMenu/__tests__/OverflowMenuControl.test.tsx
+++ b/packages/react-core/src/components/OverflowMenu/__tests__/OverflowMenuControl.test.tsx
@@ -1,23 +1,24 @@
import * as React from 'react';
-import { render } from '@testing-library/react';
-import { mount } from 'enzyme';
+
+import { render, screen } from '@testing-library/react';
+import '@testing-library/jest-dom';
+
import styles from '@patternfly/react-styles/css/components/OverflowMenu/overflow-menu';
import { OverflowMenuControl } from '../OverflowMenuControl';
import { OverflowMenuContext } from '../OverflowMenuContext';
describe('OverflowMenuControl', () => {
test('basic', () => {
- const view = mount(
+ render(
-
+
);
- expect(view.find(`.${styles.overflowMenuControl}`).length).toBe(1);
- expect(view).toMatchSnapshot();
+ expect(screen.getByTestId('test-id')).toHaveClass(styles.overflowMenuControl);
});
test('Additional Options', () => {
- const view = render( );
- expect(view.container).toMatchSnapshot();
+ const { asFragment } = render( );
+ expect(asFragment()).toMatchSnapshot();
});
});
diff --git a/packages/react-core/src/components/OverflowMenu/__tests__/OverflowMenuGroup.test.tsx b/packages/react-core/src/components/OverflowMenu/__tests__/OverflowMenuGroup.test.tsx
index 4bcb5025466..6fb5071fbea 100644
--- a/packages/react-core/src/components/OverflowMenu/__tests__/OverflowMenuGroup.test.tsx
+++ b/packages/react-core/src/components/OverflowMenu/__tests__/OverflowMenuGroup.test.tsx
@@ -1,47 +1,46 @@
-import * as React from 'react';
-import { mount } from 'enzyme';
+import React from 'react';
+
+import { render, screen } from '@testing-library/react';
+import '@testing-library/jest-dom';
+
import styles from '@patternfly/react-styles/css/components/OverflowMenu/overflow-menu';
import { OverflowMenuGroup } from '../OverflowMenuGroup';
import { OverflowMenuContext } from '../OverflowMenuContext';
describe('OverflowMenuGroup', () => {
test('isPersistent and below breakpoint should still show', () => {
- const view = mount(
+ render(
-
+
);
- expect(view.find(`.${styles.overflowMenuGroup}`).length).toBe(1);
- expect(view).toMatchSnapshot();
+ expect(screen.getByTestId('test-id')).toHaveClass(styles.overflowMenuGroup);
});
test('Below breakpoint but not isPersistent should not show', () => {
- const view = mount(
+ render(
-
+
);
- expect(view.find(`.${styles.overflowMenuGroup}`).length).toBe(0);
- expect(view).toMatchSnapshot();
+ expect(screen.queryByTestId('test-id')).toBeNull();
});
test('Button group', () => {
- const view = mount(
+ render(
-
+
);
- expect(view.find(`.${styles.modifiers.buttonGroup}`).length).toBe(1);
- expect(view).toMatchSnapshot();
+ expect(screen.getByTestId('test-id')).toHaveClass(styles.modifiers.buttonGroup);
});
test('Icon group', () => {
- const view = mount(
+ render(
-
+
);
- expect(view.find(`.${styles.modifiers.iconButtonGroup}`).length).toBe(1);
- expect(view).toMatchSnapshot();
+ expect(screen.getByTestId('test-id')).toHaveClass(styles.modifiers.iconButtonGroup);
});
});
diff --git a/packages/react-core/src/components/OverflowMenu/__tests__/OverflowMenuItem.test.tsx b/packages/react-core/src/components/OverflowMenu/__tests__/OverflowMenuItem.test.tsx
index fdcbfc7aa46..eeabd520cd8 100644
--- a/packages/react-core/src/components/OverflowMenu/__tests__/OverflowMenuItem.test.tsx
+++ b/packages/react-core/src/components/OverflowMenu/__tests__/OverflowMenuItem.test.tsx
@@ -1,27 +1,28 @@
import * as React from 'react';
-import { render } from '@testing-library/react';
-import { mount } from 'enzyme';
+
+import { render, screen } from '@testing-library/react';
+import '@testing-library/jest-dom';
+
import styles from '@patternfly/react-styles/css/components/OverflowMenu/overflow-menu';
import { OverflowMenuItem } from '../OverflowMenuItem';
import { OverflowMenuContext } from '../OverflowMenuContext';
describe('OverflowMenuItem', () => {
test('isPersistent and below breakpoint should still show', () => {
- const view = mount(
+ render(
-
+ Some item value
);
- expect(view.find(`.${styles.overflowMenuItem}`).length).toBe(1);
- expect(view).toMatchSnapshot();
+ expect(screen.getByText('Some item value')).toHaveClass(styles.overflowMenuItem);
});
test('Below breakpoint and not isPersistent should not show', () => {
- const view = render(
+ const { asFragment } = render(
-
+ Some item value
);
- expect(view.container).toMatchSnapshot();
+ expect(asFragment()).toMatchSnapshot();
});
});
diff --git a/packages/react-core/src/components/OverflowMenu/__tests__/__snapshots__/OverflowMenu.test.tsx.snap b/packages/react-core/src/components/OverflowMenu/__tests__/__snapshots__/OverflowMenu.test.tsx.snap
index 0b818017649..395c015001c 100644
--- a/packages/react-core/src/components/OverflowMenu/__tests__/__snapshots__/OverflowMenu.test.tsx.snap
+++ b/packages/react-core/src/components/OverflowMenu/__tests__/__snapshots__/OverflowMenu.test.tsx.snap
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`OverflowMenu basic 1`] = `
-
+
-
+
`;
exports[`OverflowMenu lg 1`] = `
-
+
-
-`;
-
-exports[`OverflowMenu md 1`] = `
-
-
-
+
`;
exports[`OverflowMenu xl 1`] = `
-
+
-
+
`;
diff --git a/packages/react-core/src/components/OverflowMenu/__tests__/__snapshots__/OverflowMenuControl.test.tsx.snap b/packages/react-core/src/components/OverflowMenu/__tests__/__snapshots__/OverflowMenuControl.test.tsx.snap
index 00e33519905..cc338c024b8 100644
--- a/packages/react-core/src/components/OverflowMenu/__tests__/__snapshots__/OverflowMenuControl.test.tsx.snap
+++ b/packages/react-core/src/components/OverflowMenu/__tests__/__snapshots__/OverflowMenuControl.test.tsx.snap
@@ -1,23 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`OverflowMenuControl Additional Options 1`] = `
-
+
-
-`;
-
-exports[`OverflowMenuControl basic 1`] = `
-
-
-
-
-
-
+
`;
diff --git a/packages/react-core/src/components/OverflowMenu/__tests__/__snapshots__/OverflowMenuGroup.test.tsx.snap b/packages/react-core/src/components/OverflowMenu/__tests__/__snapshots__/OverflowMenuGroup.test.tsx.snap
deleted file mode 100644
index 7c3bec943ec..00000000000
--- a/packages/react-core/src/components/OverflowMenu/__tests__/__snapshots__/OverflowMenuGroup.test.tsx.snap
+++ /dev/null
@@ -1,33 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`OverflowMenuGroup Below breakpoint but not isPersistent should not show 1`] = ` `;
-
-exports[`OverflowMenuGroup Button group 1`] = `
-
-
-
-`;
-
-exports[`OverflowMenuGroup Icon group 1`] = `
-
-
-
-`;
-
-exports[`OverflowMenuGroup isPersistent and below breakpoint should still show 1`] = `
-
-
-
-`;
diff --git a/packages/react-core/src/components/OverflowMenu/__tests__/__snapshots__/OverflowMenuItem.test.tsx.snap b/packages/react-core/src/components/OverflowMenu/__tests__/__snapshots__/OverflowMenuItem.test.tsx.snap
index f9f5881064e..c6880a212d2 100644
--- a/packages/react-core/src/components/OverflowMenu/__tests__/__snapshots__/OverflowMenuItem.test.tsx.snap
+++ b/packages/react-core/src/components/OverflowMenu/__tests__/__snapshots__/OverflowMenuItem.test.tsx.snap
@@ -1,25 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`OverflowMenuItem Below breakpoint and not isPersistent should not show 1`] = `
-
+
-
-`;
-
-exports[`OverflowMenuItem isPersistent and below breakpoint should still show 1`] = `
-
-
-
-
-
-
+
`;