@pie-lib/render-ui 6.1.1-next.36 → 6.1.1-next.37
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/dist/_virtual/_rolldown/runtime.js +11 -0
- package/dist/assets/enableAudioAutoplayImage.d.ts +10 -0
- package/dist/assets/enableAudioAutoplayImage.js +4 -0
- package/dist/collapsible/index.d.ts +31 -0
- package/dist/collapsible/index.js +53 -0
- package/dist/color.d.ts +116 -0
- package/dist/color.js +120 -0
- package/dist/feedback.d.ts +20 -0
- package/dist/feedback.js +65 -0
- package/dist/has-media.d.ts +9 -0
- package/dist/has-media.js +10 -0
- package/dist/has-text.d.ts +9 -0
- package/dist/has-text.js +10 -0
- package/dist/html-and-math.d.ts +22 -0
- package/dist/html-and-math.js +25 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +18 -0
- package/dist/inline-menu.d.ts +33 -0
- package/dist/inline-menu.js +29 -0
- package/dist/input-container.d.ts +23 -0
- package/dist/input-container.js +39 -0
- package/dist/preview-layout.d.ts +24 -0
- package/dist/preview-layout.js +37 -0
- package/dist/preview-prompt.d.ts +38 -0
- package/dist/preview-prompt.js +154 -0
- package/dist/purpose.d.ts +18 -0
- package/dist/purpose.js +11 -0
- package/dist/readable.d.ts +18 -0
- package/dist/readable.js +11 -0
- package/dist/response-indicators.d.ts +121 -0
- package/dist/response-indicators.js +62 -0
- package/{src/transform-headings.js → dist/transform-headings.d.ts} +9 -30
- package/dist/transform-headings.js +15 -0
- package/dist/ui-layout.d.ts +31 -0
- package/dist/ui-layout.js +55 -0
- package/dist/withUndoReset.d.ts +47 -0
- package/dist/withUndoReset.js +84 -0
- package/package.json +32 -20
- package/CHANGELOG.json +0 -1
- package/CHANGELOG.md +0 -1144
- package/LICENSE.md +0 -5
- package/lib/assets/enableAudioAutoplayImage.js +0 -8
- package/lib/assets/enableAudioAutoplayImage.js.map +0 -1
- package/lib/collapsible/index.js +0 -105
- package/lib/collapsible/index.js.map +0 -1
- package/lib/color.js +0 -235
- package/lib/color.js.map +0 -1
- package/lib/feedback.js +0 -112
- package/lib/feedback.js.map +0 -1
- package/lib/has-media.js +0 -22
- package/lib/has-media.js.map +0 -1
- package/lib/has-text.js +0 -22
- package/lib/has-text.js.map +0 -1
- package/lib/html-and-math.js +0 -54
- package/lib/html-and-math.js.map +0 -1
- package/lib/index.js +0 -113
- package/lib/index.js.map +0 -1
- package/lib/input-container.js +0 -59
- package/lib/input-container.js.map +0 -1
- package/lib/preview-layout.js +0 -65
- package/lib/preview-layout.js.map +0 -1
- package/lib/preview-prompt.js +0 -299
- package/lib/preview-prompt.js.map +0 -1
- package/lib/purpose.js +0 -22
- package/lib/purpose.js.map +0 -1
- package/lib/readable.js +0 -22
- package/lib/readable.js.map +0 -1
- package/lib/response-indicators.js +0 -102
- package/lib/response-indicators.js.map +0 -1
- package/lib/transform-headings.js +0 -53
- package/lib/transform-headings.js.map +0 -1
- package/lib/ui-layout.js +0 -125
- package/lib/ui-layout.js.map +0 -1
- package/lib/withUndoReset.js +0 -135
- package/lib/withUndoReset.js.map +0 -1
- package/src/__tests__/color.test.js +0 -259
- package/src/__tests__/feedback.test.jsx +0 -279
- package/src/__tests__/has-media.test.js +0 -19
- package/src/__tests__/has-text.test.js +0 -20
- package/src/__tests__/html-and-math.test.js +0 -36
- package/src/__tests__/input-container.test.jsx +0 -328
- package/src/__tests__/preview-layout.test.jsx +0 -349
- package/src/__tests__/preview-prompt.test.jsx +0 -379
- package/src/__tests__/purpose.test.jsx +0 -51
- package/src/__tests__/readable.test.jsx +0 -69
- package/src/__tests__/response-indicators.test.jsx +0 -111
- package/src/__tests__/ui-layout.test.jsx +0 -52
- package/src/__tests__/withUndoReset.test.jsx +0 -176
- package/src/assets/enableAudioAutoplayImage.js +0 -1
- package/src/collapsible/__tests__/index.test.jsx +0 -39
- package/src/collapsible/index.jsx +0 -64
- package/src/color.js +0 -139
- package/src/feedback.jsx +0 -84
- package/src/has-media.js +0 -16
- package/src/has-text.js +0 -18
- package/src/html-and-math.js +0 -21
- package/src/index.js +0 -35
- package/src/input-container.jsx +0 -47
- package/src/preview-layout.jsx +0 -41
- package/src/preview-prompt.jsx +0 -280
- package/src/purpose.jsx +0 -17
- package/src/readable.jsx +0 -19
- package/src/response-indicators.jsx +0 -82
- package/src/ui-layout.jsx +0 -96
- package/src/withUndoReset.jsx +0 -114
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { renderWithTheme, screen } from '@pie-lib/test-utils';
|
|
3
|
-
import { Feedback } from '../feedback';
|
|
4
|
-
|
|
5
|
-
describe('Feedback', () => {
|
|
6
|
-
describe('rendering', () => {
|
|
7
|
-
it('should render feedback when correctness and feedback are provided', () => {
|
|
8
|
-
renderWithTheme(<Feedback correctness="correct" feedback="Great job!" />);
|
|
9
|
-
expect(screen.getByText('Great job!')).toBeInTheDocument();
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('should not render feedback when correctness is missing', () => {
|
|
13
|
-
renderWithTheme(<Feedback feedback="Great job!" />);
|
|
14
|
-
expect(screen.queryByText('Great job!')).not.toBeInTheDocument();
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('should not render feedback when feedback text is missing', () => {
|
|
18
|
-
renderWithTheme(<Feedback correctness="correct" />);
|
|
19
|
-
const { container } = renderWithTheme(<Feedback correctness="correct" />);
|
|
20
|
-
expect(container.querySelector('[class*="feedback"]')).not.toBeInTheDocument();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('should not render feedback when both correctness and feedback are missing', () => {
|
|
24
|
-
const { container } = renderWithTheme(<Feedback />);
|
|
25
|
-
expect(container.querySelector('[class*="FeedbackContent"]')).not.toBeInTheDocument();
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('should render feedback with HTML content', () => {
|
|
29
|
-
renderWithTheme(<Feedback correctness="correct" feedback="<strong>Excellent!</strong> You got it right." />);
|
|
30
|
-
expect(screen.getByText(/Excellent!/)).toBeInTheDocument();
|
|
31
|
-
expect(screen.getByText(/You got it right/)).toBeInTheDocument();
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
describe('correctness states', () => {
|
|
36
|
-
it('should render with correct class when correctness is "correct"', () => {
|
|
37
|
-
const { container } = renderWithTheme(<Feedback correctness="correct" feedback="Correct!" />);
|
|
38
|
-
const feedbackElement = container.querySelector('.correct');
|
|
39
|
-
expect(feedbackElement).toBeInTheDocument();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('should render with incorrect class when correctness is "incorrect"', () => {
|
|
43
|
-
const { container } = renderWithTheme(<Feedback correctness="incorrect" feedback="Try again!" />);
|
|
44
|
-
const feedbackElement = container.querySelector('.incorrect');
|
|
45
|
-
expect(feedbackElement).toBeInTheDocument();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('should render with partial class when correctness is "partial"', () => {
|
|
49
|
-
const { container } = renderWithTheme(<Feedback correctness="partial" feedback="Partially correct" />);
|
|
50
|
-
expect(screen.getByText('Partially correct')).toBeInTheDocument();
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('should handle unknown correctness values', () => {
|
|
54
|
-
const { container } = renderWithTheme(<Feedback correctness="unknown" feedback="Unknown state" />);
|
|
55
|
-
expect(screen.getByText('Unknown state')).toBeInTheDocument();
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
describe('feedback content', () => {
|
|
60
|
-
it('should render simple text feedback', () => {
|
|
61
|
-
renderWithTheme(<Feedback correctness="correct" feedback="Well done!" />);
|
|
62
|
-
expect(screen.getByText('Well done!')).toBeInTheDocument();
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('should render feedback with special characters', () => {
|
|
66
|
-
renderWithTheme(<Feedback correctness="incorrect" feedback="You selected 2 + 2 = 5. That's incorrect!" />);
|
|
67
|
-
expect(screen.getByText(/You selected 2 \+ 2 = 5/)).toBeInTheDocument();
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('should render feedback with math markup', () => {
|
|
71
|
-
renderWithTheme(<Feedback correctness="correct" feedback="The answer is <math><mn>42</mn></math>" />);
|
|
72
|
-
expect(screen.getByText(/The answer is/)).toBeInTheDocument();
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('should render feedback with multiple HTML elements', () => {
|
|
76
|
-
renderWithTheme(
|
|
77
|
-
<Feedback correctness="correct" feedback="<p>Great!</p><ul><li>Point 1</li><li>Point 2</li></ul>" />,
|
|
78
|
-
);
|
|
79
|
-
expect(screen.getByText(/Great!/)).toBeInTheDocument();
|
|
80
|
-
expect(screen.getByText(/Point 1/)).toBeInTheDocument();
|
|
81
|
-
expect(screen.getByText(/Point 2/)).toBeInTheDocument();
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it('should handle empty string feedback', () => {
|
|
85
|
-
renderWithTheme(<Feedback correctness="correct" feedback="" />);
|
|
86
|
-
// Empty feedback should not render
|
|
87
|
-
const { container } = renderWithTheme(<Feedback correctness="correct" feedback="" />);
|
|
88
|
-
expect(container.querySelector('[class*="FeedbackContent"]')).not.toBeInTheDocument();
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('should render feedback with line breaks', () => {
|
|
92
|
-
renderWithTheme(<Feedback correctness="incorrect" feedback="Line 1<br/>Line 2<br/>Line 3" />);
|
|
93
|
-
expect(screen.getByText(/Line 1/)).toBeInTheDocument();
|
|
94
|
-
expect(screen.getByText(/Line 2/)).toBeInTheDocument();
|
|
95
|
-
expect(screen.getByText(/Line 3/)).toBeInTheDocument();
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
describe('TransitionGroup integration', () => {
|
|
100
|
-
it('should use TransitionGroup for animations', () => {
|
|
101
|
-
const { container } = renderWithTheme(<Feedback correctness="correct" feedback="Animated feedback" />);
|
|
102
|
-
// TransitionGroup should be present
|
|
103
|
-
expect(container.querySelector('[class*="transition"]')).toBeDefined();
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it('should handle feedback changes', () => {
|
|
107
|
-
const { rerender } = renderWithTheme(<Feedback correctness="correct" feedback="Initial feedback" />);
|
|
108
|
-
expect(screen.getByText('Initial feedback')).toBeInTheDocument();
|
|
109
|
-
|
|
110
|
-
rerender(<Feedback correctness="incorrect" feedback="Updated feedback" />);
|
|
111
|
-
expect(screen.getByText('Updated feedback')).toBeInTheDocument();
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it('should handle feedback addition', () => {
|
|
115
|
-
const { rerender } = renderWithTheme(<Feedback />);
|
|
116
|
-
expect(screen.queryByText('New feedback')).not.toBeInTheDocument();
|
|
117
|
-
|
|
118
|
-
rerender(<Feedback correctness="correct" feedback="New feedback" />);
|
|
119
|
-
expect(screen.getByText('New feedback')).toBeInTheDocument();
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
describe('CSSTransition configuration', () => {
|
|
124
|
-
it('should render with CSSTransition wrapper', () => {
|
|
125
|
-
const { container } = renderWithTheme(<Feedback correctness="correct" feedback="Test feedback" />);
|
|
126
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
it('should have nodeRef for CSSTransition', () => {
|
|
130
|
-
const feedback = new Feedback({ correctness: 'correct', feedback: 'Test' });
|
|
131
|
-
expect(feedback.nodeRef).toBeDefined();
|
|
132
|
-
expect(feedback.nodeRef.current).toBe(null);
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
describe('styling classes', () => {
|
|
137
|
-
it('should apply FeedbackContainer class', () => {
|
|
138
|
-
const { container } = renderWithTheme(<Feedback correctness="correct" feedback="Test" />);
|
|
139
|
-
expect(container.querySelector('[class*="Feedback"]')).toBeDefined();
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
it('should apply correct styling for correct feedback', () => {
|
|
143
|
-
const { container } = renderWithTheme(<Feedback correctness="correct" feedback="Correct answer!" />);
|
|
144
|
-
const correctElement = container.querySelector('.correct');
|
|
145
|
-
expect(correctElement).toBeInTheDocument();
|
|
146
|
-
expect(correctElement).toHaveTextContent('Correct answer!');
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
it('should apply incorrect styling for incorrect feedback', () => {
|
|
150
|
-
const { container } = renderWithTheme(<Feedback correctness="incorrect" feedback="Wrong answer" />);
|
|
151
|
-
const incorrectElement = container.querySelector('.incorrect');
|
|
152
|
-
expect(incorrectElement).toBeInTheDocument();
|
|
153
|
-
expect(incorrectElement).toHaveTextContent('Wrong answer');
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
describe('edge cases', () => {
|
|
158
|
-
it('should handle null correctness', () => {
|
|
159
|
-
renderWithTheme(<Feedback correctness={null} feedback="Test" />);
|
|
160
|
-
expect(screen.queryByText('Test')).not.toBeInTheDocument();
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
it('should handle undefined correctness', () => {
|
|
164
|
-
renderWithTheme(<Feedback correctness={undefined} feedback="Test" />);
|
|
165
|
-
expect(screen.queryByText('Test')).not.toBeInTheDocument();
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it('should handle null feedback', () => {
|
|
169
|
-
renderWithTheme(<Feedback correctness="correct" feedback={null} />);
|
|
170
|
-
const { container } = renderWithTheme(<Feedback correctness="correct" feedback={null} />);
|
|
171
|
-
expect(container.querySelector('[class*="FeedbackContent"]')).not.toBeInTheDocument();
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
it('should handle undefined feedback', () => {
|
|
175
|
-
renderWithTheme(<Feedback correctness="correct" feedback={undefined} />);
|
|
176
|
-
const { container } = renderWithTheme(<Feedback correctness="correct" feedback={undefined} />);
|
|
177
|
-
expect(container.querySelector('[class*="FeedbackContent"]')).not.toBeInTheDocument();
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
it('should handle very long feedback text', () => {
|
|
181
|
-
const longFeedback = 'A'.repeat(1000);
|
|
182
|
-
renderWithTheme(<Feedback correctness="correct" feedback={longFeedback} />);
|
|
183
|
-
expect(screen.getByText(longFeedback)).toBeInTheDocument();
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
describe('dangerouslySetInnerHTML', () => {
|
|
188
|
-
it('should render HTML safely using dangerouslySetInnerHTML', () => {
|
|
189
|
-
renderWithTheme(<Feedback correctness="correct" feedback='<span id="test-span">HTML Content</span>' />);
|
|
190
|
-
const htmlElement = document.getElementById('test-span');
|
|
191
|
-
expect(htmlElement).toBeInTheDocument();
|
|
192
|
-
expect(htmlElement).toHaveTextContent('HTML Content');
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
it('should handle complex nested HTML', () => {
|
|
196
|
-
renderWithTheme(<Feedback correctness="incorrect" feedback="<div><p>Paragraph 1</p><p>Paragraph 2</p></div>" />);
|
|
197
|
-
expect(screen.getByText('Paragraph 1')).toBeInTheDocument();
|
|
198
|
-
expect(screen.getByText('Paragraph 2')).toBeInTheDocument();
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
it('should render HTML with inline styles', () => {
|
|
202
|
-
renderWithTheme(<Feedback correctness="correct" feedback='<span style="color: red;">Styled text</span>' />);
|
|
203
|
-
expect(screen.getByText('Styled text')).toBeInTheDocument();
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
describe('component lifecycle', () => {
|
|
208
|
-
it('should render correctly on mount', () => {
|
|
209
|
-
renderWithTheme(<Feedback correctness="correct" feedback="Mounted feedback" />);
|
|
210
|
-
expect(screen.getByText('Mounted feedback')).toBeInTheDocument();
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
it('should update correctly when props change', () => {
|
|
214
|
-
const { rerender } = renderWithTheme(<Feedback correctness="correct" feedback="Original" />);
|
|
215
|
-
expect(screen.getByText('Original')).toBeInTheDocument();
|
|
216
|
-
|
|
217
|
-
rerender(<Feedback correctness="incorrect" feedback="Changed" />);
|
|
218
|
-
expect(screen.getByText('Changed')).toBeInTheDocument();
|
|
219
|
-
expect(screen.queryByText('Original')).not.toBeInTheDocument();
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
it('should handle multiple rapid updates', () => {
|
|
223
|
-
const { rerender } = renderWithTheme(<Feedback correctness="correct" feedback="V1" />);
|
|
224
|
-
|
|
225
|
-
rerender(<Feedback correctness="incorrect" feedback="V2" />);
|
|
226
|
-
rerender(<Feedback correctness="correct" feedback="V3" />);
|
|
227
|
-
rerender(<Feedback correctness="incorrect" feedback="V4" />);
|
|
228
|
-
|
|
229
|
-
expect(screen.getByText('V4')).toBeInTheDocument();
|
|
230
|
-
expect(screen.queryByText('V1')).not.toBeInTheDocument();
|
|
231
|
-
expect(screen.queryByText('V2')).not.toBeInTheDocument();
|
|
232
|
-
expect(screen.queryByText('V3')).not.toBeInTheDocument();
|
|
233
|
-
});
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
describe('accessibility', () => {
|
|
237
|
-
it('should render accessible content structure', () => {
|
|
238
|
-
const { container } = renderWithTheme(<Feedback correctness="correct" feedback="Accessible feedback" />);
|
|
239
|
-
expect(screen.getByText('Accessible feedback')).toBeInTheDocument();
|
|
240
|
-
expect(container.textContent).toContain('Accessible feedback');
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
it('should preserve semantic HTML in feedback', () => {
|
|
244
|
-
renderWithTheme(<Feedback correctness="correct" feedback="<strong>Important:</strong> Good work!" />);
|
|
245
|
-
const strongElement = document.querySelector('strong');
|
|
246
|
-
expect(strongElement).toBeInTheDocument();
|
|
247
|
-
expect(strongElement).toHaveTextContent('Important:');
|
|
248
|
-
});
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
describe('integration scenarios', () => {
|
|
252
|
-
it('should work in a typical correct answer scenario', () => {
|
|
253
|
-
renderWithTheme(
|
|
254
|
-
<Feedback correctness="correct" feedback="<strong>Correct!</strong> You identified the right answer." />,
|
|
255
|
-
);
|
|
256
|
-
const container = screen.getByText(/Correct!/);
|
|
257
|
-
expect(container).toBeInTheDocument();
|
|
258
|
-
expect(screen.getByText(/You identified the right answer/)).toBeInTheDocument();
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
it('should work in a typical incorrect answer scenario', () => {
|
|
262
|
-
renderWithTheme(
|
|
263
|
-
<Feedback
|
|
264
|
-
correctness="incorrect"
|
|
265
|
-
feedback="<strong>Incorrect.</strong> Please review the material and try again."
|
|
266
|
-
/>,
|
|
267
|
-
);
|
|
268
|
-
expect(screen.getByText(/Incorrect/)).toBeInTheDocument();
|
|
269
|
-
expect(screen.getByText(/Please review the material/)).toBeInTheDocument();
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
it('should work in a partially correct scenario', () => {
|
|
273
|
-
renderWithTheme(
|
|
274
|
-
<Feedback correctness="partial" feedback="You got some parts correct, but missed a few key points." />,
|
|
275
|
-
);
|
|
276
|
-
expect(screen.getByText(/You got some parts correct/)).toBeInTheDocument();
|
|
277
|
-
});
|
|
278
|
-
});
|
|
279
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { hasMedia } from '../has-media'; // Assuming you have a hasMedia function
|
|
2
|
-
|
|
3
|
-
describe('hasMedia', () => {
|
|
4
|
-
it.each`
|
|
5
|
-
input | expected
|
|
6
|
-
${'<img src="image.jpg" />'} | ${true}
|
|
7
|
-
${'<audio src="audio.mp3" />'} | ${true}
|
|
8
|
-
${'<div><img src="image.jpg" /></div>'} | ${true}
|
|
9
|
-
${'<div><audio src="audio.mp3" /></div>'} | ${true}
|
|
10
|
-
${'<div>No media here</div>'} | ${false}
|
|
11
|
-
${'<div></div>'} | ${false}
|
|
12
|
-
${' '} | ${false}
|
|
13
|
-
${null} | ${false}
|
|
14
|
-
`('$input -> $expected', ({ input, expected }) => {
|
|
15
|
-
const output = hasMedia(input);
|
|
16
|
-
|
|
17
|
-
expect(output).toEqual(expected);
|
|
18
|
-
});
|
|
19
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { hasText } from '../has-text';
|
|
2
|
-
|
|
3
|
-
describe('has-text', () => {
|
|
4
|
-
it.each`
|
|
5
|
-
input | expected
|
|
6
|
-
${'<div>Rationale</div>'} | ${true}
|
|
7
|
-
${'Rationale'} | ${true}
|
|
8
|
-
${'<div>hi</div>'} | ${true}
|
|
9
|
-
${'<div>hi'} | ${true}
|
|
10
|
-
${'<div></div>'} | ${false}
|
|
11
|
-
${'<div> </div>'} | ${false}
|
|
12
|
-
${'<div><br /> </div>'} | ${false}
|
|
13
|
-
${' '} | ${false}
|
|
14
|
-
${null} | ${false}
|
|
15
|
-
`('$input -> $expected', ({ input, expected }) => {
|
|
16
|
-
const output = hasText(input);
|
|
17
|
-
|
|
18
|
-
expect(output).toEqual(expected);
|
|
19
|
-
});
|
|
20
|
-
});
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import HtmlAndMath from '../html-and-math';
|
|
4
|
-
|
|
5
|
-
describe('html-and-math', () => {
|
|
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
|
-
|
|
12
|
-
it('renders paragraph with text', () => {
|
|
13
|
-
render(<HtmlAndMath html="<p>hi</p>" />);
|
|
14
|
-
expect(screen.getByText('hi')).toBeInTheDocument();
|
|
15
|
-
});
|
|
16
|
-
|
|
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
|
-
});
|
|
28
|
-
|
|
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();
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
});
|