@patternfly/react-core 4.224.10 → 4.224.13
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/esm/components/DragDrop/DragDrop.d.ts +1 -1
- package/dist/esm/components/DragDrop/DragDrop.d.ts.map +1 -1
- package/dist/esm/components/SearchInput/SearchInput.d.ts +7 -0
- package/dist/esm/components/SearchInput/SearchInput.d.ts.map +1 -1
- package/dist/esm/components/SearchInput/SearchInput.js +9 -4
- package/dist/esm/components/SearchInput/SearchInput.js.map +1 -1
- package/dist/js/components/DragDrop/DragDrop.d.ts +1 -1
- package/dist/js/components/DragDrop/DragDrop.d.ts.map +1 -1
- package/dist/js/components/SearchInput/SearchInput.d.ts +7 -0
- package/dist/js/components/SearchInput/SearchInput.d.ts.map +1 -1
- package/dist/js/components/SearchInput/SearchInput.js +9 -4
- package/dist/js/components/SearchInput/SearchInput.js.map +1 -1
- package/dist/umd/react-core.css +415 -617
- package/dist/umd/react-core.js +683 -705
- package/dist/umd/react-core.min.css +103 -305
- package/dist/umd/react-core.min.js +4 -4
- package/package.json +5 -5
- package/src/components/Accordion/__tests__/Accordion.test.tsx +134 -104
- package/src/components/Accordion/__tests__/AccordionContent.test.tsx +180 -0
- package/src/components/Accordion/__tests__/AccordionExpandedContentBody.test.tsx +33 -0
- package/src/components/Accordion/__tests__/AccordionItem.test.tsx +18 -0
- package/src/components/Accordion/__tests__/AccordionToggle.test.tsx +164 -0
- package/src/components/Accordion/__tests__/__snapshots__/Accordion.test.tsx.snap +1 -214
- package/src/components/Accordion/__tests__/__snapshots__/AccordionContent.test.tsx.snap +17 -0
- package/src/components/Accordion/__tests__/__snapshots__/AccordionExpandedContentBody.test.tsx.snap +19 -0
- package/src/components/Accordion/__tests__/__snapshots__/AccordionItem.test.tsx.snap +7 -0
- package/src/components/Accordion/__tests__/__snapshots__/AccordionToggle.test.tsx.snap +25 -0
- package/src/components/ActionList/__tests__/ActionList.test.tsx +46 -11
- package/src/components/ActionList/__tests__/ActionListGroup.test.tsx +34 -7
- package/src/components/ActionList/__tests__/ActionListItem.test.tsx +34 -7
- package/src/components/ActionList/__tests__/__snapshots__/ActionList.test.tsx.snap +1 -11
- package/src/components/ActionList/__tests__/__snapshots__/ActionListGroup.test.tsx.snap +1 -1
- package/src/components/ActionList/__tests__/__snapshots__/ActionListItem.test.tsx.snap +1 -1
- package/src/components/DragDrop/DragDrop.tsx +1 -1
- package/src/components/Hint/__tests__/Hint.test.tsx +63 -10
- package/src/components/Hint/__tests__/HintBody.test.tsx +47 -0
- package/src/components/Hint/__tests__/HintFooter.test.tsx +47 -0
- package/src/components/Hint/__tests__/HintTitle.test.tsx +47 -0
- package/src/components/Hint/__tests__/__snapshots__/Hint.test.tsx.snap +1 -16
- package/src/components/Hint/__tests__/__snapshots__/HintBody.test.tsx.snap +13 -0
- package/src/components/Hint/__tests__/__snapshots__/HintFooter.test.tsx.snap +13 -0
- package/src/components/Hint/__tests__/__snapshots__/HintTitle.test.tsx.snap +13 -0
- package/src/components/SearchInput/SearchInput.tsx +32 -5
- package/src/components/SearchInput/__tests__/SearchInput.test.tsx +37 -0
- package/src/components/SearchInput/__tests__/__snapshots__/SearchInput.test.tsx.snap +193 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.224.
|
|
3
|
+
"version": "4.224.13",
|
|
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",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"generate": "node scripts/copyStyles.js"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@patternfly/react-icons": "^4.75.
|
|
38
|
-
"@patternfly/react-styles": "^4.74.
|
|
39
|
-
"@patternfly/react-tokens": "^4.76.
|
|
37
|
+
"@patternfly/react-icons": "^4.75.13",
|
|
38
|
+
"@patternfly/react-styles": "^4.74.13",
|
|
39
|
+
"@patternfly/react-tokens": "^4.76.13",
|
|
40
40
|
"focus-trap": "6.9.2",
|
|
41
41
|
"react-dropzone": "9.0.0",
|
|
42
42
|
"tippy.js": "5.1.2",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"react": "^16.8.0 || ^17.0.0",
|
|
61
61
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "3da666f00f7e848913704c049a51c4085c4044a0"
|
|
64
64
|
}
|
|
@@ -3,108 +3,138 @@ import React from 'react';
|
|
|
3
3
|
import { render, screen } from '@testing-library/react';
|
|
4
4
|
|
|
5
5
|
import { Accordion } from '../Accordion';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
<
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
</
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
6
|
+
import { AccordionContext } from '../AccordionContext';
|
|
7
|
+
|
|
8
|
+
test('Renders without children', () => {
|
|
9
|
+
render(<Accordion data-testid="accordion" />);
|
|
10
|
+
|
|
11
|
+
expect(screen.getByTestId('accordion')).toBeVisible();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test('Renders children', () => {
|
|
15
|
+
render(<Accordion>Test</Accordion>);
|
|
16
|
+
|
|
17
|
+
expect(screen.getByText('Test')).toBeVisible();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('Renders with the passed aria label', () => {
|
|
21
|
+
render(<Accordion aria-label="Accordion test">Test</Accordion>);
|
|
22
|
+
|
|
23
|
+
expect(screen.getByText('Test')).toHaveAccessibleName('Accordion test');
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test('Renders with inherited element props spread to the component', () => {
|
|
27
|
+
render(
|
|
28
|
+
<>
|
|
29
|
+
<Accordion aria-labelledby="labelling-id">Test</Accordion>
|
|
30
|
+
<p id="labelling-id">Label</p>
|
|
31
|
+
</>
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
expect(screen.getByText('Test')).toHaveAccessibleName('Label');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('Renders with class name pf-c-accordion', () => {
|
|
38
|
+
render(<Accordion>Test</Accordion>);
|
|
39
|
+
|
|
40
|
+
expect(screen.getByText('Test')).toHaveClass('pf-c-accordion');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('Renders with custom class names provided via prop', () => {
|
|
44
|
+
render(<Accordion className="test-class">Test</Accordion>);
|
|
45
|
+
|
|
46
|
+
expect(screen.getByText('Test')).toHaveClass('test-class');
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('Renders Accordion as a "dl" by default', () => {
|
|
50
|
+
render(<Accordion>Test</Accordion>);
|
|
51
|
+
|
|
52
|
+
/* these tests asserting a nodeName property aren't my favorite, but dl and div elements don't have implicit aria
|
|
53
|
+
roles for us to select/assert against with something more directly meaningful to user experience */
|
|
54
|
+
expect(screen.getByText('Test')).toHaveProperty('nodeName', 'DL');
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('Renders Accordion as a "div" when asDefinitionList is false', () => {
|
|
58
|
+
render(<Accordion asDefinitionList={false}>Test</Accordion>);
|
|
59
|
+
|
|
60
|
+
expect(screen.getByText('Test')).toHaveProperty('nodeName', 'DIV');
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test('Provides a ContentContainer of "dd" in a context by default', () => {
|
|
64
|
+
render(
|
|
65
|
+
<Accordion>
|
|
66
|
+
<AccordionContext.Consumer>{({ ContentContainer }) => ContentContainer}</AccordionContext.Consumer>
|
|
67
|
+
</Accordion>
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
expect(screen.getByText('dd')).toBeVisible();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test('Provides a ContentContainer of "div" in a context when asDefinitionList is false', () => {
|
|
74
|
+
render(
|
|
75
|
+
<Accordion asDefinitionList={false}>
|
|
76
|
+
<AccordionContext.Consumer>{({ ContentContainer }) => ContentContainer}</AccordionContext.Consumer>
|
|
77
|
+
</Accordion>
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
expect(screen.getByText('div')).toBeVisible();
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('Provides a ToggleContainer of "dt" in a context by default', () => {
|
|
84
|
+
render(
|
|
85
|
+
<Accordion>
|
|
86
|
+
<AccordionContext.Consumer>{({ ToggleContainer }) => ToggleContainer}</AccordionContext.Consumer>
|
|
87
|
+
</Accordion>
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
expect(screen.getByText('dt')).toBeVisible();
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test('Provides a ToggleContainer of "h3" in a context when asDefinitionList is false', () => {
|
|
94
|
+
render(
|
|
95
|
+
<Accordion asDefinitionList={false}>
|
|
96
|
+
<AccordionContext.Consumer>{({ ToggleContainer }) => ToggleContainer}</AccordionContext.Consumer>
|
|
97
|
+
</Accordion>
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
expect(screen.getByText('h3')).toBeVisible();
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test('Provides a ToggleContainer of "h2" in a context when asDefinitionList is false and headingLevel is "h2"', () => {
|
|
104
|
+
render(
|
|
105
|
+
<Accordion asDefinitionList={false} headingLevel="h2">
|
|
106
|
+
<AccordionContext.Consumer>{({ ToggleContainer }) => ToggleContainer}</AccordionContext.Consumer>
|
|
107
|
+
</Accordion>
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
expect(screen.getByText('h2')).toBeVisible();
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test('Renders without pf-m-bordered by default', () => {
|
|
114
|
+
render(<Accordion>Test</Accordion>);
|
|
115
|
+
|
|
116
|
+
expect(screen.getByText('Test')).not.toHaveClass('pf-m-bordered');
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test('Renders with pf-m-bordered when isBordered=true', () => {
|
|
120
|
+
render(<Accordion isBordered>Test</Accordion>);
|
|
121
|
+
|
|
122
|
+
expect(screen.getByText('Test')).toHaveClass('pf-m-bordered');
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
test('Renders without pf-m-display-lg by default', () => {
|
|
126
|
+
render(<Accordion>Test</Accordion>);
|
|
127
|
+
|
|
128
|
+
expect(screen.getByText('Test')).not.toHaveClass('pf-m-display-lg');
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test('Renders with pf-m-display-lg when displaySize=large', () => {
|
|
132
|
+
render(<Accordion displaySize="large">Test</Accordion>);
|
|
133
|
+
|
|
134
|
+
expect(screen.getByText('Test')).toHaveClass('pf-m-display-lg');
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
test('Matches the snapshot', () => {
|
|
138
|
+
const { asFragment } = render(<Accordion aria-label="this is a simple accordion" />);
|
|
139
|
+
expect(asFragment()).toMatchSnapshot();
|
|
110
140
|
});
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
|
|
5
|
+
import { AccordionContent } from '../AccordionContent';
|
|
6
|
+
import { AccordionContext } from '../AccordionContext';
|
|
7
|
+
|
|
8
|
+
jest.mock('../AccordionExpandedContentBody', () => ({
|
|
9
|
+
AccordionExpandedContentBody: ({ children }) => <div aria-label="Expanded content body mock">{children}</div>
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
test('Renders without children', () => {
|
|
13
|
+
render(
|
|
14
|
+
<AccordionContext.Provider value={{ ContentContainer: 'h3' }}>
|
|
15
|
+
<AccordionContent data-testid="accordion-content" />
|
|
16
|
+
</AccordionContext.Provider>
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
expect(screen.getByTestId('accordion-content')).toBeVisible();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('Renders children', () => {
|
|
23
|
+
render(
|
|
24
|
+
<AccordionContext.Provider value={{ ContentContainer: 'h3' }}>
|
|
25
|
+
<AccordionContent>Test</AccordionContent>
|
|
26
|
+
</AccordionContext.Provider>
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
expect(screen.getByText('Test')).toBeVisible();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('Renders with children wrapped in AccordionExpandedContentBody by default', () => {
|
|
33
|
+
render(
|
|
34
|
+
<AccordionContext.Provider value={{ ContentContainer: 'h3' }}>
|
|
35
|
+
<AccordionContent>Test</AccordionContent>
|
|
36
|
+
</AccordionContext.Provider>
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
expect(screen.getByText('Test')).toHaveAccessibleName('Expanded content body mock');
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('Does not render children wrapped in AccordionExpandedContentBody when isCustomContent=true', () => {
|
|
43
|
+
render(
|
|
44
|
+
<AccordionContext.Provider value={{ ContentContainer: 'h3' }}>
|
|
45
|
+
<AccordionContent isCustomContent>Test</AccordionContent>
|
|
46
|
+
</AccordionContext.Provider>
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
expect(screen.getByText('Test')).not.toHaveAccessibleName('Expanded content body mock');
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test('Renders with the passed aria label', () => {
|
|
53
|
+
render(
|
|
54
|
+
<AccordionContext.Provider value={{ ContentContainer: 'h3' }}>
|
|
55
|
+
<AccordionContent aria-label="Accordion content">Test</AccordionContent>
|
|
56
|
+
</AccordionContext.Provider>
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
expect(screen.getByRole('heading')).toHaveAccessibleName('Accordion content');
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test('Renders with inherited element props spread to the component', () => {
|
|
63
|
+
render(
|
|
64
|
+
<>
|
|
65
|
+
<AccordionContext.Provider value={{ ContentContainer: 'h3' }}>
|
|
66
|
+
<AccordionContent aria-labelledby="labelling-id">Test</AccordionContent>
|
|
67
|
+
<p id="labelling-id">Label</p>
|
|
68
|
+
</AccordionContext.Provider>
|
|
69
|
+
</>
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
expect(screen.getByRole('heading')).toHaveAccessibleName('Label');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test('Renders with class name pf-c-accordion__expanded-content', () => {
|
|
76
|
+
render(
|
|
77
|
+
<AccordionContext.Provider value={{ ContentContainer: 'h3' }}>
|
|
78
|
+
<AccordionContent>Test</AccordionContent>
|
|
79
|
+
</AccordionContext.Provider>
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
expect(screen.getByRole('heading')).toHaveClass('pf-c-accordion__expanded-content');
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test('Renders with custom class names provided via prop', () => {
|
|
86
|
+
render(
|
|
87
|
+
<AccordionContext.Provider value={{ ContentContainer: 'h3' }}>
|
|
88
|
+
<AccordionContent className="test-class">Test</AccordionContent>
|
|
89
|
+
</AccordionContext.Provider>
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
expect(screen.getByRole('heading')).toHaveClass('test-class');
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test('Renders with the id prop passed to the container', () => {
|
|
96
|
+
render(
|
|
97
|
+
<AccordionContext.Provider value={{ ContentContainer: 'h3' }}>
|
|
98
|
+
<AccordionContent id="test-id">Test</AccordionContent>
|
|
99
|
+
</AccordionContext.Provider>
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
expect(screen.getByRole('heading')).toHaveProperty('id', 'test-id');
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test('Renders the container as the element provided in ContentContainer from a context by default', () => {
|
|
106
|
+
render(
|
|
107
|
+
<AccordionContext.Provider value={{ ContentContainer: 'h3' }}>
|
|
108
|
+
<AccordionContent>Test</AccordionContent>
|
|
109
|
+
</AccordionContext.Provider>
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
expect(screen.queryByRole('heading', { level: 1 })).not.toBeInTheDocument();
|
|
113
|
+
expect(screen.getByRole('heading', { level: 3 })).toBeVisible();
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
test('Renders as the element provided via the component prop when one is provided', () => {
|
|
117
|
+
render(
|
|
118
|
+
<AccordionContext.Provider value={{ ContentContainer: 'button' }}>
|
|
119
|
+
<AccordionContent component="h1">Test</AccordionContent>
|
|
120
|
+
</AccordionContext.Provider>
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
expect(screen.queryByRole('heading', { level: 3 })).not.toBeInTheDocument();
|
|
124
|
+
expect(screen.getByRole('heading', { level: 1 })).toBeVisible();
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
test('Renders without pf-m-fixed by default', () => {
|
|
128
|
+
render(
|
|
129
|
+
<AccordionContext.Provider value={{ ContentContainer: 'h3' }}>
|
|
130
|
+
<AccordionContent>Test</AccordionContent>
|
|
131
|
+
</AccordionContext.Provider>
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
expect(screen.getByRole('heading')).not.toHaveClass('pf-m-fixed');
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
test('Renders with pf-m-fixed when isFixed is true', () => {
|
|
138
|
+
render(
|
|
139
|
+
<AccordionContext.Provider value={{ ContentContainer: 'h3' }}>
|
|
140
|
+
<AccordionContent isFixed>Test</AccordionContent>
|
|
141
|
+
</AccordionContext.Provider>
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
expect(screen.getByRole('heading')).toHaveClass('pf-m-fixed');
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
test('Renders unhidden and with pf-m-expanded by default', () => {
|
|
148
|
+
render(
|
|
149
|
+
<AccordionContext.Provider value={{ ContentContainer: 'h3' }}>
|
|
150
|
+
<AccordionContent>Test</AccordionContent>
|
|
151
|
+
</AccordionContext.Provider>
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
const contentContainer = screen.getByRole('heading')
|
|
155
|
+
|
|
156
|
+
expect(contentContainer).not.toHaveAttribute('hidden');
|
|
157
|
+
expect(contentContainer).toHaveClass('pf-m-expanded');
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
test('Renders aria-hidden and without pf-m-expanded when isHidden is true', () => {
|
|
161
|
+
render(
|
|
162
|
+
<AccordionContext.Provider value={{ ContentContainer: 'h3' }}>
|
|
163
|
+
<AccordionContent isHidden>Test</AccordionContent>
|
|
164
|
+
</AccordionContext.Provider>
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
const contentContainer = screen.getByRole('heading', { hidden: true })
|
|
168
|
+
|
|
169
|
+
expect(contentContainer).toHaveAttribute('hidden');
|
|
170
|
+
expect(contentContainer).not.toHaveClass('pf-m-expanded');
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
test('Matches the snapshot', () => {
|
|
174
|
+
const { asFragment } = render(
|
|
175
|
+
<AccordionContext.Provider value={{ ContentContainer: 'h3' }}>
|
|
176
|
+
<AccordionContent aria-label="this is a simple accordion">Test</AccordionContent>
|
|
177
|
+
</AccordionContext.Provider>
|
|
178
|
+
);
|
|
179
|
+
expect(asFragment()).toMatchSnapshot();
|
|
180
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
|
|
5
|
+
import { AccordionExpandedContentBody } from '../AccordionExpandedContentBody';
|
|
6
|
+
|
|
7
|
+
test('Renders without children', () => {
|
|
8
|
+
const { asFragment } = render(<AccordionExpandedContentBody />);
|
|
9
|
+
|
|
10
|
+
/* a snapshot test is used here because this component isn't selectable via better screen queries without children
|
|
11
|
+
as it doesn't spread other props to its container
|
|
12
|
+
*/
|
|
13
|
+
expect(asFragment()).toMatchSnapshot();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test('Renders children', () => {
|
|
17
|
+
render(<AccordionExpandedContentBody>Test</AccordionExpandedContentBody>);
|
|
18
|
+
|
|
19
|
+
expect(screen.getByText('Test')).toBeVisible();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('Renders with class name pf-c-accordion__expanded-content-body', () => {
|
|
23
|
+
render(<AccordionExpandedContentBody>Test</AccordionExpandedContentBody>);
|
|
24
|
+
|
|
25
|
+
expect(screen.getByText('Test')).toHaveClass('pf-c-accordion__expanded-content-body');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test('Matches the snapshot', () => {
|
|
29
|
+
const { asFragment } = render(
|
|
30
|
+
<AccordionExpandedContentBody>Test</AccordionExpandedContentBody>
|
|
31
|
+
);
|
|
32
|
+
expect(asFragment()).toMatchSnapshot();
|
|
33
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
|
|
5
|
+
import { AccordionItem } from '../AccordionItem';
|
|
6
|
+
|
|
7
|
+
test('Renders children', () => {
|
|
8
|
+
render(<AccordionItem>Test</AccordionItem>);
|
|
9
|
+
|
|
10
|
+
expect(screen.getByText('Test')).toBeVisible();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
test('Matches the snapshot', () => {
|
|
14
|
+
const { asFragment } = render(
|
|
15
|
+
<AccordionItem>Test</AccordionItem>
|
|
16
|
+
);
|
|
17
|
+
expect(asFragment()).toMatchSnapshot();
|
|
18
|
+
});
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
|
|
5
|
+
import { AccordionToggle } from '../AccordionToggle';
|
|
6
|
+
import { AccordionContext } from '../AccordionContext';
|
|
7
|
+
|
|
8
|
+
jest.mock('@patternfly/react-icons/dist/esm/icons/angle-right-icon', () => () => 'Icon mock');
|
|
9
|
+
|
|
10
|
+
test('Renders without children', () => {
|
|
11
|
+
render(
|
|
12
|
+
<AccordionContext.Provider value={{ ToggleContainer: 'h3' }}>
|
|
13
|
+
<AccordionToggle id="accordion-toggle" data-testid="accordion-toggle-test-id" />
|
|
14
|
+
</AccordionContext.Provider>
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
expect(screen.getByTestId('accordion-toggle-test-id')).toBeVisible();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('Renders children', () => {
|
|
21
|
+
render(
|
|
22
|
+
<AccordionContext.Provider value={{ ToggleContainer: 'h3' }}>
|
|
23
|
+
<AccordionToggle id="accordion-toggle">Test</AccordionToggle>
|
|
24
|
+
</AccordionContext.Provider>
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
expect(screen.getByText('Test')).toBeVisible();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('Renders with inherited element props spread to the component', () => {
|
|
31
|
+
render(
|
|
32
|
+
<>
|
|
33
|
+
<AccordionContext.Provider value={{ ToggleContainer: 'h3' }}>
|
|
34
|
+
<AccordionToggle id="accordion-toggle" aria-labelledby="labelling-id">
|
|
35
|
+
Test
|
|
36
|
+
</AccordionToggle>
|
|
37
|
+
<p id="labelling-id">Label</p>
|
|
38
|
+
</AccordionContext.Provider>
|
|
39
|
+
</>
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
expect(screen.getByRole('button')).toHaveAccessibleName('Label');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test('Renders the accordion toggle with class pf-c-accordion__toggle', () => {
|
|
46
|
+
render(
|
|
47
|
+
<AccordionContext.Provider value={{ ToggleContainer: 'h3' }}>
|
|
48
|
+
<AccordionToggle id="accordion-toggle" aria-label="Accordion test">
|
|
49
|
+
Test
|
|
50
|
+
</AccordionToggle>
|
|
51
|
+
</AccordionContext.Provider>
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
expect(screen.getByRole('button')).toHaveClass('pf-c-accordion__toggle');
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('Renders the accordion toggle with custom class names provided via prop', () => {
|
|
58
|
+
render(
|
|
59
|
+
<AccordionContext.Provider value={{ ToggleContainer: 'h3' }}>
|
|
60
|
+
<AccordionToggle id="accordion-toggle" aria-label="Accordion test" className="test-class">
|
|
61
|
+
Test
|
|
62
|
+
</AccordionToggle>
|
|
63
|
+
</AccordionContext.Provider>
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
expect(screen.getByRole('button')).toHaveClass('test-class');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('Renders with children inside class pf-c-accordion__toggle-text', () => {
|
|
70
|
+
render(
|
|
71
|
+
<AccordionContext.Provider value={{ ToggleContainer: 'h3' }}>
|
|
72
|
+
<AccordionToggle id="accordion-toggle" aria-label="Accordion test">
|
|
73
|
+
Test
|
|
74
|
+
</AccordionToggle>
|
|
75
|
+
</AccordionContext.Provider>
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
expect(screen.getByText('Test')).toHaveClass('pf-c-accordion__toggle-text');
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
test('Renders with the toggle icon inside class pf-c-accordion__toggle-icon', () => {
|
|
82
|
+
render(
|
|
83
|
+
<AccordionContext.Provider value={{ ToggleContainer: 'h3' }}>
|
|
84
|
+
<AccordionToggle id="accordion-toggle" aria-label="Accordion test">
|
|
85
|
+
Test
|
|
86
|
+
</AccordionToggle>
|
|
87
|
+
</AccordionContext.Provider>
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
expect(screen.getByText('Icon mock')).toHaveClass('pf-c-accordion__toggle-icon');
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test('Renders with the id prop passed to the toggle', () => {
|
|
94
|
+
render(
|
|
95
|
+
<AccordionContext.Provider value={{ ToggleContainer: 'h3' }}>
|
|
96
|
+
<AccordionToggle id="accordion-toggle" aria-label="Accordion test">
|
|
97
|
+
Test
|
|
98
|
+
</AccordionToggle>
|
|
99
|
+
</AccordionContext.Provider>
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
expect(screen.getByRole('button')).toHaveProperty('id', 'accordion-toggle');
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test('Renders the container as the element provided in ToggleContainer from a context by default', () => {
|
|
106
|
+
render(
|
|
107
|
+
<AccordionContext.Provider value={{ ToggleContainer: 'h3' }}>
|
|
108
|
+
<AccordionToggle id="accordion-toggle">Test</AccordionToggle>
|
|
109
|
+
</AccordionContext.Provider>
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
expect(screen.queryByRole('heading', { level: 1 })).not.toBeInTheDocument();
|
|
113
|
+
expect(screen.getByRole('heading', { level: 3 })).toBeVisible();
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
test('Renders the container as the element provided via the component prop when one is provided', () => {
|
|
117
|
+
render(
|
|
118
|
+
<AccordionContext.Provider value={{ ToggleContainer: 'h3' }}>
|
|
119
|
+
<AccordionToggle id="accordion-toggle" component="h1">
|
|
120
|
+
Test
|
|
121
|
+
</AccordionToggle>
|
|
122
|
+
</AccordionContext.Provider>
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
expect(screen.queryByRole('heading', { level: 3 })).not.toBeInTheDocument();
|
|
126
|
+
expect(screen.getByRole('heading', { level: 1 })).toBeVisible();
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
test('Renders the toggle without pf-m-expanded and aria-expanded=false by default', () => {
|
|
130
|
+
render(
|
|
131
|
+
<AccordionContext.Provider value={{ ToggleContainer: 'h3' }}>
|
|
132
|
+
<AccordionToggle id="accordion-toggle">Test</AccordionToggle>
|
|
133
|
+
</AccordionContext.Provider>
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
const toggle = screen.getByRole('button');
|
|
137
|
+
|
|
138
|
+
expect(toggle).not.toHaveClass('pf-m-expanded');
|
|
139
|
+
expect(toggle).toHaveAttribute('aria-expanded', 'false');
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
test('Renders the toggle with pf-m-expanded and aria-expanded=true when isExpanded=true', () => {
|
|
143
|
+
render(
|
|
144
|
+
<AccordionContext.Provider value={{ ToggleContainer: 'h3' }}>
|
|
145
|
+
<AccordionToggle id="accordion-toggle" isExpanded>
|
|
146
|
+
Test
|
|
147
|
+
</AccordionToggle>
|
|
148
|
+
</AccordionContext.Provider>
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
const toggle = screen.getByRole('button');
|
|
152
|
+
|
|
153
|
+
expect(toggle).toHaveClass('pf-m-expanded');
|
|
154
|
+
expect(toggle).toHaveAttribute('aria-expanded', 'true');
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
test('Matches the snapshot', () => {
|
|
158
|
+
const { asFragment } = render(
|
|
159
|
+
<AccordionContext.Provider value={{ ToggleContainer: 'h3' }}>
|
|
160
|
+
<AccordionToggle id="accordion-toggle">Test</AccordionToggle>
|
|
161
|
+
</AccordionContext.Provider>
|
|
162
|
+
);
|
|
163
|
+
expect(asFragment()).toMatchSnapshot();
|
|
164
|
+
});
|