@madie/madie-design-system 1.2.71 → 1.2.73
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/components/RichTextEditor/index.jsx +358 -341
- package/dist/browser.js +1 -1
- package/dist/index.js +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
- package/test/components/RichTextEditor.test.js +31 -29
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@ beforeAll(() => {
|
|
|
13
13
|
width: 0,
|
|
14
14
|
height: 0
|
|
15
15
|
}]);
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
Element.prototype.scrollIntoView = jest.fn();
|
|
18
18
|
|
|
19
19
|
window.getSelection = jest.fn(() => ({
|
|
@@ -116,6 +116,8 @@ describe("RichTextEditor Component", () => {
|
|
|
116
116
|
const editorContent = screen.getByTestId("test-editor-value");
|
|
117
117
|
expect(editorContent).toBeInTheDocument();
|
|
118
118
|
expect(editorContent).toHaveTextContent("Safe Content");
|
|
119
|
+
const editorLabel = screen.getByText("Test Label");
|
|
120
|
+
expect(editorLabel).toBeInTheDocument();
|
|
119
121
|
});
|
|
120
122
|
|
|
121
123
|
it("test renders sanitized content with preserved whitespace when readOnly is true", () => {
|
|
@@ -188,11 +190,11 @@ describe("RichTextEditor Component", () => {
|
|
|
188
190
|
beforeEach(() => {
|
|
189
191
|
mockOnChange.mockClear();
|
|
190
192
|
jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
191
|
-
|
|
193
|
+
|
|
192
194
|
Element.prototype.getClientRects.mockClear();
|
|
193
195
|
Element.prototype.scrollIntoView.mockClear();
|
|
194
196
|
});
|
|
195
|
-
|
|
197
|
+
|
|
196
198
|
afterEach(() => {
|
|
197
199
|
console.error.mockRestore();
|
|
198
200
|
});
|
|
@@ -206,7 +208,7 @@ describe("RichTextEditor Component", () => {
|
|
|
206
208
|
content="<table><tr><td>Cell content</td></tr></table>"
|
|
207
209
|
/>,
|
|
208
210
|
);
|
|
209
|
-
|
|
211
|
+
|
|
210
212
|
expect(screen.getByLabelText("Add row above")).toBeInTheDocument();
|
|
211
213
|
expect(screen.getByLabelText("Add row below")).toBeInTheDocument();
|
|
212
214
|
expect(screen.getByLabelText("Remove row")).toBeInTheDocument();
|
|
@@ -215,7 +217,7 @@ describe("RichTextEditor Component", () => {
|
|
|
215
217
|
expect(screen.getByLabelText("Remove column")).toBeInTheDocument();
|
|
216
218
|
expect(screen.getByLabelText("Remove table")).toBeInTheDocument();
|
|
217
219
|
});
|
|
218
|
-
|
|
220
|
+
|
|
219
221
|
it("triggers Add row above button", async () => {
|
|
220
222
|
const mockChain = {
|
|
221
223
|
focus: jest.fn().mockReturnThis(),
|
|
@@ -224,7 +226,7 @@ describe("RichTextEditor Component", () => {
|
|
|
224
226
|
mockOnChange("<table><tr><td>New row</td></tr><tr><td>Cell content</td></tr></table>");
|
|
225
227
|
})
|
|
226
228
|
};
|
|
227
|
-
|
|
229
|
+
|
|
228
230
|
const { getByLabelText } = render(
|
|
229
231
|
<RichTextEditor
|
|
230
232
|
id="test-editor"
|
|
@@ -233,18 +235,18 @@ describe("RichTextEditor Component", () => {
|
|
|
233
235
|
content="<table><tr><td>Cell content</td></tr></table>"
|
|
234
236
|
/>
|
|
235
237
|
);
|
|
236
|
-
|
|
238
|
+
|
|
237
239
|
const button = getByLabelText("Add row above");
|
|
238
240
|
const originalOnClick = button.onclick;
|
|
239
241
|
button.onclick = () => {
|
|
240
242
|
mockOnChange("<table><tr><td>New row</td></tr><tr><td>Cell content</td></tr></table>");
|
|
241
243
|
};
|
|
242
|
-
|
|
244
|
+
|
|
243
245
|
await userEvent.click(button);
|
|
244
|
-
|
|
246
|
+
|
|
245
247
|
expect(mockOnChange).toHaveBeenCalled();
|
|
246
248
|
});
|
|
247
|
-
|
|
249
|
+
|
|
248
250
|
it("triggers Remove row button", async () => {
|
|
249
251
|
const { getByLabelText } = render(
|
|
250
252
|
<RichTextEditor
|
|
@@ -254,18 +256,18 @@ describe("RichTextEditor Component", () => {
|
|
|
254
256
|
content="<table><tr><td>Cell content</td></tr><tr><td>Another row</td></tr></table>"
|
|
255
257
|
/>
|
|
256
258
|
);
|
|
257
|
-
|
|
259
|
+
|
|
258
260
|
const button = getByLabelText("Remove row");
|
|
259
261
|
const originalOnClick = button.onclick;
|
|
260
262
|
button.onclick = () => {
|
|
261
263
|
mockOnChange("<table><tr><td>Cell content</td></tr></table>");
|
|
262
264
|
};
|
|
263
|
-
|
|
265
|
+
|
|
264
266
|
await userEvent.click(button);
|
|
265
|
-
|
|
267
|
+
|
|
266
268
|
expect(mockOnChange).toHaveBeenCalled();
|
|
267
269
|
});
|
|
268
|
-
|
|
270
|
+
|
|
269
271
|
it("triggers Add column left button", async () => {
|
|
270
272
|
const { getByLabelText } = render(
|
|
271
273
|
<RichTextEditor
|
|
@@ -275,17 +277,17 @@ describe("RichTextEditor Component", () => {
|
|
|
275
277
|
content="<table><tr><td>Cell content</td></tr></table>"
|
|
276
278
|
/>
|
|
277
279
|
);
|
|
278
|
-
|
|
280
|
+
|
|
279
281
|
const button = getByLabelText("Add column left");
|
|
280
282
|
button.onclick = () => {
|
|
281
283
|
mockOnChange("<table><tr><td>New column</td><td>Cell content</td></tr></table>");
|
|
282
284
|
};
|
|
283
|
-
|
|
285
|
+
|
|
284
286
|
fireEvent.click(button);
|
|
285
|
-
|
|
287
|
+
|
|
286
288
|
expect(mockOnChange).toHaveBeenCalled();
|
|
287
289
|
});
|
|
288
|
-
|
|
290
|
+
|
|
289
291
|
it("triggers Add column right button", async () => {
|
|
290
292
|
const { getByLabelText } = render(
|
|
291
293
|
<RichTextEditor
|
|
@@ -295,17 +297,17 @@ describe("RichTextEditor Component", () => {
|
|
|
295
297
|
content="<table><tr><td>Cell content</td></tr></table>"
|
|
296
298
|
/>
|
|
297
299
|
);
|
|
298
|
-
|
|
300
|
+
|
|
299
301
|
const button = getByLabelText("Add column right");
|
|
300
302
|
button.onclick = () => {
|
|
301
303
|
mockOnChange("<table><tr><td>Cell content</td><td>New column</td></tr></table>");
|
|
302
304
|
};
|
|
303
|
-
|
|
305
|
+
|
|
304
306
|
fireEvent.click(button);
|
|
305
|
-
|
|
307
|
+
|
|
306
308
|
expect(mockOnChange).toHaveBeenCalled();
|
|
307
309
|
});
|
|
308
|
-
|
|
310
|
+
|
|
309
311
|
it("triggers Remove column button", async () => {
|
|
310
312
|
const { getByLabelText } = render(
|
|
311
313
|
<RichTextEditor
|
|
@@ -315,17 +317,17 @@ describe("RichTextEditor Component", () => {
|
|
|
315
317
|
content="<table><tr><td>Col 1</td><td>Col 2</td></tr></table>"
|
|
316
318
|
/>
|
|
317
319
|
);
|
|
318
|
-
|
|
320
|
+
|
|
319
321
|
const button = getByLabelText("Remove column");
|
|
320
322
|
button.onclick = () => {
|
|
321
323
|
mockOnChange("<table><tr><td>Col 1</td></tr></table>");
|
|
322
324
|
};
|
|
323
|
-
|
|
325
|
+
|
|
324
326
|
fireEvent.click(button);
|
|
325
|
-
|
|
327
|
+
|
|
326
328
|
expect(mockOnChange).toHaveBeenCalled();
|
|
327
329
|
});
|
|
328
|
-
|
|
330
|
+
|
|
329
331
|
it("triggers Remove table button", async () => {
|
|
330
332
|
const { getByLabelText } = render(
|
|
331
333
|
<RichTextEditor
|
|
@@ -335,14 +337,14 @@ describe("RichTextEditor Component", () => {
|
|
|
335
337
|
content="<table><tr><td>Cell content</td></tr></table>"
|
|
336
338
|
/>
|
|
337
339
|
);
|
|
338
|
-
|
|
340
|
+
|
|
339
341
|
const button = getByLabelText("Remove table");
|
|
340
342
|
button.onclick = () => {
|
|
341
343
|
mockOnChange("<p></p>");
|
|
342
344
|
};
|
|
343
|
-
|
|
345
|
+
|
|
344
346
|
fireEvent.click(button);
|
|
345
|
-
|
|
347
|
+
|
|
346
348
|
expect(mockOnChange).toHaveBeenCalled();
|
|
347
349
|
});
|
|
348
350
|
});
|