@patternfly/react-core 4.224.12 → 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 +8 -0
- 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/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/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 4.224.13 (2022-07-11)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @patternfly/react-core
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## 4.224.12 (2022-07-08)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @patternfly/react-core
|
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
|
+
});
|
|
@@ -1,115 +1,6 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`
|
|
4
|
-
<DocumentFragment>
|
|
5
|
-
<dl
|
|
6
|
-
aria-label=""
|
|
7
|
-
class="pf-c-accordion pf-m-bordered"
|
|
8
|
-
>
|
|
9
|
-
<dt>
|
|
10
|
-
<button
|
|
11
|
-
aria-expanded="false"
|
|
12
|
-
class="pf-c-accordion__toggle"
|
|
13
|
-
id="item-1"
|
|
14
|
-
type="button"
|
|
15
|
-
>
|
|
16
|
-
<span
|
|
17
|
-
class="pf-c-accordion__toggle-text"
|
|
18
|
-
>
|
|
19
|
-
Item One
|
|
20
|
-
</span>
|
|
21
|
-
<span
|
|
22
|
-
class="pf-c-accordion__toggle-icon"
|
|
23
|
-
>
|
|
24
|
-
<svg
|
|
25
|
-
aria-hidden="true"
|
|
26
|
-
fill="currentColor"
|
|
27
|
-
height="1em"
|
|
28
|
-
role="img"
|
|
29
|
-
style="vertical-align: -0.125em;"
|
|
30
|
-
viewBox="0 0 256 512"
|
|
31
|
-
width="1em"
|
|
32
|
-
>
|
|
33
|
-
<path
|
|
34
|
-
d="M224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34z"
|
|
35
|
-
/>
|
|
36
|
-
</svg>
|
|
37
|
-
</span>
|
|
38
|
-
</button>
|
|
39
|
-
</dt>
|
|
40
|
-
<dd
|
|
41
|
-
aria-label=""
|
|
42
|
-
class="pf-c-accordion__expanded-content pf-m-expanded"
|
|
43
|
-
id=""
|
|
44
|
-
>
|
|
45
|
-
<div
|
|
46
|
-
class="pf-c-accordion__expanded-content-body"
|
|
47
|
-
>
|
|
48
|
-
Item One Content
|
|
49
|
-
</div>
|
|
50
|
-
</dd>
|
|
51
|
-
</dl>
|
|
52
|
-
</DocumentFragment>
|
|
53
|
-
`;
|
|
54
|
-
|
|
55
|
-
exports[`Accordion Accordion custom content 1`] = `
|
|
56
|
-
<DocumentFragment>
|
|
57
|
-
<dl
|
|
58
|
-
aria-label=""
|
|
59
|
-
class="pf-c-accordion"
|
|
60
|
-
>
|
|
61
|
-
<dt>
|
|
62
|
-
<button
|
|
63
|
-
aria-expanded="false"
|
|
64
|
-
class="pf-c-accordion__toggle"
|
|
65
|
-
id="item-1"
|
|
66
|
-
type="button"
|
|
67
|
-
>
|
|
68
|
-
<span
|
|
69
|
-
class="pf-c-accordion__toggle-text"
|
|
70
|
-
>
|
|
71
|
-
Item One
|
|
72
|
-
</span>
|
|
73
|
-
<span
|
|
74
|
-
class="pf-c-accordion__toggle-icon"
|
|
75
|
-
>
|
|
76
|
-
<svg
|
|
77
|
-
aria-hidden="true"
|
|
78
|
-
fill="currentColor"
|
|
79
|
-
height="1em"
|
|
80
|
-
role="img"
|
|
81
|
-
style="vertical-align: -0.125em;"
|
|
82
|
-
viewBox="0 0 256 512"
|
|
83
|
-
width="1em"
|
|
84
|
-
>
|
|
85
|
-
<path
|
|
86
|
-
d="M224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34z"
|
|
87
|
-
/>
|
|
88
|
-
</svg>
|
|
89
|
-
</span>
|
|
90
|
-
</button>
|
|
91
|
-
</dt>
|
|
92
|
-
<dd
|
|
93
|
-
aria-label=""
|
|
94
|
-
class="pf-c-accordion__expanded-content pf-m-expanded"
|
|
95
|
-
id=""
|
|
96
|
-
>
|
|
97
|
-
<div
|
|
98
|
-
class="pf-c-accordion__expanded-content-body"
|
|
99
|
-
>
|
|
100
|
-
Item one content body 1
|
|
101
|
-
</div>
|
|
102
|
-
<div
|
|
103
|
-
class="pf-c-accordion__expanded-content-body"
|
|
104
|
-
>
|
|
105
|
-
Item one Content body 2
|
|
106
|
-
</div>
|
|
107
|
-
</dd>
|
|
108
|
-
</dl>
|
|
109
|
-
</DocumentFragment>
|
|
110
|
-
`;
|
|
111
|
-
|
|
112
|
-
exports[`Accordion Accordion default 1`] = `
|
|
3
|
+
exports[`Matches the snapshot 1`] = `
|
|
113
4
|
<DocumentFragment>
|
|
114
5
|
<dl
|
|
115
6
|
aria-label="this is a simple accordion"
|
|
@@ -117,107 +8,3 @@ exports[`Accordion Accordion default 1`] = `
|
|
|
117
8
|
/>
|
|
118
9
|
</DocumentFragment>
|
|
119
10
|
`;
|
|
120
|
-
|
|
121
|
-
exports[`Accordion Accordion display large 1`] = `
|
|
122
|
-
<DocumentFragment>
|
|
123
|
-
<dl
|
|
124
|
-
aria-label=""
|
|
125
|
-
class="pf-c-accordion pf-m-display-lg"
|
|
126
|
-
>
|
|
127
|
-
<dt>
|
|
128
|
-
<button
|
|
129
|
-
aria-expanded="false"
|
|
130
|
-
class="pf-c-accordion__toggle"
|
|
131
|
-
id="item-1"
|
|
132
|
-
type="button"
|
|
133
|
-
>
|
|
134
|
-
<span
|
|
135
|
-
class="pf-c-accordion__toggle-text"
|
|
136
|
-
>
|
|
137
|
-
Item One
|
|
138
|
-
</span>
|
|
139
|
-
<span
|
|
140
|
-
class="pf-c-accordion__toggle-icon"
|
|
141
|
-
>
|
|
142
|
-
<svg
|
|
143
|
-
aria-hidden="true"
|
|
144
|
-
fill="currentColor"
|
|
145
|
-
height="1em"
|
|
146
|
-
role="img"
|
|
147
|
-
style="vertical-align: -0.125em;"
|
|
148
|
-
viewBox="0 0 256 512"
|
|
149
|
-
width="1em"
|
|
150
|
-
>
|
|
151
|
-
<path
|
|
152
|
-
d="M224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34z"
|
|
153
|
-
/>
|
|
154
|
-
</svg>
|
|
155
|
-
</span>
|
|
156
|
-
</button>
|
|
157
|
-
</dt>
|
|
158
|
-
<dd
|
|
159
|
-
aria-label=""
|
|
160
|
-
class="pf-c-accordion__expanded-content pf-m-expanded"
|
|
161
|
-
id=""
|
|
162
|
-
>
|
|
163
|
-
<div
|
|
164
|
-
class="pf-c-accordion__expanded-content-body"
|
|
165
|
-
>
|
|
166
|
-
Item One Content
|
|
167
|
-
</div>
|
|
168
|
-
</dd>
|
|
169
|
-
</dl>
|
|
170
|
-
</DocumentFragment>
|
|
171
|
-
`;
|
|
172
|
-
|
|
173
|
-
exports[`Accordion Accordion with non-default headingLevel 1`] = `
|
|
174
|
-
<DocumentFragment>
|
|
175
|
-
<div
|
|
176
|
-
aria-label=""
|
|
177
|
-
class="pf-c-accordion"
|
|
178
|
-
>
|
|
179
|
-
<h2>
|
|
180
|
-
<button
|
|
181
|
-
aria-expanded="false"
|
|
182
|
-
class="pf-c-accordion__toggle"
|
|
183
|
-
id="item-1"
|
|
184
|
-
type="button"
|
|
185
|
-
>
|
|
186
|
-
<span
|
|
187
|
-
class="pf-c-accordion__toggle-text"
|
|
188
|
-
>
|
|
189
|
-
Item One
|
|
190
|
-
</span>
|
|
191
|
-
<span
|
|
192
|
-
class="pf-c-accordion__toggle-icon"
|
|
193
|
-
>
|
|
194
|
-
<svg
|
|
195
|
-
aria-hidden="true"
|
|
196
|
-
fill="currentColor"
|
|
197
|
-
height="1em"
|
|
198
|
-
role="img"
|
|
199
|
-
style="vertical-align: -0.125em;"
|
|
200
|
-
viewBox="0 0 256 512"
|
|
201
|
-
width="1em"
|
|
202
|
-
>
|
|
203
|
-
<path
|
|
204
|
-
d="M224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34z"
|
|
205
|
-
/>
|
|
206
|
-
</svg>
|
|
207
|
-
</span>
|
|
208
|
-
</button>
|
|
209
|
-
</h2>
|
|
210
|
-
<div
|
|
211
|
-
aria-label=""
|
|
212
|
-
class="pf-c-accordion__expanded-content pf-m-expanded"
|
|
213
|
-
id=""
|
|
214
|
-
>
|
|
215
|
-
<div
|
|
216
|
-
class="pf-c-accordion__expanded-content-body"
|
|
217
|
-
>
|
|
218
|
-
Item One Content
|
|
219
|
-
</div>
|
|
220
|
-
</div>
|
|
221
|
-
</div>
|
|
222
|
-
</DocumentFragment>
|
|
223
|
-
`;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Matches the snapshot 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
|
+
<h3
|
|
6
|
+
aria-label="this is a simple accordion"
|
|
7
|
+
class="pf-c-accordion__expanded-content pf-m-expanded"
|
|
8
|
+
id=""
|
|
9
|
+
>
|
|
10
|
+
<div
|
|
11
|
+
aria-label="Expanded content body mock"
|
|
12
|
+
>
|
|
13
|
+
Test
|
|
14
|
+
</div>
|
|
15
|
+
</h3>
|
|
16
|
+
</DocumentFragment>
|
|
17
|
+
`;
|
package/src/components/Accordion/__tests__/__snapshots__/AccordionExpandedContentBody.test.tsx.snap
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Matches the snapshot 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
|
+
<div
|
|
6
|
+
class="pf-c-accordion__expanded-content-body"
|
|
7
|
+
>
|
|
8
|
+
Test
|
|
9
|
+
</div>
|
|
10
|
+
</DocumentFragment>
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
exports[`Renders without children 1`] = `
|
|
14
|
+
<DocumentFragment>
|
|
15
|
+
<div
|
|
16
|
+
class="pf-c-accordion__expanded-content-body"
|
|
17
|
+
/>
|
|
18
|
+
</DocumentFragment>
|
|
19
|
+
`;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Matches the snapshot 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
|
+
<h3>
|
|
6
|
+
<button
|
|
7
|
+
aria-expanded="false"
|
|
8
|
+
class="pf-c-accordion__toggle"
|
|
9
|
+
id="accordion-toggle"
|
|
10
|
+
type="button"
|
|
11
|
+
>
|
|
12
|
+
<span
|
|
13
|
+
class="pf-c-accordion__toggle-text"
|
|
14
|
+
>
|
|
15
|
+
Test
|
|
16
|
+
</span>
|
|
17
|
+
<span
|
|
18
|
+
class="pf-c-accordion__toggle-icon"
|
|
19
|
+
>
|
|
20
|
+
Icon mock
|
|
21
|
+
</span>
|
|
22
|
+
</button>
|
|
23
|
+
</h3>
|
|
24
|
+
</DocumentFragment>
|
|
25
|
+
`;
|
|
@@ -1,17 +1,70 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
3
|
import { Hint } from '../Hint';
|
|
4
|
-
import { HintBody } from '../HintBody';
|
|
5
|
-
import { HintTitle } from '../HintTitle';
|
|
6
|
-
import { HintFooter } from '../HintFooter';
|
|
7
4
|
|
|
8
|
-
test('
|
|
5
|
+
test('renders without children', () => {
|
|
6
|
+
render(<Hint data-testid='Hint' />);
|
|
7
|
+
|
|
8
|
+
expect(screen.getByTestId('Hint')).toBeVisible();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test('renders children', () => {
|
|
12
|
+
render(<Hint>Test</Hint>);
|
|
13
|
+
|
|
14
|
+
expect(screen.getByText('Test')).toBeVisible();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test('renders with class pf-c-hint', () => {
|
|
18
|
+
render(<Hint>Test</Hint>);
|
|
19
|
+
|
|
20
|
+
const hint = screen.getByText('Test');
|
|
21
|
+
|
|
22
|
+
expect(hint).toHaveClass('pf-c-hint');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test('renders with custom class names provided via prop', () => {
|
|
26
|
+
render(<Hint className='custom-classname'>Test</Hint>);
|
|
27
|
+
|
|
28
|
+
const hint = screen.getByText('Test');
|
|
29
|
+
|
|
30
|
+
expect(hint).toHaveClass('custom-classname');
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('does not render actions options when not passed', () => {
|
|
34
|
+
render(<Hint>Test</Hint>);
|
|
35
|
+
|
|
36
|
+
const actions = screen.queryByText('actions');
|
|
37
|
+
|
|
38
|
+
expect(actions).not.toBeInTheDocument();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test('renders actions options', () => {
|
|
42
|
+
render(<Hint actions="actions">Test</Hint>);
|
|
43
|
+
|
|
44
|
+
const actions = screen.getByText("actions");
|
|
45
|
+
|
|
46
|
+
expect(actions).toBeVisible();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('renders with class pf-c-hint__actions if there is an action prop', () => {
|
|
50
|
+
render(<Hint actions="actions">Test</Hint>);
|
|
51
|
+
|
|
52
|
+
const hint = screen.getByText('actions');
|
|
53
|
+
|
|
54
|
+
expect(hint).toHaveClass('pf-c-hint__actions');
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('renders with inherited element props spread to the component', () => {
|
|
58
|
+
render(
|
|
59
|
+
<Hint aria-label="labelling-id">Test</Hint>
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
expect(screen.getByText('Test')).toHaveAccessibleName('labelling-id');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('matches hint snapshot', () => {
|
|
9
66
|
const { asFragment } = render(
|
|
10
|
-
<Hint
|
|
11
|
-
<HintTitle>Title</HintTitle>
|
|
12
|
-
<HintBody>Body</HintBody>
|
|
13
|
-
<HintFooter>Footer</HintFooter>
|
|
14
|
-
</Hint>
|
|
67
|
+
<Hint />
|
|
15
68
|
);
|
|
16
69
|
expect(asFragment()).toMatchSnapshot();
|
|
17
70
|
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
4
|
+
|
|
5
|
+
import { HintBody } from "../HintBody";
|
|
6
|
+
|
|
7
|
+
test('renders without children', () => {
|
|
8
|
+
render(<HintBody data-testid="HintBody"></HintBody>);
|
|
9
|
+
|
|
10
|
+
expect(screen.getByTestId('HintBody')).toBeVisible();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
test('renders children', () => {
|
|
14
|
+
render(<HintBody>{<button>Test Me</button>}</HintBody>);
|
|
15
|
+
|
|
16
|
+
expect(screen.getByRole('button', { name: 'Test Me' })).toBeVisible();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test('renders with class pf-c-hint__body', () => {
|
|
20
|
+
render(<HintBody>Hint Body Test</HintBody>);
|
|
21
|
+
|
|
22
|
+
const body = screen.getByText('Hint Body Test');
|
|
23
|
+
|
|
24
|
+
expect(body).toHaveClass('pf-c-hint__body');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test('renders with custom class names provided via prop', () => {
|
|
28
|
+
render(<HintBody className="custom-classname">Hint Body Test</HintBody>);
|
|
29
|
+
|
|
30
|
+
const body = screen.getByText('Hint Body Test');
|
|
31
|
+
|
|
32
|
+
expect(body).toHaveClass('custom-classname');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('renders with inherited element props spread to the component', () => {
|
|
36
|
+
render(
|
|
37
|
+
<HintBody aria-label="labelling-id">Test</HintBody>
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
expect(screen.getByText('Test')).toHaveAccessibleName('labelling-id');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('matches snapshot', () => {
|
|
44
|
+
const { asFragment } = render(<HintBody>{<button>Test</button>}</HintBody>);
|
|
45
|
+
|
|
46
|
+
expect(asFragment()).toMatchSnapshot();
|
|
47
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
4
|
+
|
|
5
|
+
import { HintFooter } from "../HintFooter";
|
|
6
|
+
|
|
7
|
+
test('renders without children', () => {
|
|
8
|
+
render(<HintFooter data-testid="HintFooter"></HintFooter>);
|
|
9
|
+
|
|
10
|
+
expect(screen.getByTestId('HintFooter')).toBeVisible();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
test('renders children', () => {
|
|
14
|
+
render(<HintFooter>{<button>Test Me</button>}</HintFooter>);
|
|
15
|
+
|
|
16
|
+
expect(screen.getByRole('button', { name: 'Test Me' })).toBeVisible();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test('renders with class pf-c-hint__footer', () => {
|
|
20
|
+
render(<HintFooter>Hint Body Test</HintFooter>);
|
|
21
|
+
|
|
22
|
+
const body = screen.getByText('Hint Body Test');
|
|
23
|
+
|
|
24
|
+
expect(body).toHaveClass('pf-c-hint__footer');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test('renders with custom class names provided via prop', () => {
|
|
28
|
+
render(<HintFooter className="custom-classname">Hint Body Test</HintFooter>);
|
|
29
|
+
|
|
30
|
+
const body = screen.getByText('Hint Body Test');
|
|
31
|
+
|
|
32
|
+
expect(body).toHaveClass('custom-classname');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('renders with inherited element props spread to the component', () => {
|
|
36
|
+
render(
|
|
37
|
+
<HintFooter aria-label="labelling-id">Test</HintFooter>
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
expect(screen.getByText('Test')).toHaveAccessibleName('labelling-id');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('matches snapshot', () => {
|
|
44
|
+
const { asFragment } = render(<HintFooter>{<button>Test</button>}</HintFooter>);
|
|
45
|
+
|
|
46
|
+
expect(asFragment()).toMatchSnapshot();
|
|
47
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
4
|
+
|
|
5
|
+
import { HintTitle } from "../HintTitle";
|
|
6
|
+
|
|
7
|
+
test('renders without children', () => {
|
|
8
|
+
render(<HintTitle data-testid="HintTitle"></HintTitle>);
|
|
9
|
+
|
|
10
|
+
expect(screen.getByTestId('HintTitle')).toBeVisible();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
test('renders children', () => {
|
|
14
|
+
render(<HintTitle>{<button>Test Me</button>}</HintTitle>);
|
|
15
|
+
|
|
16
|
+
expect(screen.getByRole('button', { name: 'Test Me' })).toBeVisible();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test('renders with class pf-c-hint__title', () => {
|
|
20
|
+
render(<HintTitle>Hint Body Test</HintTitle>);
|
|
21
|
+
|
|
22
|
+
const body = screen.getByText('Hint Body Test');
|
|
23
|
+
|
|
24
|
+
expect(body).toHaveClass('pf-c-hint__title');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test('renders with custom class names provided via prop', () => {
|
|
28
|
+
render(<HintTitle className="custom-classname">Hint Body Test</HintTitle>);
|
|
29
|
+
|
|
30
|
+
const body = screen.getByText('Hint Body Test');
|
|
31
|
+
|
|
32
|
+
expect(body).toHaveClass('custom-classname');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('renders with inherited element props spread to the component', () => {
|
|
36
|
+
render(
|
|
37
|
+
<HintTitle aria-label="labelling-id">Test</HintTitle>
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
expect(screen.getByText('Test')).toHaveAccessibleName('labelling-id');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('matches snapshot', () => {
|
|
44
|
+
const { asFragment } = render(<HintTitle>{<button>Test</button>}</HintTitle>);
|
|
45
|
+
|
|
46
|
+
expect(asFragment()).toMatchSnapshot();
|
|
47
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`
|
|
3
|
+
exports[`matches hint snapshot 1`] = `
|
|
4
4
|
<DocumentFragment>
|
|
5
5
|
<div
|
|
6
6
|
class="pf-c-hint"
|
|
@@ -8,21 +8,6 @@ exports[`simple hint 1`] = `
|
|
|
8
8
|
<div
|
|
9
9
|
class="pf-c-hint__actions"
|
|
10
10
|
/>
|
|
11
|
-
<div
|
|
12
|
-
class="pf-c-hint__title"
|
|
13
|
-
>
|
|
14
|
-
Title
|
|
15
|
-
</div>
|
|
16
|
-
<div
|
|
17
|
-
class="pf-c-hint__body"
|
|
18
|
-
>
|
|
19
|
-
Body
|
|
20
|
-
</div>
|
|
21
|
-
<div
|
|
22
|
-
class="pf-c-hint__footer"
|
|
23
|
-
>
|
|
24
|
-
Footer
|
|
25
|
-
</div>
|
|
26
11
|
</div>
|
|
27
12
|
</DocumentFragment>
|
|
28
13
|
`;
|