@patternfly/react-core 4.260.0 → 4.261.0

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 +19 -0
  2. package/dist/esm/components/MultipleFileUpload/MultipleFileUploadStatusItem.d.ts +2 -0
  3. package/dist/esm/components/MultipleFileUpload/MultipleFileUploadStatusItem.d.ts.map +1 -1
  4. package/dist/esm/components/MultipleFileUpload/MultipleFileUploadStatusItem.js +4 -2
  5. package/dist/esm/components/MultipleFileUpload/MultipleFileUploadStatusItem.js.map +1 -1
  6. package/dist/esm/components/Text/TextList.js +1 -1
  7. package/dist/esm/components/Text/TextList.js.map +1 -1
  8. package/dist/esm/components/Text/TextListItem.js +1 -1
  9. package/dist/esm/components/Text/TextListItem.js.map +1 -1
  10. package/dist/esm/components/Text/__tests__/TextContent.text.d.ts +2 -0
  11. package/dist/esm/components/Text/__tests__/TextContent.text.d.ts.map +1 -0
  12. package/dist/esm/components/Text/__tests__/TextContent.text.js +37 -0
  13. package/dist/esm/components/Text/__tests__/TextContent.text.js.map +1 -0
  14. package/dist/js/components/MultipleFileUpload/MultipleFileUploadStatusItem.d.ts +2 -0
  15. package/dist/js/components/MultipleFileUpload/MultipleFileUploadStatusItem.d.ts.map +1 -1
  16. package/dist/js/components/MultipleFileUpload/MultipleFileUploadStatusItem.js +4 -2
  17. package/dist/js/components/MultipleFileUpload/MultipleFileUploadStatusItem.js.map +1 -1
  18. package/dist/js/components/Text/TextList.js +1 -1
  19. package/dist/js/components/Text/TextList.js.map +1 -1
  20. package/dist/js/components/Text/TextListItem.js +1 -1
  21. package/dist/js/components/Text/TextListItem.js.map +1 -1
  22. package/dist/js/components/Text/__tests__/TextContent.text.d.ts +2 -0
  23. package/dist/js/components/Text/__tests__/TextContent.text.d.ts.map +1 -0
  24. package/dist/js/components/Text/__tests__/TextContent.text.js +40 -0
  25. package/dist/js/components/Text/__tests__/TextContent.text.js.map +1 -0
  26. package/dist/umd/react-core.min.css +2186 -2186
  27. package/dist/umd/react-core.min.js +1 -1
  28. package/package.json +2 -2
  29. package/src/components/MultipleFileUpload/MultipleFileUploadStatusItem.tsx +9 -2
  30. package/src/components/MultipleFileUpload/__tests__/MultipleFileUploadStatusItem.test.tsx +35 -0
  31. package/src/components/MultipleFileUpload/examples/MultipleFileUpload.md +6 -0
  32. package/src/components/MultipleFileUpload/examples/MultipleFileUploadBasic.tsx +35 -2
  33. package/src/components/Text/TextList.tsx +1 -1
  34. package/src/components/Text/TextListItem.tsx +1 -1
  35. package/src/components/Text/__tests__/Generated/__snapshots__/TextList.test.tsx.snap +0 -1
  36. package/src/components/Text/__tests__/Generated/__snapshots__/TextListItem.test.tsx.snap +0 -1
  37. package/src/components/Text/__tests__/Text.test.tsx +98 -109
  38. package/src/components/Text/__tests__/TextContent.text.tsx +47 -0
  39. package/src/components/Text/__tests__/TextList.test.tsx +52 -0
  40. package/src/components/Text/__tests__/TextListItem.test.tsx +52 -0
  41. package/src/components/Text/__tests__/__snapshots__/Text.test.tsx.snap +9 -328
  42. package/src/components/Text/__tests__/__snapshots__/TextContent.text.tsx.snap +11 -0
  43. package/src/components/Text/__tests__/__snapshots__/TextList.test.tsx.snap +11 -0
  44. package/src/components/Text/__tests__/__snapshots__/TextListItem.test.tsx.snap +11 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "4.260.0",
3
+ "version": "4.261.0",
4
4
  "description": "This library provides a set of common React components for use with the PatternFly reference implementation.",
