@patternfly/react-core 4.199.2 → 4.199.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/umd/react-core.css +2 -2
  3. package/dist/umd/react-core.min.css +221 -221
  4. package/package.json +6 -6
  5. package/src/components/AboutModal/__tests__/AboutModal.test.tsx +41 -60
  6. package/src/components/Accordion/__tests__/Accordion.test.tsx +23 -17
  7. package/src/components/Alert/__tests__/Alert.test.tsx +195 -184
  8. package/src/components/Alert/__tests__/Generated/AlertActionCloseButton.test.tsx +19 -17
  9. package/src/components/Alert/__tests__/Generated/__snapshots__/AlertActionCloseButton.test.tsx.snap +26 -4
  10. package/src/components/Alert/__tests__/__snapshots__/Alert.test.tsx.snap +50 -700
  11. package/src/components/AlertGroup/__tests__/AlertGroup.test.tsx +68 -73
  12. package/src/components/AlertGroup/__tests__/__snapshots__/AlertGroup.test.tsx.snap +1 -893
  13. package/src/components/ApplicationLauncher/__tests__/Generated/ApplicationLauncherSeparator.test.tsx +13 -10
  14. package/src/components/ApplicationLauncher/__tests__/Generated/__snapshots__/ApplicationLauncherSeparator.test.tsx.snap +12 -1
  15. package/src/components/Button/__tests__/Button.test.tsx +116 -107
  16. package/src/components/Button/__tests__/__snapshots__/Button.test.tsx.snap +21 -21
  17. package/src/components/Card/__tests__/Card.test.tsx +119 -100
  18. package/src/components/Card/__tests__/CardBody.test.tsx +35 -28
  19. package/src/components/Card/__tests__/CardFooter.test.tsx +28 -24
  20. package/src/components/Card/__tests__/CardHeadMain.test.tsx +19 -14
  21. package/src/components/Card/__tests__/CardHeader.test.tsx +6 -22
  22. package/src/components/Card/__tests__/CardHeaderMain.test.tsx +19 -14
  23. package/src/components/Card/__tests__/CardTitle.test.tsx +25 -0
  24. package/src/components/Card/__tests__/__snapshots__/Card.test.tsx.snap +12 -28
  25. package/src/components/Card/__tests__/__snapshots__/CardBody.test.tsx.snap +2 -4
  26. package/src/components/Card/__tests__/__snapshots__/CardFooter.test.tsx.snap +1 -3
  27. package/src/components/Card/__tests__/__snapshots__/CardHeadMain.test.tsx.snap +1 -11
  28. package/src/components/Card/__tests__/__snapshots__/CardHeader.test.tsx.snap +1 -11
  29. package/src/components/Card/__tests__/__snapshots__/CardHeaderMain.test.tsx.snap +1 -11
  30. package/src/components/Card/__tests__/__snapshots__/CardTitle.test.tsx.snap +3 -0
  31. package/src/components/Checkbox/__tests__/Checkbox.test.tsx +66 -70
  32. package/src/components/Checkbox/__tests__/__snapshots__/Checkbox.test.tsx.snap +9 -204
  33. package/src/components/ClipboardCopy/examples/ClipboardCopy.md +11 -123
  34. package/src/components/ClipboardCopy/examples/ClipboardCopyBasic.tsx +8 -0
  35. package/src/components/ClipboardCopy/examples/ClipboardCopyExpanded.tsx +9 -0
  36. package/src/components/ClipboardCopy/examples/ClipboardCopyExpandedWithArray.tsx +14 -0
  37. package/src/components/ClipboardCopy/examples/ClipboardCopyInlineCompact.tsx +7 -0
  38. package/src/components/ClipboardCopy/examples/ClipboardCopyInlineCompactCode.tsx +8 -0
  39. package/src/components/ClipboardCopy/examples/ClipboardCopyInlineCompactInSentence.tsx +36 -0
  40. package/src/components/ClipboardCopy/examples/ClipboardCopyInlineCompactWithAdditionalAction.tsx +20 -0
  41. package/src/components/ClipboardCopy/examples/ClipboardCopyJSONObject.tsx +18 -0
  42. package/src/components/ClipboardCopy/examples/ClipboardCopyReadOnly.tsx +8 -0
  43. package/src/components/ClipboardCopy/examples/ClipboardCopyReadOnlyExpanded.tsx +9 -0
  44. package/src/components/ClipboardCopy/examples/ClipboardCopyReadOnlyExpandedByDefault.tsx +9 -0
@@ -1,87 +1,82 @@
1
1
  import * as React from 'react';
2
- import { render } from '@testing-library/react';
3
- import { mount, shallow } from 'enzyme';
2
+
3
+ import { render, screen } from '@testing-library/react';
4
+ import userEvent from '@testing-library/user-event';
5
+ import '@testing-library/jest-dom';
6
+
4
7
  import { Alert } from '../../Alert';
5
8
  import { AlertGroup } from '../../AlertGroup';
6
9
  import { AlertActionCloseButton } from '../../../components/Alert/AlertActionCloseButton';
7
10
 
