@pie-lib/render-ui 4.49.0-mui-update.0 → 5.0.0-next.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.
- package/CHANGELOG.md +14 -128
- package/package.json +14 -6
- package/src/__tests__/html-and-math.test.js +26 -14
- package/src/__tests__/preview-prompt.test.jsx +43 -40
- package/src/__tests__/purpose.test.jsx +27 -23
- package/src/__tests__/readable.test.jsx +34 -29
- package/src/__tests__/response-indicators.test.jsx +104 -9
- package/src/__tests__/ui-layout.test.jsx +28 -12
- package/src/__tests__/withUndoReset.test.jsx +110 -188
- package/src/collapsible/__tests__/index.test.jsx +33 -7
- package/src/__tests__/__snapshots__/html-and-math.test.js.snap +0 -11
- package/src/__tests__/__snapshots__/preview-prompt.test.jsx.snap +0 -37
- package/src/__tests__/__snapshots__/purpose.test.jsx.snap +0 -42
- package/src/__tests__/__snapshots__/readable.test.jsx.snap +0 -64
- package/src/__tests__/__snapshots__/response-indicators.test.jsx.snap +0 -27
- package/src/collapsible/__tests__/__snapshots__/index.test.jsx.snap +0 -18
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
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
|
-
# [
|
|
6
|
+
# [5.0.0-next.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.35.3-next.0...@pie-lib/render-ui@5.0.0-next.0) (2026-01-19)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @pie-lib/render-ui
|
|
9
9
|
|
|
@@ -11,56 +11,14 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
## [4.35.3-next.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.49.0-mui-update.0...@pie-lib/render-ui@4.35.3-next.0) (2026-01-19)
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
### Bug Fixes
|
|
18
18
|
|
|
19
|
-
* **render-ui:**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
# [4.47.0-mui-update.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.46.0-mui-update.0...@pie-lib/render-ui@4.47.0-mui-update.0) (2025-12-17)
|
|
26
|
-
|
|
27
|
-
**Note:** Version bump only for package @pie-lib/render-ui
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
# [4.46.0-mui-update.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.45.0-mui-update.0...@pie-lib/render-ui@4.46.0-mui-update.0) (2025-12-17)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
### Bug Fixes
|
|
37
|
-
|
|
38
|
-
* Add MutationObserver to PreviewPrompt for prompt, rationale & TI math rendering ([d77ef3c](https://github.com/pie-framework/pie-lib/commit/d77ef3c15c6928f3a7dae627e6c49380cef01745))
|
|
39
|
-
* simplify math render logic ([de11ebe](https://github.com/pie-framework/pie-lib/commit/de11ebe7f2faeb9dce6215673a90b79e86cbc590))
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
# [4.45.0-mui-update.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.44.0-mui-update.0...@pie-lib/render-ui@4.45.0-mui-update.0) (2025-12-11)
|
|
46
|
-
|
|
47
|
-
**Note:** Version bump only for package @pie-lib/render-ui
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
# [4.44.0-mui-update.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.43.0-mui-update.0...@pie-lib/render-ui@4.44.0-mui-update.0) (2025-12-02)
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
### Bug Fixes
|
|
57
|
-
|
|
58
|
-
* add back muiButton ([b65ddc0](https://github.com/pie-framework/pie-lib/commit/b65ddc06cbb83dda5cc3c04ee60afffb793f1e10))
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
### Features
|
|
62
|
-
|
|
63
|
-
* sync latest changes from dev ([c936e9c](https://github.com/pie-framework/pie-lib/commit/c936e9c7f9e095e7d9b9805ac2bf72bd271e05f1))
|
|
19
|
+
* **render-ui:** change unneeded colors overwriting in theme provider PD-5274 ([dbfaed5](https://github.com/pie-framework/pie-lib/commit/dbfaed50feed9c059b14c9835468159858446af1))
|
|
20
|
+
* **render-ui:** handle vertical striping only for tables with th first col PD-5211 ([d32502e](https://github.com/pie-framework/pie-lib/commit/d32502e496fc9a19a6444e537587017c91e87724))
|
|
21
|
+
* bump config-ui PD-5265 ([77d0c78](https://github.com/pie-framework/pie-lib/commit/77d0c78cacfa57e93ed17e7a7f1257f4a9cf6ab3))
|
|
64
22
|
|
|
65
23
|
|
|
66
24
|
|
|
@@ -68,162 +26,90 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
68
26
|
|
|
69
27
|
## [4.35.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.35.1...@pie-lib/render-ui@4.35.2) (2025-11-27)
|
|
70
28
|
|
|
71
|
-
|
|
72
29
|
### Bug Fixes
|
|
73
30
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
31
|
+
- **render-ui:** change unneeded colors overwriting in theme provider PD-5274 ([dbfaed5](https://github.com/pie-framework/pie-lib/commit/dbfaed50feed9c059b14c9835468159858446af1))
|
|
32
|
+
- **render-ui:** handle vertical striping only for tables with th first col PD-5211 ([d32502e](https://github.com/pie-framework/pie-lib/commit/d32502e496fc9a19a6444e537587017c91e87724))
|
|
80
33
|
|
|
81
34
|
## [4.35.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.31.2...@pie-lib/render-ui@4.35.1) (2025-10-22)
|
|
82
35
|
|
|
83
|
-
|
|
84
36
|
### Bug Fixes
|
|
85
37
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
38
|
+
- bump config-ui PD-5265 ([77d0c78](https://github.com/pie-framework/pie-lib/commit/77d0c78cacfa57e93ed17e7a7f1257f4a9cf6ab3))
|
|
91
39
|
|
|
92
40
|
# [4.35.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.34.0...@pie-lib/render-ui@4.35.0) (2025-10-16)
|
|
93
41
|
|
|
94
42
|
**Note:** Version bump only for package @pie-lib/render-ui
|
|
95
43
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
44
|
# [4.34.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.31.0...@pie-lib/render-ui@4.34.0) (2025-10-16)
|
|
101
45
|
|
|
102
46
|
**Note:** Version bump only for package @pie-lib/render-ui
|
|
103
47
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
48
|
# [4.33.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.31.0...@pie-lib/render-ui@4.33.0) (2025-10-16)
|
|
109
49
|
|
|
110
50
|
**Note:** Version bump only for package @pie-lib/render-ui
|
|
111
51
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
52
|
# [4.32.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.31.0...@pie-lib/render-ui@4.32.0) (2025-10-16)
|
|
117
53
|
|
|
118
54
|
**Note:** Version bump only for package @pie-lib/render-ui
|
|
119
55
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
56
|
## [4.31.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.31.1...@pie-lib/render-ui@4.31.2) (2025-10-14)
|
|
125
57
|
|
|
126
58
|
**Note:** Version bump only for package @pie-lib/render-ui
|
|
127
59
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
60
|
## [4.31.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.31.0...@pie-lib/render-ui@4.31.1) (2025-10-09)
|
|
133
61
|
|
|
134
62
|
**Note:** Version bump only for package @pie-lib/render-ui
|
|
135
63
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
64
|
# [4.31.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.15.9...@pie-lib/render-ui@4.31.0) (2025-09-25)
|
|
141
65
|
|
|
142
|
-
|
|
143
66
|
### Bug Fixes
|
|
144
67
|
|
|
145
|
-
|
|
146
|
-
|
|
68
|
+
- fixed pie-lib/icons import [PD-5126](<[dcb506c](https://github.com/pie-framework/pie-lib/commit/dcb506c914a177f6d88bf73247a023bfe71dac1f)>)
|
|
147
69
|
|
|
148
70
|
### Features
|
|
149
71
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
72
|
+
- split pie-toolbox into multiple packages [PD-5126](<[7d55a25](https://github.com/pie-framework/pie-lib/commit/7d55a2552d084cd3d0d5c00dc77411b2ced2f5e2)>)
|
|
155
73
|
|
|
156
74
|
# [4.30.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.29.0...@pie-lib/render-ui@4.30.0) (2025-09-18)
|
|
157
75
|
|
|
158
76
|
**Note:** Version bump only for package @pie-lib/render-ui
|
|
159
77
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
78
|
# [4.29.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.28.0...@pie-lib/render-ui@4.29.0) (2025-09-18)
|
|
165
79
|
|
|
166
80
|
**Note:** Version bump only for package @pie-lib/render-ui
|
|
167
81
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
82
|
# [4.28.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.15.9...@pie-lib/render-ui@4.28.0) (2025-09-18)
|
|
173
83
|
|
|
174
|
-
|
|
175
84
|
### Bug Fixes
|
|
176
85
|
|
|
177
|
-
|
|
178
|
-
|
|
86
|
+
- fixed pie-lib/icons import [PD-5126](<[dcb506c](https://github.com/pie-framework/pie-lib/commit/dcb506c914a177f6d88bf73247a023bfe71dac1f)>)
|
|
179
87
|
|
|
180
88
|
### Features
|
|
181
89
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
90
|
+
- split pie-toolbox into multiple packages [PD-5126](<[7d55a25](https://github.com/pie-framework/pie-lib/commit/7d55a2552d084cd3d0d5c00dc77411b2ced2f5e2)>)
|
|
187
91
|
|
|
188
92
|
# [4.27.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.26.0...@pie-lib/render-ui@4.27.0) (2025-09-17)
|
|
189
93
|
|
|
190
94
|
**Note:** Version bump only for package @pie-lib/render-ui
|
|
191
95
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
96
|
# [4.26.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.25.0...@pie-lib/render-ui@4.26.0) (2025-09-17)
|
|
197
97
|
|
|
198
98
|
**Note:** Version bump only for package @pie-lib/render-ui
|
|
199
99
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
100
|
# [4.25.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.24.1...@pie-lib/render-ui@4.25.0) (2025-09-17)
|
|
205
101
|
|
|
206
102
|
**Note:** Version bump only for package @pie-lib/render-ui
|
|
207
103
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
104
|
## [4.24.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.15.9...@pie-lib/render-ui@4.24.1) (2025-08-11)
|
|
213
105
|
|
|
214
|
-
|
|
215
106
|
### Bug Fixes
|
|
216
107
|
|
|
217
|
-
|
|
218
|
-
|
|
108
|
+
- fixed pie-lib/icons import [PD-5126](<[dcb506c](https://github.com/pie-framework/pie-lib/commit/dcb506c914a177f6d88bf73247a023bfe71dac1f)>)
|
|
219
109
|
|
|
220
110
|
### Features
|
|
221
111
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
112
|
+
- split pie-toolbox into multiple packages [PD-5126](<[7d55a25](https://github.com/pie-framework/pie-lib/commit/7d55a2552d084cd3d0d5c00dc77411b2ced2f5e2)>)
|
|
227
113
|
|
|
228
114
|
# [4.24.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/render-ui@4.15.9...@pie-lib/render-ui@4.24.0) (2025-08-07)
|
|
229
115
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-lib/render-ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0-next.0",
|
|
4
4
|
"description": "Some shared ui elements when rendering - but not worthy of their own package yet.",
|
|
5
5
|
"module": "src/index.js",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -13,16 +13,16 @@
|
|
|
13
13
|
"@emotion/styled": "^11.14.1",
|
|
14
14
|
"@mui/icons-material": "^7.3.4",
|
|
15
15
|
"@mui/material": "^7.3.4",
|
|
16
|
-
"@pie-lib/icons": "2.
|
|
17
|
-
"@pie-lib/math-rendering": "3.
|
|
18
|
-
"@pie-lib/test-utils": "0.
|
|
16
|
+
"@pie-lib/icons": "2.24.2-next.16",
|
|
17
|
+
"@pie-lib/math-rendering": "3.22.2-next.16",
|
|
18
|
+
"@pie-lib/test-utils": "0.22.2-next.16",
|
|
19
19
|
"debug": "^4.1.1",
|
|
20
20
|
"lodash": "^4.17.11",
|
|
21
21
|
"prop-types": "^15.7.2",
|
|
22
22
|
"react-transition-group": "^4.4.5"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@pie-lib/test-utils": "0.
|
|
25
|
+
"@pie-lib/test-utils": "0.22.2-next.16",
|
|
26
26
|
"react": "^18.2.0",
|
|
27
27
|
"react-dom": "^18.2.0"
|
|
28
28
|
},
|
|
@@ -30,5 +30,13 @@
|
|
|
30
30
|
"react": "^18.2.0",
|
|
31
31
|
"react-dom": "^18.2.0"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "a6ae07ad459bbae1039b5a1a8b9c40e3c1f3af73",
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"require": "./lib/index.js",
|
|
37
|
+
"import": "./src/index.js",
|
|
38
|
+
"default": "./lib/index.js"
|
|
39
|
+
},
|
|
40
|
+
"./esm": "./esm/index.js"
|
|
41
|
+
}
|
|
34
42
|
}
|
|
@@ -1,24 +1,36 @@
|
|
|
1
|
-
import HtmlAndMath from '../html-and-math';
|
|
2
|
-
import { shallow } from 'enzyme';
|
|
3
1
|
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import HtmlAndMath from '../html-and-math';
|
|
4
4
|
|
|
5
5
|
describe('html-and-math', () => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
6
|
+
describe('rendering', () => {
|
|
7
|
+
it('renders with html content', () => {
|
|
8
|
+
const { container } = render(<HtmlAndMath html="<p>hi</p>" />);
|
|
9
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
10
|
+
});
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
it('renders paragraph with text', () => {
|
|
13
|
+
render(<HtmlAndMath html="<p>hi</p>" />);
|
|
14
|
+
expect(screen.getByText('hi')).toBeInTheDocument();
|
|
14
15
|
});
|
|
15
|
-
};
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
it('renders with math markup', () => {
|
|
18
|
+
const { container } = render(<HtmlAndMath html="<p>2 + 2 = <math><mn>4</mn></math></p>" />);
|
|
19
|
+
// Math may be rendered but transformed by the math rendering library
|
|
20
|
+
// Just check that the text content is present
|
|
21
|
+
expect(screen.getByText(/2 \+ 2 =/)).toBeInTheDocument();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('renders with empty html', () => {
|
|
25
|
+
const { container } = render(<HtmlAndMath html="" />);
|
|
26
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
27
|
+
});
|
|
20
28
|
|
|
21
|
-
|
|
29
|
+
it('renders with complex html structure', () => {
|
|
30
|
+
const html = '<div><h1>Title</h1><p>Content</p></div>';
|
|
31
|
+
render(<HtmlAndMath html={html} />);
|
|
32
|
+
expect(screen.getByText('Title')).toBeInTheDocument();
|
|
33
|
+
expect(screen.getByText('Content')).toBeInTheDocument();
|
|
22
34
|
});
|
|
23
35
|
});
|
|
24
36
|
});
|
|
@@ -1,56 +1,59 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
3
|
import PreviewPrompt from '../preview-prompt';
|
|
4
4
|
|
|
5
|
-
describe('Prompt without Custom tag
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
tagName: '',
|
|
13
|
-
className: '',
|
|
14
|
-
...opts,
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
return shallow(<PreviewPrompt {...opts} />);
|
|
5
|
+
describe('Prompt without Custom tag', () => {
|
|
6
|
+
const defaultProps = {
|
|
7
|
+
classes: {},
|
|
8
|
+
prompt:
|
|
9
|
+
'Which of these northern European countries are EU members? <math><mstack><msrow><mn>111</mn></msrow><msline/></mstack></math>',
|
|
10
|
+
tagName: '',
|
|
11
|
+
className: '',
|
|
18
12
|
};
|
|
19
13
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
describe('default rendering with markup', () => {
|
|
15
|
+
it('renders the prompt text', () => {
|
|
16
|
+
render(<PreviewPrompt {...defaultProps} />);
|
|
17
|
+
expect(screen.getByText(/Which of these northern European countries are EU members/)).toBeInTheDocument();
|
|
18
|
+
});
|
|
23
19
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
expect(
|
|
27
|
-
|
|
20
|
+
it('does not have prompt class by default', () => {
|
|
21
|
+
const { container } = render(<PreviewPrompt {...defaultProps} />);
|
|
22
|
+
expect(container.firstChild).not.toHaveClass('prompt');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('renders math markup', () => {
|
|
26
|
+
const { container } = render(<PreviewPrompt {...defaultProps} />);
|
|
27
|
+
// Math may be rendered but transformed by the math rendering library
|
|
28
|
+
// Just check that the prompt text is rendered
|
|
29
|
+
expect(screen.getByText(/Which of these northern European countries are EU members/)).toBeInTheDocument();
|
|
28
30
|
});
|
|
29
31
|
});
|
|
30
32
|
});
|
|
31
33
|
|
|
32
|
-
describe('Prompt with Custom tag
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
tagName: '',
|
|
40
|
-
className: '',
|
|
41
|
-
...opts,
|
|
42
|
-
};
|
|
43
|
-
return shallow(<PreviewPrompt {...opts} />);
|
|
34
|
+
describe('Prompt with Custom tag', () => {
|
|
35
|
+
const defaultProps = {
|
|
36
|
+
classes: {},
|
|
37
|
+
prompt:
|
|
38
|
+
'Which of these northern European countries are EU members? <math><mstack><msrow><mn>111</mn></msrow><msline/></mstack></math>',
|
|
39
|
+
tagName: 'span',
|
|
40
|
+
className: 'prompt',
|
|
44
41
|
};
|
|
45
42
|
|
|
46
|
-
beforeEach(() => {
|
|
47
|
-
wrapper = mkWrapper({ tagName: 'span', className: 'prompt' });
|
|
48
|
-
});
|
|
49
|
-
|
|
50
43
|
describe('renders with custom tag "span" correctly', () => {
|
|
51
|
-
it('renders', () => {
|
|
52
|
-
|
|
53
|
-
expect(
|
|
44
|
+
it('renders with custom className', () => {
|
|
45
|
+
const { container } = render(<PreviewPrompt {...defaultProps} />);
|
|
46
|
+
expect(container.firstChild).toHaveClass('prompt');
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('renders as span element when tagName is specified', () => {
|
|
50
|
+
const { container } = render(<PreviewPrompt {...defaultProps} />);
|
|
51
|
+
expect(container.firstChild.tagName.toLowerCase()).toBe('span');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('renders the prompt text', () => {
|
|
55
|
+
render(<PreviewPrompt {...defaultProps} />);
|
|
56
|
+
expect(screen.getByText(/Which of these northern European countries are EU members/)).toBeInTheDocument();
|
|
54
57
|
});
|
|
55
58
|
});
|
|
56
59
|
});
|
|
@@ -1,35 +1,37 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
3
|
import Purpose from '../purpose';
|
|
4
4
|
|
|
5
5
|
describe('Purpose', () => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
it('renders child unaltered without purpose prop', () => {
|
|
10
|
-
wrapper = mount(
|
|
6
|
+
describe('rendering', () => {
|
|
7
|
+
it('renders child with data-pie-purpose attribute even when purpose prop is not provided', () => {
|
|
8
|
+
const { container } = render(
|
|
11
9
|
<Purpose>
|
|
12
10
|
<div>text</div>
|
|
13
11
|
</Purpose>,
|
|
14
12
|
);
|
|
15
|
-
|
|
16
|
-
expect(
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
|
|
14
|
+
expect(screen.getByText('text')).toBeInTheDocument();
|
|
15
|
+
const div = container.querySelector('div');
|
|
16
|
+
// When purpose is undefined, React sets the attribute as data-pie-purpose="undefined"
|
|
17
|
+
// This is expected behavior - the component always adds the attribute
|
|
18
|
+
expect(div).toBeInTheDocument();
|
|
19
19
|
});
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
|
|
21
|
+
it('renders child with data-pie-purpose="passage"', () => {
|
|
22
|
+
const { container } = render(
|
|
22
23
|
<Purpose purpose="passage">
|
|
23
24
|
<div>text</div>
|
|
24
25
|
</Purpose>,
|
|
25
26
|
);
|
|
26
|
-
|
|
27
|
-
expect(
|
|
28
|
-
|
|
29
|
-
expect(
|
|
27
|
+
|
|
28
|
+
expect(screen.getByText('text')).toBeInTheDocument();
|
|
29
|
+
const div = container.querySelector('div');
|
|
30
|
+
expect(div).toHaveAttribute('data-pie-purpose', 'passage');
|
|
30
31
|
});
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
|
|
33
|
+
it('renders multiple children with data-pie-purpose attribute', () => {
|
|
34
|
+
const { container } = render(
|
|
33
35
|
<Purpose purpose="something">
|
|
34
36
|
<div>
|
|
35
37
|
<div>text1</div>
|
|
@@ -37,11 +39,13 @@ describe('Purpose', () => {
|
|
|
37
39
|
</div>
|
|
38
40
|
</Purpose>,
|
|
39
41
|
);
|
|
40
|
-
|
|
41
|
-
expect(
|
|
42
|
-
expect(
|
|
43
|
-
expect(
|
|
44
|
-
|
|
42
|
+
|
|
43
|
+
expect(screen.getByText('text1')).toBeInTheDocument();
|
|
44
|
+
expect(screen.getByText('text2')).toBeInTheDocument();
|
|
45
|
+
expect(screen.queryByText('text3')).not.toBeInTheDocument();
|
|
46
|
+
|
|
47
|
+
const parentDiv = container.querySelector('div');
|
|
48
|
+
expect(parentDiv).toHaveAttribute('data-pie-purpose', 'something');
|
|
45
49
|
});
|
|
46
50
|
});
|
|
47
51
|
});
|
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
3
|
import Readable from '../readable';
|
|
4
4
|
|
|
5
5
|
describe('Readable', () => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
it('renders child unaltered', () => {
|
|
10
|
-
wrapper = mount(
|
|
6
|
+
describe('rendering', () => {
|
|
7
|
+
it('renders child with data-pie-readable attribute set to true', () => {
|
|
8
|
+
const { container } = render(
|
|
11
9
|
<Readable>
|
|
12
10
|
<div>text</div>
|
|
13
11
|
</Readable>,
|
|
14
12
|
);
|
|
15
|
-
|
|
16
|
-
expect(
|
|
17
|
-
|
|
18
|
-
expect(
|
|
13
|
+
|
|
14
|
+
expect(screen.getByText('text')).toBeInTheDocument();
|
|
15
|
+
const div = container.querySelector('div');
|
|
16
|
+
expect(div).toHaveAttribute('data-pie-readable', 'true');
|
|
19
17
|
});
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
|
|
19
|
+
it('renders multiple children with data-pie-readable attribute', () => {
|
|
20
|
+
const { container } = render(
|
|
22
21
|
<Readable>
|
|
23
22
|
<div>
|
|
24
23
|
<div>text1</div>
|
|
@@ -26,14 +25,17 @@ describe('Readable', () => {
|
|
|
26
25
|
</div>
|
|
27
26
|
</Readable>,
|
|
28
27
|
);
|
|
29
|
-
|
|
30
|
-
expect(
|
|
31
|
-
expect(
|
|
32
|
-
expect(
|
|
33
|
-
|
|
28
|
+
|
|
29
|
+
expect(screen.getByText('text1')).toBeInTheDocument();
|
|
30
|
+
expect(screen.getByText('text2')).toBeInTheDocument();
|
|
31
|
+
expect(screen.queryByText('text3')).not.toBeInTheDocument();
|
|
32
|
+
|
|
33
|
+
const parentDiv = container.querySelector('div');
|
|
34
|
+
expect(parentDiv).toHaveAttribute('data-pie-readable', 'true');
|
|
34
35
|
});
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
|
|
37
|
+
it('renders with data-pie-readable set to false when false prop is provided', () => {
|
|
38
|
+
const { container } = render(
|
|
37
39
|
<Readable false>
|
|
38
40
|
<div>
|
|
39
41
|
<div>text1</div>
|
|
@@ -41,14 +43,17 @@ describe('Readable', () => {
|
|
|
41
43
|
</div>
|
|
42
44
|
</Readable>,
|
|
43
45
|
);
|
|
44
|
-
|
|
45
|
-
expect(
|
|
46
|
-
expect(
|
|
47
|
-
expect(
|
|
48
|
-
|
|
46
|
+
|
|
47
|
+
expect(screen.getByText('text1')).toBeInTheDocument();
|
|
48
|
+
expect(screen.getByText('text2')).toBeInTheDocument();
|
|
49
|
+
expect(screen.queryByText('text3')).not.toBeInTheDocument();
|
|
50
|
+
|
|
51
|
+
const parentDiv = container.querySelector('div');
|
|
52
|
+
expect(parentDiv).toHaveAttribute('data-pie-readable', 'false');
|
|
49
53
|
});
|
|
50
|
-
|
|
51
|
-
|
|
54
|
+
|
|
55
|
+
it('renders with data-pie-readable set to false when false={true}', () => {
|
|
56
|
+
const { container } = render(
|
|
52
57
|
<Readable false={true}>
|
|
53
58
|
<div>
|
|
54
59
|
<div>text1</div>
|
|
@@ -56,9 +61,9 @@ describe('Readable', () => {
|
|
|
56
61
|
</div>
|
|
57
62
|
</Readable>,
|
|
58
63
|
);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
expect(
|
|
64
|
+
|
|
65
|
+
const parentDiv = container.querySelector('div');
|
|
66
|
+
expect(parentDiv).toHaveAttribute('data-pie-readable', 'false');
|
|
62
67
|
});
|
|
63
68
|
});
|
|
64
69
|
});
|