5
5
  "main": "dist/js/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -70,5 +70,5 @@
70
70
  "react": "^16.8 || ^17 || ^18",
71
71
  "react-dom": "^16.8 || ^17 || ^18"
72
72
  },
73
- "gitHead": "8d5d8dc62afaae1e70567b802bf617bf73df36a4"
73
+ "gitHead": "5d1af989ad4a302d1fa53c4658f033ad0fa1abef"
74
74
  }
@@ -54,6 +54,8 @@ export interface MultipleFileUploadStatusItemProps extends React.HTMLProps<HTMLL
54
54
  progressAriaLiveMessage?: string | ((loadPercentage: number) => string);
55
55
  /** Unique identifier for progress. Generated if not specified. */
56
56
  progressId?: string;
57
+ /** @beta Additional content related to the status item. */
58
+ progressHelperText?: React.ReactNode;
57
59
  }
58
60
 
59
61
  export const MultipleFileUploadStatusItem: React.FunctionComponent<MultipleFileUploadStatusItemProps> = ({
@@ -75,6 +77,7 @@ export const MultipleFileUploadStatusItem: React.FunctionComponent<MultipleFileU
75
77
  progressId,
76
78
  progressAriaLiveMessage,
77
79
  buttonAriaLabel = 'Remove from list',
80
+ progressHelperText,
78
81
  ...props
79
82
  }: MultipleFileUploadStatusItemProps) => {
80
83
  const [loadPercentage, setLoadPercentage] = React.useState(0);
@@ -129,6 +132,9 @@ export const MultipleFileUploadStatusItem: React.FunctionComponent<MultipleFileU
129
132
  return `${Math.round(size)}${prefixes[prefixUnit]}B`;
130
133
  };
131
134
 
135
+ const value = progressValue || loadPercentage;
136
+ const variant = progressVariant || loadResult;
137
+
132
138
  const title = (
133
139
  <span className={styles.multipleFileUploadStatusItemProgress}>
134
140
  <span className={styles.multipleFileUploadStatusItemProgressText}>{fileName || file?.name || ''}</span>
@@ -151,11 +157,12 @@ export const MultipleFileUploadStatusItem: React.FunctionComponent<MultipleFileU
151
157
  </div>
152
158
  <Progress
153
159
  title={title}
154
- value={progressValue || loadPercentage}
155
- variant={progressVariant || loadResult}
160
+ value={value}
161
+ variant={variant}
156
162
  aria-label={progressAriaLabel}
157
163
  aria-labelledby={progressAriaLabelledBy}
158
164
  id={progressId}
165
+ helperText={progressHelperText}
159
166
  />
160
167
  </div>
161
168
  <div className={styles.multipleFileUploadStatusItemClose}>
@@ -99,3 +99,38 @@ describe('MultipleFileUploadStatusItem', () => {
99
99
  expect(asFragment()).toMatchSnapshot();
100
100
  });
101
101
  });
102
+
103
+ test('does not render helper text by default', () => {
104
+ const testFile = new File(['foo'], 'testFile.txt');
105
+ render(
106
+ <MultipleFileUploadStatusItem
107
+ file={testFile}
108
+ buttonAriaLabel="buttonAriaLabel"
109
+ progressAriaLabel="progressAriaLabel"
110
+ progressAriaLabelledBy="progressAriaLabelledBy"
111
+ progressId="test-progress-id"
112
+ />
113
+ );
114
+
115
+ const helperText = screen.queryByText('Test helper text');
116
+
117
+ expect(helperText).not.toBeInTheDocument();
118
+ });
119
+
120
+ test('renders helper text', () => {
121
+ const testFile = new File(['foo'], 'testFile.txt');
122
+ render(
123
+ <MultipleFileUploadStatusItem
124
+ file={testFile}
125
+ buttonAriaLabel="buttonAriaLabel"
126
+ progressAriaLabel="progressAriaLabel"
127
+ progressAriaLabelledBy="progressAriaLabelledBy"
128
+ progressId="test-progress-id"
129
+ progressHelperText="Test helper text"
130
+ />
131
+ );
132
+
133
+ const helperText = screen.getByText('Test helper text');
134
+
135
+ expect(helperText).toBeVisible();
136
+ });
@@ -42,5 +42,11 @@ File upload - multiple is designed in a composable manner to make customization
42
42
 