8
- jest.spyOn(document, 'createElement');
9
- jest.spyOn(document.body, 'addEventListener');
11
+ describe('AlertGroup', () => {
12
+ test('Alert Group renders without children', () => {
13
+ const view = render(<AlertGroup />);
14
+ expect(view.container).toMatchSnapshot();
15
+ });
10
16
 
11
- test('Alert Group works with zero children', () => {
12
- const view = render(<AlertGroup></AlertGroup>);
13
- expect(view).toBeTruthy();
14
- });
17
+ test('Alert Group works with n children', () => {
18
+ const view = render(
19
+ <AlertGroup>
20
+ <Alert variant="success" title="alert title" />
21
+ <Alert variant="warning" title="another alert title" />
22
+ </AlertGroup>
23
+ );
24
+ expect(view).toBeTruthy();
25
+ });
15
26
 
16
- test('Alert Group should match snapshot', () => {
17
- const view = render(<AlertGroup></AlertGroup>);
18
- expect(view.container).toMatchSnapshot();
19
- });
27
+ test('Alert group overflow shows up', () => {
28
+ const overflowMessage = 'View 2 more alerts';
29
+ const onOverflowClick = jest.fn();
20
30
 
21
- test('Alert Group works with n children', () => {
22
- const view = render(
23
- <AlertGroup>
24
- <Alert variant="success" title="alert title" />
25
- <Alert variant="warning" title="another alert title" />
26
- </AlertGroup>
27
- );
28
- expect(view).toBeTruthy();
29
- });
31
+ render(
32
+ <AlertGroup overflowMessage={overflowMessage} onOverflowClick={onOverflowClick}>
33
+ <Alert variant="danger" title="alert title" />
34
+ </AlertGroup>
35
+ );
30
36
 
31
- test('Alert group overflow shows up', () => {
32
- const overflowMessage = "View 2 more alerts";
33
- const onOverflowClick = jest.fn();
34
- const wrapper = mount(
35
- <AlertGroup overflowMessage={overflowMessage} onOverflowClick={onOverflowClick}>
36
- <Alert variant="danger" title="alert title" />
37
- </AlertGroup>
38
- )
39
- expect(wrapper.find('.pf-c-alert-group > li')).toHaveLength(2);
40
- expect(wrapper.find('.pf-c-alert-group__overflow-button').text()).toContain(overflowMessage);
41
- expect(wrapper).toMatchSnapshot();
42
- wrapper.find('.pf-c-alert-group__overflow-button').simulate('click');
43
- expect(onOverflowClick).toBeCalled();
44
- });
37
+ expect(screen.getAllByRole('listitem')).toHaveLength(2);
45
38
 
46
- test('Standard Alert Group is not a toast alert group', () => {
47
- const wrapper = mount(
48
- <AlertGroup>
49
- <Alert variant="danger" title="alert title" />
50
- </AlertGroup>
51
- );
52
- expect(wrapper.find('.pf-c-alert-group.pf-m-toast')).toHaveLength(0);
53
- expect(wrapper).toMatchSnapshot();
54
- });
39
+ const overflowButton = screen.getByRole('button', { name: 'View 2 more alerts' });
40
+ expect(overflowButton).toBeInTheDocument();
55
41
 
56
- test('Toast Alert Group contains expected modifier class', () => {
57
- const wrapper = mount(
58
- <AlertGroup isToast>
59
- <Alert variant="warning" title="alert title" />
60
- </AlertGroup>
61
- );
62
- expect(wrapper.find('.pf-c-alert-group.pf-m-toast')).toHaveLength(1);
63
- expect(wrapper).toMatchSnapshot();
64
- });
42
+ userEvent.click(overflowButton);
43
+ expect(onOverflowClick).toBeCalled();
44
+ });
65
45
 
66
- test('Alert Group creates a container element once for div', () => {
67
- const view = shallow(<AlertGroup> Test About Modal </AlertGroup>);
68
- view.update();
69
- expect(document.createElement).toBeCalledWith('div');
70
- expect(document.createElement).toHaveBeenCalledTimes(1);
71
- });
46
+ test('Standard Alert Group is not a toast alert group', () => {
47
+ render(
48
+ <AlertGroup>
49
+ <Alert variant="danger" title="alert title" />
50
+ </AlertGroup>
51
+ );
52
+
53
+ expect(screen.getByText('alert title').parentElement).not.toHaveClass('pf-m-toast');
54
+ });
55
+
56
+ test('Toast Alert Group contains expected modifier class', () => {
57
+ render(
58
+ <AlertGroup isToast aria-label="group label">
59
+ <Alert variant="warning" title="alert title" />
60
+ </AlertGroup>
61
+ );
62
+
63
+ expect(screen.getByLabelText('group label')).toHaveClass('pf-m-toast');
64
+ });
65
+
66
+ test('alertgroup closes when alerts are closed', () => {
67
+ const onClose = jest.fn();
68
+
69
+ render(
70
+ <AlertGroup isToast appendTo={document.body}>
71
+ <Alert
72
+ isLiveRegion
73
+ title={'Test Alert'}
74
+ actionClose={<AlertActionCloseButton aria-label="Close" onClose={onClose} />}
75
+ />
76
+ </AlertGroup>
77
+ );
72
78
 
73
- test('alertgroup closes when alerts are closed', () => {
74
- const onClose = jest.fn();
75
- const wrapper = mount(
76
- <AlertGroup isToast appendTo={document.body}>
77
- <Alert
78
- isLiveRegion
79
- title={'Test Alert'}
80
- actionClose={<AlertActionCloseButton aria-label="Close" onClose={onClose} />}
81
- />
82
- </AlertGroup>
83
- );
84
- expect(wrapper).toMatchSnapshot();
85
- wrapper.find('button[aria-label="Close"]').simulate('click');
86
- expect(onClose).toBeCalled();
79
+ userEvent.click(screen.getByLabelText('Close'));
80
+ expect(onClose).toBeCalled();
81
+ });
87
82
  });