@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.
- package/CHANGELOG.md +24 -0
- package/dist/umd/react-core.css +2 -2
- package/dist/umd/react-core.min.css +221 -221
- package/package.json +6 -6
- package/src/components/AboutModal/__tests__/AboutModal.test.tsx +41 -60
- package/src/components/Accordion/__tests__/Accordion.test.tsx +23 -17
- package/src/components/Alert/__tests__/Alert.test.tsx +195 -184
- package/src/components/Alert/__tests__/Generated/AlertActionCloseButton.test.tsx +19 -17
- package/src/components/Alert/__tests__/Generated/__snapshots__/AlertActionCloseButton.test.tsx.snap +26 -4
- package/src/components/Alert/__tests__/__snapshots__/Alert.test.tsx.snap +50 -700
- package/src/components/AlertGroup/__tests__/AlertGroup.test.tsx +68 -73
- package/src/components/AlertGroup/__tests__/__snapshots__/AlertGroup.test.tsx.snap +1 -893
- package/src/components/ApplicationLauncher/__tests__/Generated/ApplicationLauncherSeparator.test.tsx +13 -10
- package/src/components/ApplicationLauncher/__tests__/Generated/__snapshots__/ApplicationLauncherSeparator.test.tsx.snap +12 -1
- package/src/components/Button/__tests__/Button.test.tsx +116 -107
- package/src/components/Button/__tests__/__snapshots__/Button.test.tsx.snap +21 -21
- package/src/components/Card/__tests__/Card.test.tsx +119 -100
- package/src/components/Card/__tests__/CardBody.test.tsx +35 -28
- package/src/components/Card/__tests__/CardFooter.test.tsx +28 -24
- package/src/components/Card/__tests__/CardHeadMain.test.tsx +19 -14
- package/src/components/Card/__tests__/CardHeader.test.tsx +6 -22
- package/src/components/Card/__tests__/CardHeaderMain.test.tsx +19 -14
- package/src/components/Card/__tests__/CardTitle.test.tsx +25 -0
- package/src/components/Card/__tests__/__snapshots__/Card.test.tsx.snap +12 -28
- package/src/components/Card/__tests__/__snapshots__/CardBody.test.tsx.snap +2 -4
- package/src/components/Card/__tests__/__snapshots__/CardFooter.test.tsx.snap +1 -3
- package/src/components/Card/__tests__/__snapshots__/CardHeadMain.test.tsx.snap +1 -11
- package/src/components/Card/__tests__/__snapshots__/CardHeader.test.tsx.snap +1 -11
- package/src/components/Card/__tests__/__snapshots__/CardHeaderMain.test.tsx.snap +1 -11
- package/src/components/Card/__tests__/__snapshots__/CardTitle.test.tsx.snap +3 -0
- package/src/components/Checkbox/__tests__/Checkbox.test.tsx +66 -70
- package/src/components/Checkbox/__tests__/__snapshots__/Checkbox.test.tsx.snap +9 -204
- package/src/components/ClipboardCopy/examples/ClipboardCopy.md +11 -123
- package/src/components/ClipboardCopy/examples/ClipboardCopyBasic.tsx +8 -0
- package/src/components/ClipboardCopy/examples/ClipboardCopyExpanded.tsx +9 -0
- package/src/components/ClipboardCopy/examples/ClipboardCopyExpandedWithArray.tsx +14 -0
- package/src/components/ClipboardCopy/examples/ClipboardCopyInlineCompact.tsx +7 -0
- package/src/components/ClipboardCopy/examples/ClipboardCopyInlineCompactCode.tsx +8 -0
- package/src/components/ClipboardCopy/examples/ClipboardCopyInlineCompactInSentence.tsx +36 -0
- package/src/components/ClipboardCopy/examples/ClipboardCopyInlineCompactWithAdditionalAction.tsx +20 -0
- package/src/components/ClipboardCopy/examples/ClipboardCopyJSONObject.tsx +18 -0
- package/src/components/ClipboardCopy/examples/ClipboardCopyReadOnly.tsx +8 -0
- package/src/components/ClipboardCopy/examples/ClipboardCopyReadOnlyExpanded.tsx +9 -0
- package/src/components/ClipboardCopy/examples/ClipboardCopyReadOnlyExpandedByDefault.tsx +9 -0
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import {
|
|
2
|
+
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import '@testing-library/jest-dom';
|
|
5
|
+
|
|
4
6
|
import { Accordion } from '../Accordion';
|
|
5
7
|
import { AccordionToggle } from '../AccordionToggle';
|
|
6
8
|
import { AccordionContent } from '../AccordionContent';
|
|
@@ -26,31 +28,34 @@ describe('Accordion', () => {
|
|
|
26
28
|
});
|
|
27
29
|
|
|
28
30
|
test('It should pass optional aria props', () => {
|
|
29
|
-
|
|
31
|
+
render(
|
|
30
32
|
<Accordion asDefinitionList>
|
|
31
33
|
<AccordionToggle aria-label="Toggle details for" aria-labelledby="ex-toggle2 ex-item2" id="ex-toggle2" />
|
|
32
34
|
</Accordion>
|
|
33
35
|
);
|
|
34
|
-
const button =
|
|
35
|
-
|
|
36
|
-
expect(button.
|
|
37
|
-
expect(button.
|
|
36
|
+
const button = screen.getByRole('button');
|
|
37
|
+
|
|
38
|
+
expect(button.getAttribute('aria-label')).toEqual('Toggle details for');
|
|
39
|
+
expect(button.getAttribute('aria-labelledby')).toEqual('ex-toggle2 ex-item2');
|
|
40
|
+
expect(button.getAttribute('aria-expanded')).toEqual('false');
|
|
38
41
|
});
|
|
39
42
|
|
|
40
43
|
test('Toggle expanded', () => {
|
|
41
|
-
|
|
44
|
+
render(
|
|
42
45
|
<Accordion asDefinitionList>
|
|
43
46
|
<AccordionToggle aria-label="Toggle details for" id="ex-toggle2" isExpanded />
|
|
44
47
|
</Accordion>
|
|
45
48
|
);
|
|
46
|
-
const button =
|
|
47
|
-
|
|
48
|
-
expect(button.
|
|
49
|
+
const button = screen.getByRole('button');
|
|
50
|
+
|
|
51
|
+
expect(button.getAttribute('aria-expanded')).toEqual('true');
|
|
52
|
+
expect(button.className).toContain('pf-m-expanded');
|
|
49
53
|
});
|
|
50
54
|
|
|
51
|
-
test('
|
|
55
|
+
test('renders content with custom Toggle and Content containers', () => {
|
|
52
56
|
const container = 'a';
|
|
53
|
-
|
|
57
|
+
|
|
58
|
+
const view = render(
|
|
54
59
|
<Accordion headingLevel="h2">
|
|
55
60
|
<AccordionItem>
|
|
56
61
|
<AccordionToggle id="item-1" component={container}>
|
|
@@ -60,8 +65,9 @@ describe('Accordion', () => {
|
|
|
60
65
|
</AccordionItem>
|
|
61
66
|
</Accordion>
|
|
62
67
|
);
|
|
63
|
-
|
|
64
|
-
expect(
|
|
68
|
+
|
|
69
|
+
expect(screen.getByText('Item One')).toBeInTheDocument();
|
|
70
|
+
expect(screen.getByText('Item One Content')).toBeInTheDocument();
|
|
65
71
|
});
|
|
66
72
|
|
|
67
73
|
test('Accordion bordered', () => {
|
|
@@ -78,7 +84,7 @@ describe('Accordion', () => {
|
|
|
78
84
|
|
|
79
85
|
test('Accordion display large', () => {
|
|
80
86
|
const view = render(
|
|
81
|
-
<Accordion displaySize=
|
|
87
|
+
<Accordion displaySize="large">
|
|
82
88
|
<AccordionItem>
|
|
83
89
|
<AccordionToggle id="item-1">Item One</AccordionToggle>
|
|
84
90
|
<AccordionContent>Item One Content</AccordionContent>
|
|
@@ -96,7 +102,7 @@ describe('Accordion', () => {
|
|
|
96
102
|
<AccordionContent isCustomContent>
|
|
97
103
|
<AccordionExpandedContentBody>Item one content body 1</AccordionExpandedContentBody>
|
|
98
104
|
<AccordionExpandedContentBody>Item one Content body 2</AccordionExpandedContentBody>
|
|
99
|
-
|
|
105
|
+
</AccordionContent>
|
|
100
106
|
</AccordionItem>
|
|
101
107
|
</Accordion>
|
|
102
108
|
);
|
|
@@ -1,197 +1,208 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
3
|
-
import
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
4
|
|
|
5
5
|
import { Alert, AlertVariant } from '../Alert';
|
|
6
6
|
import { AlertActionLink } from '../AlertActionLink';
|
|
7
7
|
import { AlertActionCloseButton } from '../AlertActionCloseButton';
|
|
8
8
|
import { UsersIcon } from '@patternfly/react-icons';
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
.childAt(0)
|
|
16
|
-
.prop('className')
|
|
17
|
-
).toContain('pf-c-alert');
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
Object.values(AlertVariant).forEach(variant => {
|
|
21
|
-
describe(`Alert - ${variant}`, () => {
|
|
22
|
-
test('Description', () => {
|
|
23
|
-
const view = render(
|
|
24
|
-
<Alert variant={variant} title="">
|
|
25
|
-
Some alert
|
|
26
|
-
</Alert>
|
|
27
|
-
);
|
|
28
|
-
expect(view.container).toMatchSnapshot();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
test('Title', () => {
|
|
32
|
-
const view = render(
|
|
33
|
-
<Alert variant={variant} title="Some title">
|
|
34
|
-
Some alert
|
|
35
|
-
</Alert>
|
|
36
|
-
);
|
|
37
|
-
expect(view.container).toMatchSnapshot();
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
test('Heading level', () => {
|
|
41
|
-
const view = render(
|
|
42
|
-
<Alert variant={variant} title="Some title" titleHeadingLevel="h1">
|
|
43
|
-
Some alert
|
|
44
|
-
</Alert>
|
|
45
|
-
);
|
|
46
|
-
expect(view.container).toMatchSnapshot();
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
test('Action Link', () => {
|
|
50
|
-
const view = render(
|
|
51
|
-
<Alert variant={variant} actionLinks={[<AlertActionLink key={'action-1'}>test</AlertActionLink>]} title="">
|
|
52
|
-
Some alert
|
|
53
|
-
</Alert>
|
|
54
|
-
);
|
|
55
|
-
expect(view.container).toMatchSnapshot();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
test('Action Close Button', () => {
|
|
59
|
-
const onClose = jest.fn();
|
|
60
|
-
const view = mount(
|
|
61
|
-
<Alert
|
|
62
|
-
variant={variant}
|
|
63
|
-
actionClose={<AlertActionCloseButton aria-label="Close" onClose={onClose} />}
|
|
64
|
-
title={`Sample ${variant} alert`}
|
|
65
|
-
>
|
|
66
|
-
Some alert
|
|
67
|
-
</Alert>
|
|
68
|
-
);
|
|
69
|
-
expect(view).toMatchSnapshot();
|
|
70
|
-
view.find('button[aria-label="Close"]').simulate('click');
|
|
71
|
-
expect(onClose).toHaveBeenCalled();
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
test('Action and Title', () => {
|
|
75
|
-
const view = render(
|
|
76
|
-
<Alert variant={variant} actionLinks={[<AlertActionLink key={'action-1'}>test</AlertActionLink>]} title="Some title">
|
|
77
|
-
Some alert
|
|
78
|
-
</Alert>
|
|
79
|
-
);
|
|
80
|
-
expect(view.container).toMatchSnapshot();
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
test('Custom aria label', () => {
|
|
84
|
-
const view = render(
|
|
85
|
-
<Alert
|
|
86
|
-
variant={variant}
|
|
87
|
-
aria-label={`Custom aria label for ${variant}`}
|
|
88
|
-
actionLinks={[<AlertActionLink key={'action-1'}>test</AlertActionLink>]}
|
|
89
|
-
title="Some title"
|
|
90
|
-
>
|
|
91
|
-
Some alert
|
|
92
|
-
</Alert>
|
|
93
|
-
);
|
|
94
|
-
expect(view.container).toMatchSnapshot();
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
test('inline variation', () => {
|
|
98
|
-
const view = render(
|
|
99
|
-
<Alert variant={variant} isInline title="Some title">
|
|
100
|
-
Some alert
|
|
101
|
-
</Alert>
|
|
102
|
-
);
|
|
103
|
-
expect(view.container).toMatchSnapshot();
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
test('expandable variation', () => {
|
|
107
|
-
const view = render(
|
|
108
|
-
<Alert variant={variant} title="Some title" isExpandable>
|
|
109
|
-
<p>Success alert description. This should tell the user more information about the alert.</p>
|
|
110
|
-
</Alert>
|
|
111
|
-
)
|
|
112
|
-
expect(view.container).toMatchSnapshot();
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
test('expandable variation description hidden', () => {
|
|
116
|
-
const wrapper = mount(
|
|
117
|
-
<Alert variant={variant} title="Some title" isExpandable>
|
|
118
|
-
<p>Success alert description. This should tell the user more information about the alert.</p>
|
|
119
|
-
</Alert>
|
|
120
|
-
)
|
|
121
|
-
const descriptionExists = wrapper.find('.pf-c-alert__description').exists();
|
|
122
|
-
expect(descriptionExists).toBeFalsy();
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
test('Toast alerts match snapsnot', () => {
|
|
126
|
-
const view = render(
|
|
127
|
-
<Alert isLiveRegion={true} variant={variant} aria-label={`${variant} toast alert`} title="Some title">
|
|
128
|
-
Some toast alert
|
|
129
|
-
</Alert>
|
|
130
|
-
);
|
|
131
|
-
expect(view.container).toMatchSnapshot();
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
test('Toast alerts contain default live region', () => {
|
|
135
|
-
const wrapper = mount(
|
|
136
|
-
<Alert isLiveRegion={true} variant={variant} aria-label={`${variant} toast alert`} title="Some title">
|
|
137
|
-
Some toast alert
|
|
138
|
-
</Alert>
|
|
139
|
-
);
|
|
140
|
-
const liveRegion = wrapper.find({ 'aria-live': 'polite' }).length;
|
|
141
|
-
expect(liveRegion).toBe(1);
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
test('Toast alert live regions are not atomic', () => {
|
|
145
|
-
const wrapper = mount(
|
|
146
|
-
<Alert isLiveRegion={true} variant={variant} aria-label={`${variant} toast alert`} title="Some title">
|
|
147
|
-
Some toast alert
|
|
148
|
-
</Alert>
|
|
149
|
-
);
|
|
150
|
-
expect(wrapper.find('.pf-c-alert').prop('aria-atomic')).toBe('false');
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
test('Non-toast alerts can have custom live region settings', () => {
|
|
154
|
-
const wrapper = mount(
|
|
155
|
-
<Alert
|
|
156
|
-
aria-live="assertive"
|
|
157
|
-
aria-relevant="all"
|
|
158
|
-
aria-atomic="true"
|
|
159
|
-
variant={variant}
|
|
160
|
-
aria-label={`${variant} toast alert`}
|
|
161
|
-
title="Some title"
|
|
162
|
-
>
|
|
163
|
-
Some noisy alert
|
|
164
|
-
</Alert>
|
|
165
|
-
);
|
|
166
|
-
const alert = wrapper.find(Alert);
|
|
167
|
-
|
|
168
|
-
expect(alert.prop('aria-live')).toBe('assertive');
|
|
169
|
-
expect(alert.prop('aria-relevant')).toBe('all');
|
|
170
|
-
expect(alert.prop('aria-atomic')).toBe('true');
|
|
171
|
-
});
|
|
10
|
+
describe('Alert', () => {
|
|
11
|
+
test('default Alert variant is default', () => {
|
|
12
|
+
render(<Alert title="this is a test">Alert testing</Alert>);
|
|
13
|
+
expect(screen.getByText('this is a test').className).toContain('pf-c-alert');
|
|
14
|
+
});
|
|
172
15
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
variant={variant}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
16
|
+
Object.values(AlertVariant).forEach(variant => {
|
|
17
|
+
describe(`Alert - ${variant}`, () => {
|
|
18
|
+
test('Description', () => {
|
|
19
|
+
const view = render(
|
|
20
|
+
<Alert variant={variant} title="">
|
|
21
|
+
Some alert
|
|
22
|
+
</Alert>
|
|
23
|
+
);
|
|
24
|
+
expect(view.container).toMatchSnapshot();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test('Title', () => {
|
|
28
|
+
const view = render(
|
|
29
|
+
<Alert variant={variant} title="Some title">
|
|
30
|
+
Some alert
|
|
31
|
+
</Alert>
|
|
32
|
+
);
|
|
33
|
+
expect(view.container).toMatchSnapshot();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test('Heading level', () => {
|
|
37
|
+
const view = render(
|
|
38
|
+
<Alert variant={variant} title="Some title" titleHeadingLevel="h1">
|
|
39
|
+
Some alert
|
|
40
|
+
</Alert>
|
|
41
|
+
);
|
|
42
|
+
expect(view.container).toMatchSnapshot();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test('Action Link', () => {
|
|
46
|
+
const view = render(
|
|
47
|
+
<Alert variant={variant} actionLinks={[<AlertActionLink key={'action-1'}>test</AlertActionLink>]} title="">
|
|
48
|
+
Some alert
|
|
49
|
+
</Alert>
|
|
50
|
+
);
|
|
51
|
+
expect(view.container).toMatchSnapshot();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('Action Close Button', () => {
|
|
55
|
+
const onClose = jest.fn();
|
|
56
|
+
|
|
57
|
+
render(
|
|
58
|
+
<Alert
|
|
59
|
+
variant={variant}
|
|
60
|
+
actionClose={<AlertActionCloseButton aria-label="Close" onClose={onClose} />}
|
|
61
|
+
title={`Sample ${variant} alert`}
|
|
62
|
+
>
|
|
63
|
+
Some alert
|
|
64
|
+
</Alert>
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
userEvent.click(screen.getByLabelText('Close'));
|
|
68
|
+
expect(onClose).toHaveBeenCalled();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test('Action and Title', () => {
|
|
72
|
+
const view = render(
|
|
73
|
+
<Alert
|
|
74
|
+
variant={variant}
|
|
75
|
+
actionLinks={[<AlertActionLink key={'action-1'}>test</AlertActionLink>]}
|
|
76
|
+
title="Some title"
|
|
77
|
+
>
|
|
78
|
+
Some alert
|
|
79
|
+
</Alert>
|
|
80
|
+
);
|
|
81
|
+
expect(view.container).toMatchSnapshot();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
test('Custom aria label', () => {
|
|
85
|
+
const view = render(
|
|
86
|
+
<Alert
|
|
87
|
+
variant={variant}
|
|
88
|
+
aria-label={`Custom aria label for ${variant}`}
|
|
89
|
+
actionLinks={[<AlertActionLink key={'action-1'}>test</AlertActionLink>]}
|
|
90
|
+
title="Some title"
|
|
91
|
+
>
|
|
92
|
+
Some alert
|
|
93
|
+
</Alert>
|
|
94
|
+
);
|
|
95
|
+
expect(view.container).toMatchSnapshot();
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test('inline variation', () => {
|
|
99
|
+
const view = render(
|
|
100
|
+
<Alert variant={variant} isInline title="Some title">
|
|
101
|
+
Some alert
|
|
102
|
+
</Alert>
|
|
103
|
+
);
|
|
104
|
+
expect(view.container).toMatchSnapshot();
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test('expandable variation', () => {
|
|
108
|
+
const view = render(
|
|
109
|
+
<Alert variant={variant} title="Some title" isExpandable>
|
|
110
|
+
<p>Success alert description. This should tell the user more information about the alert.</p>
|
|
111
|
+
</Alert>
|
|
112
|
+
);
|
|
113
|
+
expect(view.container).toMatchSnapshot();
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
test('expandable variation description hidden', () => {
|
|
117
|
+
const description = 'Success alert description.';
|
|
118
|
+
|
|
119
|
+
render(
|
|
120
|
+
<Alert variant={variant} title="Some title" isExpandable>
|
|
121
|
+
<p>{description}</p>
|
|
122
|
+
</Alert>
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
expect(screen.queryByText(description)).toBeNull();
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
test('Toast alerts match snapsnot', () => {
|
|
129
|
+
const view = render(
|
|
130
|
+
<Alert isLiveRegion={true} variant={variant} aria-label={`${variant} toast alert`} title="Some title">
|
|
131
|
+
Some toast alert
|
|
132
|
+
</Alert>
|
|
133
|
+
);
|
|
134
|
+
expect(view.container).toMatchSnapshot();
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
test('Toast alerts contain default live region', () => {
|
|
138
|
+
const ariaLabel = `${variant} toast alert`;
|
|
139
|
+
|
|
140
|
+
render(
|
|
141
|
+
<Alert isLiveRegion={true} variant={variant} aria-label={ariaLabel} title="Some title">
|
|
142
|
+
Some toast alert
|
|
143
|
+
</Alert>
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
expect(screen.getByLabelText(ariaLabel).getAttribute('aria-live')).toEqual('polite');
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
test('Toast alert live regions are not atomic', () => {
|
|
150
|
+
const ariaLabel = `${variant} toast alert`;
|
|
151
|
+
|
|
152
|
+
render(
|
|
153
|
+
<Alert isLiveRegion={true} variant={variant} aria-label={ariaLabel} title="Some title">
|
|
154
|
+
Some toast alert
|
|
155
|
+
</Alert>
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
expect(screen.getByLabelText(ariaLabel).getAttribute('aria-atomic')).toEqual('false');
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
test('Non-toast alerts can have custom live region settings', () => {
|
|
162
|
+
const ariaLabel = `${variant} toast alert`;
|
|
163
|
+
|
|
164
|
+
render(
|
|
165
|
+
<Alert
|
|
166
|
+
aria-live="assertive"
|
|
167
|
+
aria-relevant="all"
|
|
168
|
+
aria-atomic="true"
|
|
169
|
+
variant={variant}
|
|
170
|
+
aria-label={ariaLabel}
|
|
171
|
+
title="Some title"
|
|
172
|
+
>
|
|
173
|
+
Some noisy alert
|
|
174
|
+
</Alert>
|
|
175
|
+
);
|
|
176
|
+
const alert = screen.getByLabelText(ariaLabel);
|
|
177
|
+
|
|
178
|
+
expect(alert.getAttribute('aria-live')).toEqual('assertive');
|
|
179
|
+
expect(alert.getAttribute('aria-relevant')).toEqual('all');
|
|
180
|
+
expect(alert.getAttribute('aria-atomic')).toEqual('true');
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
test('Custom icon', () => {
|
|
184
|
+
const view = render(
|
|
185
|
+
<Alert
|
|
186
|
+
customIcon={<UsersIcon />}
|
|
187
|
+
variant={variant}
|
|
188
|
+
aria-label={`${variant} custom icon alert`}
|
|
189
|
+
title="custom icon alert title"
|
|
190
|
+
>
|
|
191
|
+
Some noisy alert
|
|
192
|
+
</Alert>
|
|
193
|
+
);
|
|
194
|
+
expect(view.container).toMatchSnapshot();
|
|
195
|
+
});
|
|
185
196
|
});
|
|
186
197
|
});
|
|
187
|
-
});
|
|
188
198
|
|
|
199
|
+
test('Alert truncate title', () => {
|
|
200
|
+
render(
|
|
201
|
+
<Alert truncateTitle={1} title="this is a test">
|
|
202
|
+
Alert testing
|
|
203
|
+
</Alert>
|
|
204
|
+
);
|
|
189
205
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
expect(
|
|
193
|
-
view
|
|
194
|
-
.find('h4')
|
|
195
|
-
.prop('className')
|
|
196
|
-
).toContain('pf-m-truncate');
|
|
206
|
+
expect(screen.getByText('this is a test').className).toContain('pf-m-truncate');
|
|
207
|
+
});
|
|
197
208
|
});
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { shallow } from 'enzyme';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { render } from '@testing-library/react';
|
|
4
|
+
|
|
6
5
|
import { AlertActionCloseButton } from '../../AlertActionCloseButton';
|
|
7
|
-
|
|
8
|
-
import {} from '../..';
|
|
6
|
+
import { AlertContext } from '../../AlertContext';
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
describe('AlertActionCloseButton', () => {
|
|
9
|
+
it('should match snapshot', () => {
|
|
10
|
+
const view = render(
|
|
11
|
+
<AlertContext.Provider value={{ title: 'test title', variantLabel: 'some label' }}>
|
|
12
|
+
<AlertActionCloseButton
|
|
13
|
+
className=""
|
|
14
|
+
onClose={() => console.log('close clicked')}
|
|
15
|
+
aria-label=""
|
|
16
|
+
variantLabel=""
|
|
17
|
+
/>
|
|
18
|
+
</AlertContext.Provider>
|
|
19
|
+
);
|
|
20
|
+
expect(view.container).toMatchSnapshot();
|
|
21
|
+
});
|
|
20
22
|
});
|
package/src/components/Alert/__tests__/Generated/__snapshots__/AlertActionCloseButton.test.tsx.snap
CHANGED
|
@@ -1,7 +1,29 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`AlertActionCloseButton should match snapshot
|
|
4
|
-
<
|
|
5
|
-
<
|
|
6
|
-
|
|
3
|
+
exports[`AlertActionCloseButton should match snapshot 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<button
|
|
6
|
+
aria-disabled="false"
|
|
7
|
+
aria-label="Close some label alert: test title"
|
|
8
|
+
class="pf-c-button pf-m-plain"
|
|
9
|
+
data-ouia-component-id="OUIA-Generated-Button-plain-1"
|
|
10
|
+
data-ouia-component-type="PF4/Button"
|
|
11
|
+
data-ouia-safe="true"
|
|
12
|
+
type="button"
|
|
13
|
+
>
|
|
14
|
+
<svg
|
|
15
|
+
aria-hidden="true"
|
|
16
|
+
fill="currentColor"
|
|
17
|
+
height="1em"
|
|
18
|
+
role="img"
|
|
19
|
+
style="vertical-align: -0.125em;"
|
|
20
|
+
viewBox="0 0 352 512"
|
|
21
|
+
width="1em"
|
|
22
|
+
>
|
|
23
|
+
<path
|
|
24
|
+
d="M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z"
|
|
25
|
+
/>
|
|
26
|
+
</svg>
|
|
27
|
+
</button>
|
|
28
|
+
</div>
|
|
7
29
|
`;
|