43
43
  ### Basic
44
44
 
45
+ The below example demonstrates a typical application of file upload - multiple, with a few tweaks from that typical application to enhance the convenience of the example.
46
+
47
+ The "Show as horizontal" checkbox can be used to easily toggle the `isHorizontal` prop, showing our available styling variations.
48
+
49
+ The "Demonstrate error reporting by forcing uploads to fail" checkbox shows how our `progressHelperText` prop can be used to provide status messages to users, such as when a file fails to upload. While this checkbox is checked it will cause any file uploaded to automatically fail the file reading process, and helper text will be dynamically rendered which informs the user of that error.
50
+
45
51
  ```ts file="./MultipleFileUploadBasic.tsx"
46
52
  ```
@@ -4,7 +4,9 @@ import {
4
4
  MultipleFileUploadMain,
5
5
  MultipleFileUploadStatus,
6
6
  MultipleFileUploadStatusItem,
7
- Checkbox
7
+ Checkbox,
8
+ HelperText,
9
+ HelperTextItem
8
10
  } from '@patternfly/react-core';
9
11
  import UploadIcon from '@patternfly/react-icons/dist/esm/icons/upload-icon';
10
12
 
@@ -17,6 +19,7 @@ interface readFile {
17
19
 
18
20
  export const MultipleFileUploadBasic: React.FunctionComponent = () => {
19
21
  const [isHorizontal, setIsHorizontal] = React.useState(false);
22
+ const [fileUploadShouldFail, setFileUploadShouldFail] = React.useState(false);
20
23
  const [currentFiles, setCurrentFiles] = React.useState<File[]>([]);
21
24
  const [readFileData, setReadFileData] = React.useState<readFile[]>([]);
22
25
  const [showStatus, setShowStatus] = React.useState(false);
@@ -53,6 +56,17 @@ export const MultipleFileUploadBasic: React.FunctionComponent = () => {
53
56
  setReadFileData(newReadFiles);
54
57
  };
55
58
 
59
+ /** Forces uploaded files to become corrupted if "Demonstrate error reporting by forcing uploads to fail" is selected in the example,
60
+ * only used in this example for demonstration purposes */
61
+ const updateCurrentFiles = (files: File[]) => {
62
+ if (fileUploadShouldFail) {
63
+ const corruptedFiles = files.map(file => ({ ...file, lastModified: ('foo' as unknown) as number }));
64
+ setCurrentFiles(prevFiles => [...prevFiles, ...corruptedFiles]);
65
+ } else {
66
+ setCurrentFiles(prevFiles => [...prevFiles, ...files]);
67
+ }
68
+ };
69
+
56
70
  // callback that will be called by the react dropzone with the newly dropped file objects
57
71
  const handleFileDrop = (droppedFiles: File[]) => {
58
72
  // identify what, if any, files are re-uploads of already uploaded files
@@ -63,7 +77,7 @@ export const MultipleFileUploadBasic: React.FunctionComponent = () => {
63
77
  * won't realize that the status items for the re-uploaded files needs to be re-rendered */
64
78
  Promise.resolve()
65
79
  .then(() => removeFiles(reUploads.map(file => file.name)))
66
- .then(() => setCurrentFiles(prevFiles => [...prevFiles, ...droppedFiles]));
80
+ .then(() => updateCurrentFiles(droppedFiles));
67
81
  };
68
82
 
69
83
  // callback called by the status item when a file is successfully read with the built-in file reader
@@ -79,6 +93,18 @@ export const MultipleFileUploadBasic: React.FunctionComponent = () => {
79
93
  ]);
80
94
  };
81
95
 
96
+ // add helper text to a status item showing any error encountered during the file reading process
97
+ const createHelperText = (file: File) => {
98
+ const fileResult = readFileData.find(readFile => readFile.fileName === file.name);
99
+ if (fileResult?.loadError) {
100
+ return (
101
+ <HelperText isLiveRegion>
102
+ <HelperTextItem variant={'error'}>{fileResult.loadError.toString()}</HelperTextItem>
103
+ </HelperText>
104
+ );
105
+ }
106
+ };
107
+
82
108
  const successfullyReadFileCount = readFileData.filter(fileData => fileData.loadResult === 'success').length;
83
109
 
84
110
  return (
@@ -108,6 +134,7 @@ export const MultipleFileUploadBasic: React.FunctionComponent = () => {
108
134
  onClearClick={() => removeFiles([file.name])}
109
135
  onReadSuccess={handleReadSuccess}
110
136
  onReadFail={handleReadFail}
137
+ progressHelperText={createHelperText(file)}
111
138
  />
112
139
  ))}
113
140
  </MultipleFileUploadStatus>
@@ -119,6 +146,12 @@ export const MultipleFileUploadBasic: React.FunctionComponent = () => {
119
146
  isChecked={isHorizontal}
120
147
  onChange={() => setIsHorizontal(!isHorizontal)}
121
148
  />
149
+ <Checkbox
150
+ id="upload-should-fail-checkbox"
151
+ label="Demonstrate error reporting by forcing uploads to fail"
152
+ isChecked={fileUploadShouldFail}
153
+ onChange={() => setFileUploadShouldFail(!fileUploadShouldFail)}
154
+ />
122
155
  </>
123
156
  );
124
157
  };
@@ -25,7 +25,7 @@ export const TextList: React.FunctionComponent<TextListProps> = ({
25
25
  const Component: any = component;
26
26
 
27
27
  return (
28
- <Component {...props} data-pf-content className={css(className)}>
28
+ <Component {...props} className={css(className)}>
29
29
  {children}
30
30
  </Component>
31
31
  );
@@ -25,7 +25,7 @@ export const TextListItem: React.FunctionComponent<TextListItemProps> = ({
25
25
  const Component: any = component;
26
26
 
27
27
  return (
28
- <Component {...props} data-pf-content className={css(className)}>
28
+ <Component {...props} className={css(className)}>
29
29
  {children}
30
30
  </Component>
31
31
  );
@@ -4,7 +4,6 @@ exports[`TextList should match snapshot (auto-generated) 1`] = `
4
4
  <DocumentFragment>
5
5
  <ul
6
6
  class="''"
7
- data-pf-content="true"
8
7
  >
9
8
  ReactNode
10
9
  </ul>
@@ -4,7 +4,6 @@ exports[`TextListItem should match snapshot (auto-generated) 1`] = `
4
4
  <DocumentFragment>
5
5
  <li
6
6
  class="''"
7
- data-pf-content="true"
8
7
  >
9
8
  ReactNode
10
9
  </li>
@@ -1,112 +1,101 @@
1
- import React from 'react';
2
- import { render } from '@testing-library/react';
3
- import { TextContent } from '../TextContent';
4
- import { Text, TextVariants } from '../Text';
5
- import { TextList, TextListVariants } from '../TextList';
6
- import { TextListItem, TextListItemVariants } from '../TextListItem';
7
-
8
- test('Text example should match snapshot', () => {
9
- const { asFragment } = render(
10
- <TextContent>
11
- <Text component={TextVariants.h1}>Hello World</Text>
12
- <Text component={TextVariants.p}>
13
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla accumsan, metus ultrices eleifend gravida, nulla
14
- nunc varius lectus, nec rutrum justo nibh eu lectus. Ut vulputate semper dui. Fusce erat odio, sollicitudin vel
15
- erat vel, interdum mattis neque. Sub works as well!
16
- </Text>
17
- <Text component={TextVariants.h2}>Second level</Text>
18
- <Text component={TextVariants.p}>
19
- Curabitur accumsan turpis pharetra <strong>augue tincidunt</strong> blandit. Quisque condimentum maximus mi, sit
20
- amet commodo arcu rutrum id. Proin pretium urna vel cursus venenatis. Suspendisse potenti. Etiam mattis sem
21
- rhoncus lacus dapibus facilisis. Donec at dignissim dui. Ut et neque nisl.
22
- </Text>
23
- <TextList>
24
- <TextListItem>In fermentum leo eu lectus mollis, quis dictum mi aliquet.</TextListItem>
25
- <TextListItem>Morbi eu nulla lobortis, lobortis est in, fringilla felis.</TextListItem>
26
- <TextListItem>
27
- Aliquam nec felis in sapien venenatis viverra fermentum nec lectus.
28
- <TextList>
29
- <TextListItem>In fermentum leo eu lectus mollis, quis dictum mi aliquet.</TextListItem>
30
- <TextListItem>Morbi eu nulla lobortis, lobortis est in, fringilla felis.</TextListItem>
31
- </TextList>
32
- </TextListItem>
33
- <TextListItem>Ut non enim metus.</TextListItem>
34
- </TextList>
35
- <Text component={TextVariants.h3}>Third level</Text>
36
- <Text component={TextVariants.p}>
37
- Quisque ante lacus, malesuada ac auctor vitae, congue{' '}
38
- <Text component={TextVariants.a} href="#">
39
- non ante
40
- </Text>
41
- . Phasellus lacus ex, semper ac tortor nec, fringilla condimentum orci. Fusce eu rutrum tellus.
42
- </Text>
43
- <TextList component={TextListVariants.ol}>
44
- <TextListItem>Donec blandit a lorem id convallis.</TextListItem>
45
- <TextListItem>Cras gravida arcu at diam gravida gravida.</TextListItem>
46
- <TextListItem>Integer in volutpat libero.</TextListItem>
47
- <TextListItem>Donec a diam tellus.</TextListItem>
48
- <TextListItem>Aenean nec tortor orci.</TextListItem>
49
- <TextListItem>Quisque aliquam cursus urna, non bibendum massa viverra eget.</TextListItem>
50
- <TextListItem>Vivamus maximus ultricies pulvinar.</TextListItem>
51
- </TextList>
52
- <Text component={TextVariants.blockquote}>
53
- Ut venenatis, nisl scelerisque sollicitudin fermentum, quam libero hendrerit ipsum, ut blandit est tellus sit
54
- amet turpis.
55
- </Text>
56
- <Text component={TextVariants.p}>
57
- Quisque at semper enim, eu hendrerit odio. Etiam auctor nisl et <em>justo sodales</em> elementum. Maecenas
58
- ultrices lacus quis neque consectetur, et lobortis nisi molestie.
59
- </Text>
60
- <Text component={TextVariants.p}>
61
- Sed sagittis enim ac tortor maximus rutrum. Nulla facilisi. Donec mattis vulputate risus in luctus. Maecenas
62
- vestibulum interdum commodo.
63
- </Text>
64
- <TextList component={TextListVariants.dl}>
65
- <TextListItem component={TextListItemVariants.dt}>Web</TextListItem>
66
- <TextListItem component={TextListItemVariants.dd}>
67
- The part of the Internet that contains websites and web pages
68
- </TextListItem>
69
- <TextListItem component={TextListItemVariants.dt}>HTML</TextListItem>
70
- <TextListItem component={TextListItemVariants.dd}>A markup language for creating web pages</TextListItem>
71
- <TextListItem component={TextListItemVariants.dt}>CSS</TextListItem>
72
- <TextListItem component={TextListItemVariants.dd}>A technology to make HTML look better</TextListItem>
73
- </TextList>
74
- <Text component={TextVariants.p}>
75
- Suspendisse egestas sapien non felis placerat elementum. Morbi tortor nisl, suscipit sed mi sit amet, mollis
76
- malesuada nulla. Nulla facilisi. Nullam ac erat ante.
77
- </Text>
78
- <Text component={TextVariants.h4}>Fourth level</Text>
79
- <Text component={TextVariants.p}>
80
- Nulla efficitur eleifend nisi, sit amet bibendum sapien fringilla ac. Mauris euismod metus a tellus laoreet, at
81
- elementum ex efficitur.
82
- </Text>
83
- <Text component={TextVariants.p}>
84
- Maecenas eleifend sollicitudin dui, faucibus sollicitudin augue cursus non. Ut finibus eleifend arcu ut
85
- vehicula. Mauris eu est maximus est porta condimentum in eu justo. Nulla id iaculis sapien.
86
- </Text>
87
- <Text component={TextVariants.small}>Sometimes you need small text to display things like date created</Text>
88
- <Text component={TextVariants.p}>
89
- Phasellus porttitor enim id metus volutpat ultricies. Ut nisi nunc, blandit sed dapibus at, vestibulum in felis.
90
- Etiam iaculis lorem ac nibh bibendum rhoncus. Nam interdum efficitur ligula sit amet ullamcorper. Etiam
91
- tristique, leo vitae porta faucibus, mi lacus laoreet metus, at cursus leo est vel tellus. Sed ac posuere est.
92
- Nunc ultricies nunc neque, vitae ultricies ex sodales quis. Aliquam eu nibh in libero accumsan pulvinar. Nullam
93
- nec nisl placerat, pretium metus vel, euismod ipsum. Proin tempor cursus nisl vel condimentum. Nam pharetra
94
- varius metus non pellentesque.
95
- </Text>
96
- <Text component={TextVariants.h5}>Fifth level</Text>
97
- <Text component={TextVariants.p}>
98
- Aliquam sagittis rhoncus vulputate. Cras non luctus sem, sed tincidunt ligula. Vestibulum at nunc elit. Praesent
99
- aliquet ligula mi, in luctus elit volutpat porta. Phasellus molestie diam vel nisi sodales, a eleifend augue
100
- laoreet. Sed nec eleifend justo. Nam et sollicitudin odio.
101
- </Text>
102
- <Text component={TextVariants.h6}>Sixth level</Text>
103
- <Text component={TextVariants.p}>
104
- Cras in nibh lacinia, venenatis nisi et, auctor urna. Donec pulvinar lacus sed diam dignissim, ut eleifend eros
105
- accumsan. Phasellus non tortor eros. Ut sed rutrum lacus. Etiam purus nunc, scelerisque quis enim vitae,
106
- malesuada ultrices turpis. Nunc vitae maximus purus, nec consectetur dui. Suspendisse euismod, elit vel rutrum
107
- commodo, ipsum tortor maximus dui, sed varius sapien odio vitae est. Etiam at cursus metus.
108
- </Text>
109
- </TextContent>
1
+ import * as React from 'react';
2
+ import { render, screen } from '@testing-library/react';
3
+ import { Text } from '../Text';
4
+
5
+ test('Renders without children', () => {
6
+ render(
7
+ <div data-testid="test-content">
8
+ <Text />
9
+ </div>
10
+ );
11
+ expect(screen.getByTestId('test-content').firstChild).toBeVisible();
12
+ });
13
+
14
+ test('Renders children', () => {
15
+ render(<Text>Test</Text>);
16
+ expect(screen.getByText('Test')).toBeVisible();
17
+ });
18
+
19
+ test('Renders without class name by default', () => {
20
+ render(<Text>Test</Text>);
21
+ expect(screen.getByText('Test')).not.toHaveClass();
22
+ });
23
+
24
+ test('Renders with custom class name when className prop is provided', () => {
25
+ render(<Text className="custom-class">Test</Text>);
26
+ expect(screen.getByText('Test')).toHaveClass('custom-class');
27
+ });
28
+
29
+ test('Renders as "p" element by default', () => {
30
+ render(<Text>Test</Text>);
31
+ expect(screen.getByText('Test')).toHaveProperty('nodeName', 'P');
32
+ });
33
+
34
+ test('Renders as "h1" element when component="h1"', () => {
35
+ render(<Text component="h1">Test</Text>);
36
+ expect(screen.getByRole('heading', { level: 1 })).toBeVisible();
37
+ });
38
+
39
+ test('Renders as "h2" element when component="h2"', () => {
40
+ render(<Text component="h2">Test</Text>);
41
+ expect(screen.getByRole('heading', { level: 2 })).toBeVisible();
42
+ });
43
+
44
+ test('Renders as "h3" element when component="h3"', () => {
45
+ render(<Text component="h3">Test</Text>);
46
+ expect(screen.getByRole('heading', { level: 3 })).toBeVisible();
47
+ });
48
+
49
+ test('Renders as "h4" element when component="h4"', () => {
50
+ render(<Text component="h4">Test</Text>);
51
+ expect(screen.getByRole('heading', { level: 4 })).toBeVisible();
52
+ });
53
+
54
+ test('Renders as "h5" element when component="h5"', () => {
55
+ render(<Text component="h5">Test</Text>);
56
+ expect(screen.getByRole('heading', { level: 5 })).toBeVisible();
57
+ });
58
+
59
+ test('Renders as "h6" element when component="h6"', () => {
60
+ render(<Text component="h6">Test</Text>);
61
+ expect(screen.getByRole('heading', { level: 6 })).toBeVisible();
62
+ });
63
+
64
+ test('Renders as "a" element when component="a"', () => {
65
+ render(<Text component="a">Test</Text>);
66
+ expect(screen.getByText('Test')).toHaveProperty('nodeName', 'A');
67
+ });
68
+
69
+ test('Renders as "blockquote" element when component="blockquote"', () => {
70
+ render(<Text component="blockquote">Test</Text>);
71
+ expect(screen.getByText('Test')).toHaveProperty('nodeName', 'BLOCKQUOTE');
72
+ });
73
+
74
+ test('Renders as "pre" element when component="pre"', () => {
75
+ render(<Text component="pre">Test</Text>);
76
+ expect(screen.getByText('Test')).toHaveProperty('nodeName', 'PRE');
77
+ });
78
+
79
+ test('Renders without class name pf-m-visited by default', () => {
80
+ render(<Text>Test</Text>);
81
+ expect(screen.getByText('Test')).not.toHaveClass('pf-m-visited');
82
+ });
83
+
84
+ test('Renders with class name pf-m-visited when isVisited=true and component="a"', () => {
85
+ render(
86
+ <Text isVisitedLink={true} component="a">
87
+ Test
88
+ </Text>
110
89
  );
90
+ expect(screen.getByText('Test')).toHaveClass('pf-m-visited');
91
+ });
92
+
93
+ test('Renders with inherited element props spread to the component', () => {
94
+ render(<Text aria-label="Test label">Test</Text>);
95
+ expect(screen.getByText('Test')).toHaveAccessibleName('Test label');
96
+ });
97
+
98
+ test('Matches the snapshot', () => {
99
+ const { asFragment } = render(<Text ouiaId="ouia-id">Test</Text>);
111
100
  expect(asFragment()).toMatchSnapshot();
112
101
  });
@@ -0,0 +1,47 @@
1
+ import * as React from 'react';
2
+ import { render, screen } from '@testing-library/react';
3
+ import { TextContent } from '../TextContent';
4
+
5
+ test('Renders without children', () => {
6
+ render(
7
+ <div data-testid="test-content">
8
+ <TextContent />
9
+ </div>
10
+ );
11
+ expect(screen.getByTestId('test-content').firstChild).toBeVisible();
12
+ });
13
+
14
+ test('Renders children', () => {
15
+ render(<TextContent>Test</TextContent>);
16
+ expect(screen.getByText('Test')).toBeVisible();
17
+ });
18
+
19
+ test('Renders with class name pf-c-content', () => {
20
+ render(<TextContent>Test</TextContent>);
21
+ expect(screen.getByText('Test')).toHaveClass('pf-c-content', { exact: true });
22
+ });
23
+
24
+ test('Renders with custom class name when className prop is provided', () => {
25
+ render(<TextContent className="custom-class">Test</TextContent>);
26
+ expect(screen.getByText('Test')).toHaveClass('custom-class');
27
+ });
28
+
29
+ test('Renders without class name pf-m-visited by default', () => {
30
+ render(<TextContent>Test</TextContent>);
31
+ expect(screen.getByText('Test')).not.toHaveClass('pf-m-visited');
32
+ });
33
+
34
+ test('Renders with class name pf-m-visited when isVisited=true', () => {
35
+ render(<TextContent isVisited={true}>Test</TextContent>);
36
+ expect(screen.getByText('Test')).toHaveClass('pf-m-visited');
37
+ });
38
+
39
+ test('Renders with inherited element props spread to the component', () => {
40
+ render(<TextContent aria-label="Test label">Test</TextContent>);
41
+ expect(screen.getByText('Test')).toHaveAccessibleName('Test label');
42
+ });
43
+
44
+ test('Matches the snapshot', () => {
45
+ const { asFragment } = render(<TextContent>Test</TextContent>);
46
+ expect(asFragment()).toMatchSnapshot();
47
+ });
@@ -0,0 +1,52 @@
1
+ import * as React from 'react';
2
+ import { render, screen } from '@testing-library/react';
3
+ import { TextList } from '../TextList';
4
+
5
+ test('Renders without children', () => {
6
+ render(
7
+ <div data-testid="test-list">
8
+ <TextList />
9
+ </div>
10
+ );
11
+ expect(screen.getByTestId('test-list').firstChild).toBeVisible();
12
+ });
13
+
14
+ test('Renders children', () => {
15
+ render(<TextList>Test</TextList>);
16
+ expect(screen.getByText('Test')).toBeVisible();
17
+ });
18
+
19
+ test('Renders without class name by default', () => {
20
+ render(<TextList>Test</TextList>);
21
+ expect(screen.getByText('Test')).not.toHaveClass();
22
+ });
23
+
24
+ test('Renders with custom class name when className prop is provided', () => {
25
+ render(<TextList className="custom-class">Test</TextList>);
26
+ expect(screen.getByText('Test')).toHaveClass('custom-class');
27
+ });
28
+
29
+ test('Renders as "ul" element by default', () => {
30
+ render(<TextList>Test</TextList>);
31
+ expect(screen.getByText('Test')).toHaveProperty('nodeName', 'UL');
32
+ });
33
+
34
+ test('Renders as "ol" element when component="ol"', () => {
35
+ render(<TextList component="ol">Test</TextList>);
36
+ expect(screen.getByText('Test')).toHaveProperty('nodeName', 'OL');
37
+ });
38
+
39
+ test('Renders as "dl" element when component="dl"', () => {
40
+ render(<TextList component="dl">Test</TextList>);
41
+ expect(screen.getByText('Test')).toHaveProperty('nodeName', 'DL');
42
+ });
43
+
44
+ test('Renders with inherited element props spread to the component', () => {
45
+ render(<TextList aria-label="Test label">Test</TextList>);
46
+ expect(screen.getByText('Test')).toHaveAccessibleName('Test label');
47
+ });
48
+
49
+ test('Matches the snapshot', () => {
50
+ const { asFragment } = render(<TextList>Test</TextList>);
51
+ expect(asFragment()).toMatchSnapshot();
52
+ });
@@ -0,0 +1,52 @@
1
+ import * as React from 'react';
2
+ import { render, screen } from '@testing-library/react';
3
+ import { TextListItem } from '../TextListItem';
4
+
5
+ test('Renders without children', () => {
6
+ render(
7
+ <div data-testid="test-list-item">
8
+ <TextListItem />
9
+ </div>
10
+ );
11
+ expect(screen.getByTestId('test-list-item').firstChild).toBeVisible();
12
+ });
13
+
14
+ test('Renders children', () => {
15
+ render(<TextListItem>Test</TextListItem>);
16
+ expect(screen.getByText('Test')).toBeVisible();
17
+ });
18
+
19
+ test('Renders without class name by default', () => {
20
+ render(<TextListItem>Test</TextListItem>);
21
+ expect(screen.getByText('Test')).not.toHaveClass();
22
+ });
23
+
24
+ test('Renders with custom class name when className prop is provided', () => {
25
+ render(<TextListItem className="custom-class">Test</TextListItem>);
26
+ expect(screen.getByText('Test')).toHaveClass('custom-class');
27
+ });
28
+
29
+ test('Renders as "li" element by default', () => {
30
+ render(<TextListItem>Test</TextListItem>);
31
+ expect(screen.getByText('Test')).toHaveProperty('nodeName', 'LI');
32
+ });
33
+
34
+ test('Renders as "dt" element when component="dt"', () => {
35
+ render(<TextListItem component="dt">Test</TextListItem>);
36
+ expect(screen.getByText('Test')).toHaveProperty('nodeName', 'DT');
37
+ });
38
+
39
+ test('Renders as "dd" element when component="dd"', () => {
40
+ render(<TextListItem component="dd">Test</TextListItem>);
41
+ expect(screen.getByText('Test')).toHaveProperty('nodeName', 'DD');
42
+ });
43
+
44
+ test('Renders with inherited element props spread to the component', () => {
45
+ render(<TextListItem aria-label="Test label">Test</TextListItem>);
46
+ expect(screen.getByText('Test')).toHaveAccessibleName('Test label');
47
+ });
48
+
49
+ test('Matches the snapshot', () => {
50
+ const { asFragment } = render(<TextListItem>Test</TextListItem>);
51
+ expect(asFragment()).toMatchSnapshot();
52
+ });