@pie-lib/editable-html-tip-tap 2.2.0-beta.8 → 2.2.0-beta.9

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.
Files changed (47) hide show
  1. package/package.json +3 -3
  2. package/src/__tests__/EditableHtml.test.jsx +0 -588
  3. package/src/__tests__/constants.test.js +0 -19
  4. package/src/__tests__/div-to-paragraph-conversion.test.jsx +0 -125
  5. package/src/__tests__/extensions.test.js +0 -208
  6. package/src/__tests__/index.test.jsx +0 -154
  7. package/src/__tests__/size-utils.test.js +0 -64
  8. package/src/__tests__/theme.test.js +0 -17
  9. package/src/components/__tests__/AltDialog.test.jsx +0 -147
  10. package/src/components/__tests__/CharacterPicker.test.jsx +0 -270
  11. package/src/components/__tests__/CssIcon.test.jsx +0 -46
  12. package/src/components/__tests__/DragInTheBlank.test.jsx +0 -255
  13. package/src/components/__tests__/ExplicitConstructedResponse.test.jsx +0 -209
  14. package/src/components/__tests__/ImageToolbar.test.jsx +0 -128
  15. package/src/components/__tests__/InlineDropdown.test.jsx +0 -557
  16. package/src/components/__tests__/InsertImageHandler.test.js +0 -161
  17. package/src/components/__tests__/MediaDialog.test.jsx +0 -293
  18. package/src/components/__tests__/MediaToolbar.test.jsx +0 -74
  19. package/src/components/__tests__/MediaWrapper.test.jsx +0 -81
  20. package/src/components/__tests__/MenuBar.test.jsx +0 -250
  21. package/src/components/__tests__/RespArea.test.jsx +0 -122
  22. package/src/components/__tests__/TableIcons.test.jsx +0 -149
  23. package/src/components/__tests__/TextAlign.test.jsx +0 -167
  24. package/src/components/__tests__/TiptapContainer.test.jsx +0 -138
  25. package/src/components/__tests__/characterUtils.test.js +0 -166
  26. package/src/components/__tests__/choice.test.jsx +0 -171
  27. package/src/components/__tests__/custom-popper.test.jsx +0 -82
  28. package/src/components/__tests__/done-button.test.jsx +0 -54
  29. package/src/components/__tests__/toolbar-buttons.test.jsx +0 -234
  30. package/src/components/respArea/DragInTheBlank/__tests__/choice.test.jsx +0 -72
  31. package/src/components/respArea/__tests__/MathTemplated.test.jsx +0 -210
  32. package/src/extensions/__tests__/css.test.js +0 -196
  33. package/src/extensions/__tests__/custom-toolbar-wrapper.test.jsx +0 -180
  34. package/src/extensions/__tests__/divNode.test.js +0 -87
  35. package/src/extensions/__tests__/ensure-empty-root-div.test.js +0 -57
  36. package/src/extensions/__tests__/ensure-list-item-content-is-div.test.js +0 -44
  37. package/src/extensions/__tests__/extended-list-item.test.js +0 -13
  38. package/src/extensions/__tests__/extended-table-cell.test.js +0 -22
  39. package/src/extensions/__tests__/extended-table.test.js +0 -183
  40. package/src/extensions/__tests__/image-component.test.jsx +0 -346
  41. package/src/extensions/__tests__/image.test.js +0 -237
  42. package/src/extensions/__tests__/math.test.js +0 -900
  43. package/src/extensions/__tests__/media-node-view.test.jsx +0 -298
  44. package/src/extensions/__tests__/media.test.js +0 -271
  45. package/src/extensions/__tests__/responseArea.test.js +0 -655
  46. package/src/utils/__tests__/helper.test.js +0 -126
  47. package/src/utils/__tests__/toolbar.test.js +0 -43
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "2.2.0-beta.8",
6
+ "version": "2.2.0-beta.9",
7
7
  "description": "",
8
8
  "license": "ISC",
9
9
  "main": "lib/index.js",
@@ -17,9 +17,9 @@
17
17
  "@mui/icons-material": "^7.3.4",
18
18
  "@mui/material": "^7.3.4",
19
19
  "@pie-lib/drag": "^4.0.2",
20
- "@pie-lib/math-input-mathlive": "^1.0.12",
20
+ "@pie-lib/math-input-mathlive": "^1.0.13",
21
21
  "@pie-lib/math-rendering": "^5.0.2",
22
- "@pie-lib/math-toolbar": "^3.1.0-beta.8",
22
+ "@pie-lib/math-toolbar": "^3.1.0-beta.9",
23
23
  "@pie-lib/render-ui": "^6.1.0",
24
24
  "@tiptap/core": "3.20.0",
25
25
  "@tiptap/extension-character-count": "3.20.0",
@@ -1,588 +0,0 @@
1
- import React from 'react';
2
- import { render, waitFor } from '@testing-library/react';
3
- import { useEditor } from '@tiptap/react';
4
- import { EditableHtml } from '../components/EditableHtml';
5
- import { InlineDropdownNode } from '../extensions/responseArea';
6
-
7
- // Mock TipTap dependencies
8
- jest.mock('@tiptap/react', () => ({
9
- EditorContent: ({ editor, ...props }) => <div data-testid="editor-content" {...props} />,
10
- useEditor: jest.fn((config) => {
11
- const mockEditor = {
12
- getHTML: jest.fn(() => '<p>test content</p>'),
13
- setEditable: jest.fn(),
14
- commands: {
15
- setContent: jest.fn(),
16
- },
17
- isActive: jest.fn(() => false),
18
- isFocused: false,
19
- };
20
- return mockEditor;
21
- }),
22
- useEditorState: jest.fn(() => ({
23
- isFocused: false,
24
- })),
25
- }));
26
-
27
- jest.mock('@tiptap/starter-kit', () => ({
28
- __esModule: true,
29
- default: {
30
- configure: jest.fn(() => ({})),
31
- },
32
- }));
33
-
34
- jest.mock('@tiptap/extension-text-style', () => ({
35
- TextStyleKit: {},
36
- }));
37
-
38
- jest.mock('@tiptap/extension-character-count', () => ({
39
- CharacterCount: {
40
- configure: jest.fn(() => ({})),
41
- },
42
- }));
43
-
44
- jest.mock('@tiptap/extension-superscript', () => ({
45
- __esModule: true,
46
- default: {},
47
- }));
48
-
49
- jest.mock('@tiptap/extension-subscript', () => ({
50
- __esModule: true,
51
- default: {},
52
- }));
53
-
54
- jest.mock('@tiptap/extension-text-align', () => ({
55
- __esModule: true,
56
- default: {
57
- configure: jest.fn(() => ({})),
58
- },
59
- }));
60
-
61
- jest.mock('@tiptap/extension-image', () => ({
62
- __esModule: true,
63
- default: {},
64
- }));
65
-
66
- jest.mock('@tiptap/extension-table', () => ({
67
- __esModule: true,
68
- default: {},
69
- }));
70
-
71
- jest.mock('@tiptap/extension-table-row', () => ({
72
- TableRow: {},
73
- }));
74
-
75
- jest.mock('../extensions/extended-table-cell', () => ({
76
- ExtendedTableCell: {},
77
- ExtendedTableHeader: {},
78
- }));
79
-
80
- jest.mock('../extensions/extended-table', () => ({
81
- __esModule: true,
82
- default: {},
83
- }));
84
-
85
- jest.mock('../extensions/ensure-empty-root-div', () => ({
86
- EnsureEmptyRootIsDiv: {},
87
- }));
88
-
89
- jest.mock('../extensions/extended-list-item', () => ({
90
- ExtendedListItem: {},
91
- }));
92
-
93
- jest.mock('../extensions/ensure-list-item-content-is-div', () => ({
94
- EnsureListItemContentIsDiv: {},
95
- }));
96
-
97
- jest.mock('../extensions/responseArea', () => ({
98
- ExplicitConstructedResponseNode: {
99
- configure: jest.fn(() => ({})),
100
- },
101
- DragInTheBlankNode: {
102
- configure: jest.fn(() => ({})),
103
- },
104
- InlineDropdownNode: {
105
- configure: jest.fn(() => ({})),
106
- },
107
- MathTemplatedNode: {
108
- configure: jest.fn(() => ({})),
109
- },
110
- ResponseAreaExtension: {
111
- configure: jest.fn(() => ({})),
112
- },
113
- }));
114
-
115
- jest.mock('../extensions/math', () => ({
116
- MathNode: {
117
- configure: jest.fn(() => ({})),
118
- },
119
- }));
120
-
121
- jest.mock('../extensions/image', () => ({
122
- ImageUploadNode: {
123
- configure: jest.fn(() => ({})),
124
- },
125
- }));
126
-
127
- jest.mock('../extensions/media', () => ({
128
- Media: {
129
- configure: jest.fn(() => ({})),
130
- },
131
- }));
132
-
133
- jest.mock('../extensions/css', () => ({
134
- CSSMark: {
135
- configure: jest.fn(() => ({})),
136
- },
137
- }));
138
-
139
- jest.mock('../components/TiptapContainer', () => ({
140
- __esModule: true,
141
- default: ({ children }) => <div data-testid="editor-container">{children}</div>,
142
- }));
143
-
144
- jest.mock('../extensions', () => ({
145
- ...jest.requireActual('../extensions'),
146
- buildExtensions: jest.fn(() => []),
147
- }));
148
-
149
- describe('EditableHtml', () => {
150
- const defaultProps = {
151
- markup: '<p>Hello World</p>',
152
- onChange: jest.fn(),
153
- onDone: jest.fn(),
154
- disabled: false,
155
- };
156
-
157
- beforeEach(() => {
158
- jest.clearAllMocks();
159
- });
160
-
161
- it('renders without crashing', () => {
162
- const { container } = render(<EditableHtml {...defaultProps} />);
163
- expect(container).toBeInTheDocument();
164
- });
165
-
166
- it('renders editor container', () => {
167
- const { getByTestId } = render(<EditableHtml {...defaultProps} />);
168
- expect(getByTestId('editor-container')).toBeInTheDocument();
169
- });
170
-
171
- it('renders editor content when editor is initialized', async () => {
172
- const { getByTestId } = render(<EditableHtml {...defaultProps} />);
173
- await waitFor(() => {
174
- expect(getByTestId('editor-content')).toBeInTheDocument();
175
- });
176
- });
177
-
178
- it('accepts custom toolbar options', () => {
179
- const toolbarOpts = {
180
- position: 'top',
181
- alignment: 'center',
182
- alwaysVisible: true,
183
- showDone: false,
184
- doneOn: 'change',
185
- };
186
- const { container } = render(<EditableHtml {...defaultProps} toolbarOpts={toolbarOpts} />);
187
- expect(container).toBeInTheDocument();
188
- });
189
-
190
- it('accepts custom active plugins', () => {
191
- const activePlugins = ['bold', 'italic', 'underline'];
192
- const { container } = render(<EditableHtml {...defaultProps} activePlugins={activePlugins} />);
193
- expect(container).toBeInTheDocument();
194
- });
195
-
196
- it('accepts plugin props', () => {
197
- const pluginProps = {
198
- showParagraphs: { disabled: false },
199
- separateParagraphs: { disabled: false },
200
- };
201
- const { container } = render(<EditableHtml {...defaultProps} pluginProps={pluginProps} />);
202
- expect(container).toBeInTheDocument();
203
- });
204
-
205
- it('accepts response area props', () => {
206
- const responseAreaProps = {
207
- type: 'explicit-constructed-response',
208
- options: {},
209
- };
210
- const { container } = render(<EditableHtml {...defaultProps} responseAreaProps={responseAreaProps} />);
211
- expect(container).toBeInTheDocument();
212
- });
213
-
214
- it('passes blur done behavior to inline dropdown toolbar close', async () => {
215
- const onChange = jest.fn();
216
- const onDone = jest.fn();
217
- const html = '<p>from inline dropdown close</p>';
218
-
219
- render(
220
- <EditableHtml
221
- {...defaultProps}
222
- markup="<p>Hello World</p>"
223
- onChange={onChange}
224
- onDone={onDone}
225
- toolbarOpts={{ doneOn: 'blur' }}
226
- responseAreaProps={{ type: 'inline-dropdown' }}
227
- />,
228
- );
229
-
230
- await waitFor(() => {
231
- expect(InlineDropdownNode.configure).toHaveBeenCalled();
232
- });
233
-
234
- const configureCall = InlineDropdownNode.configure.mock.calls[InlineDropdownNode.configure.mock.calls.length - 1];
235
- const inlineDropdownOptions = configureCall[0];
236
- const editor = {
237
- getHTML: jest.fn(() => html),
238
- };
239
-
240
- inlineDropdownOptions.onInlineDropdownToolbarClose(editor);
241
-
242
- expect(editor.getHTML).toHaveBeenCalledTimes(1);
243
- expect(onChange).toHaveBeenCalledWith(html);
244
- expect(onDone).toHaveBeenCalledWith(html);
245
- });
246
-
247
- it('accepts size props', () => {
248
- const sizeProps = {
249
- width: 500,
250
- height: 300,
251
- minHeight: 200,
252
- maxHeight: 400,
253
- minWidth: 300,
254
- maxWidth: 600,
255
- };
256
- const { container } = render(<EditableHtml {...defaultProps} {...sizeProps} />);
257
- expect(container).toBeInTheDocument();
258
- });
259
-
260
- it('accepts character limit', () => {
261
- const { container } = render(<EditableHtml {...defaultProps} charactersLimit={500} />);
262
- expect(container).toBeInTheDocument();
263
- });
264
-
265
- it('accepts image support props', () => {
266
- const imageSupport = {
267
- add: jest.fn(),
268
- delete: jest.fn(),
269
- };
270
- const { container } = render(<EditableHtml {...defaultProps} imageSupport={imageSupport} />);
271
- expect(container).toBeInTheDocument();
272
- });
273
-
274
- it('accepts max image dimensions', () => {
275
- const { container } = render(<EditableHtml {...defaultProps} maxImageWidth={800} maxImageHeight={600} />);
276
- expect(container).toBeInTheDocument();
277
- });
278
-
279
- it('accepts language characters props', () => {
280
- const languageCharactersProps = [
281
- { label: 'Greek', value: 'greek' },
282
- { label: 'Cyrillic', value: 'cyrillic' },
283
- ];
284
- const { container } = render(<EditableHtml {...defaultProps} languageCharactersProps={languageCharactersProps} />);
285
- expect(container).toBeInTheDocument();
286
- });
287
-
288
- it('accepts extra CSS rules', () => {
289
- const extraCSSRules = {
290
- '.custom-class': { color: 'red' },
291
- };
292
- const { container } = render(<EditableHtml {...defaultProps} extraCSSRules={extraCSSRules} />);
293
- expect(container).toBeInTheDocument();
294
- });
295
-
296
- it('accepts upload sound support', () => {
297
- const uploadSoundSupport = {
298
- add: jest.fn(),
299
- delete: jest.fn(),
300
- };
301
- const { container } = render(<EditableHtml {...defaultProps} uploadSoundSupport={uploadSoundSupport} />);
302
- expect(container).toBeInTheDocument();
303
- });
304
-
305
- it('accepts onKeyDown handler', () => {
306
- const onKeyDown = jest.fn();
307
- const { container } = render(<EditableHtml {...defaultProps} onKeyDown={onKeyDown} />);
308
- expect(container).toBeInTheDocument();
309
- });
310
-
311
- it('accepts disableImageAlignmentButtons prop', () => {
312
- const { container } = render(<EditableHtml {...defaultProps} disableImageAlignmentButtons={true} />);
313
- expect(container).toBeInTheDocument();
314
- });
315
-
316
- it('calls editorRef callback when editor is initialized', async () => {
317
- const editorRef = jest.fn();
318
- render(<EditableHtml {...defaultProps} editorRef={editorRef} />);
319
-
320
- await waitFor(() => {
321
- expect(editorRef).toHaveBeenCalled();
322
- });
323
- });
324
-
325
- it('calls editorRef with the editor instance', async () => {
326
- const editorRef = jest.fn();
327
- render(<EditableHtml {...defaultProps} editorRef={editorRef} />);
328
-
329
- await waitFor(() => {
330
- expect(editorRef).toHaveBeenCalled();
331
- // Verify it was called with an object that has editor-like properties
332
- const callArg = editorRef.mock.calls[0][0];
333
- expect(callArg).toHaveProperty('getHTML');
334
- expect(callArg).toHaveProperty('commands');
335
- });
336
- });
337
-
338
- it('handles editorRef being undefined', () => {
339
- const { container } = render(<EditableHtml {...defaultProps} editorRef={undefined} />);
340
- expect(container).toBeInTheDocument();
341
- });
342
-
343
- it('applies flex display to StyledEditorContent', async () => {
344
- const { getByTestId } = render(<EditableHtml {...defaultProps} />);
345
- await waitFor(() => {
346
- const editorContent = getByTestId('editor-content');
347
- expect(editorContent).toBeInTheDocument();
348
- });
349
- });
350
-
351
- it('does not run blur onChange/onDone while an image insert flow is active', async () => {
352
- jest.useFakeTimers();
353
- const onChange = jest.fn();
354
- const onDone = jest.fn();
355
-
356
- render(
357
- <EditableHtml
358
- {...defaultProps}
359
- markup="<p>Hello World</p>"
360
- onChange={onChange}
361
- onDone={onDone}
362
- toolbarOpts={{ ...defaultProps.toolbarOpts, doneOn: 'blur' }}
363
- />,
364
- );
365
-
366
- await waitFor(() => {
367
- expect(useEditor).toHaveBeenCalled();
368
- });
369
-
370
- const editorConfig = useEditor.mock.calls[useEditor.mock.calls.length - 1][0];
371
- const blurEditor = {
372
- getHTML: jest.fn(() => '<p>changed</p>'),
373
- schema: {},
374
- _insertingImage: true,
375
- _toolbarOpened: false,
376
- isActive: jest.fn(() => false),
377
- };
378
-
379
- editorConfig.onBlur({ editor: blurEditor });
380
- jest.advanceTimersByTime(200);
381
-
382
- expect(onChange).not.toHaveBeenCalled();
383
- expect(onDone).not.toHaveBeenCalled();
384
-
385
- jest.useRealTimers();
386
- });
387
-
388
- it('does not run blur onChange/onDone when editor has no schema', async () => {
389
- jest.useFakeTimers();
390
- const onChange = jest.fn();
391
- const onDone = jest.fn();
392
-
393
- render(
394
- <EditableHtml
395
- {...defaultProps}
396
- markup="<p>Hello World</p>"
397
- onChange={onChange}
398
- onDone={onDone}
399
- toolbarOpts={{ doneOn: 'blur' }}
400
- />,
401
- );
402
-
403
- await waitFor(() => {
404
- expect(useEditor).toHaveBeenCalled();
405
- });
406
-
407
- const editorConfig = useEditor.mock.calls[useEditor.mock.calls.length - 1][0];
408
- const getHTML = jest.fn(() => '<p>changed</p>');
409
- const blurEditor = {
410
- getHTML,
411
- schema: undefined,
412
- _insertingImage: false,
413
- _toolbarOpened: false,
414
- isActive: jest.fn(() => false),
415
- };
416
-
417
- editorConfig.onBlur({ editor: blurEditor });
418
- jest.advanceTimersByTime(200);
419
-
420
- expect(getHTML).not.toHaveBeenCalled();
421
- expect(onChange).not.toHaveBeenCalled();
422
- expect(onDone).not.toHaveBeenCalled();
423
-
424
- jest.useRealTimers();
425
- });
426
-
427
- it('calls getHTML once on blur and passes the same html to onChange and onDone', async () => {
428
- jest.useFakeTimers();
429
- const onChange = jest.fn();
430
- const onDone = jest.fn();
431
- const html = '<p>from editor</p>';
432
-
433
- render(
434
- <EditableHtml
435
- {...defaultProps}
436
- markup="<p>Hello World</p>"
437
- onChange={onChange}
438
- onDone={onDone}
439
- toolbarOpts={{ doneOn: 'blur' }}
440
- />,
441
- );
442
-
443
- await waitFor(() => {
444
- expect(useEditor).toHaveBeenCalled();
445
- });
446
-
447
- const editorConfig = useEditor.mock.calls[useEditor.mock.calls.length - 1][0];
448
- const getHTML = jest.fn(() => html);
449
- const blurEditor = {
450
- getHTML,
451
- schema: {},
452
- _insertingImage: false,
453
- _toolbarOpened: false,
454
- isActive: jest.fn(() => false),
455
- };
456
-
457
- editorConfig.onBlur({ editor: blurEditor });
458
- jest.advanceTimersByTime(200);
459
-
460
- expect(getHTML).toHaveBeenCalledTimes(1);
461
- expect(onChange).toHaveBeenCalledWith(html);
462
- expect(onDone).toHaveBeenCalledWith(html);
463
-
464
- jest.useRealTimers();
465
- });
466
-
467
- describe('onUpdate callback', () => {
468
- it('calls onChange when transaction.isDone is true', async () => {
469
- const onChange = jest.fn();
470
- const markup = '<p>Initial content</p>';
471
-
472
- render(<EditableHtml {...defaultProps} markup={markup} onChange={onChange} />);
473
-
474
- await waitFor(() => {
475
- expect(useEditor).toHaveBeenCalled();
476
- });
477
-
478
- const editorConfig = useEditor.mock.calls[useEditor.mock.calls.length - 1][0];
479
- const mockEditor = {
480
- getHTML: jest.fn(() => '<p>Updated content</p>'),
481
- };
482
-
483
- const mockTransaction = {
484
- isDone: true,
485
- };
486
-
487
- editorConfig.onUpdate({ editor: mockEditor, transaction: mockTransaction });
488
-
489
- expect(onChange).toHaveBeenCalledWith('<p>Updated content</p>');
490
- });
491
-
492
- it('does not call onChange when transaction.isDone is false even if markup differs from editor HTML', async () => {
493
- const onChange = jest.fn();
494
- const markup = '<p>Initial content</p>';
495
-
496
- render(<EditableHtml {...defaultProps} markup={markup} onChange={onChange} />);
497
-
498
- await waitFor(() => {
499
- expect(useEditor).toHaveBeenCalled();
500
- });
501
-
502
- const editorConfig = useEditor.mock.calls[useEditor.mock.calls.length - 1][0];
503
- const mockEditor = {
504
- getHTML: jest.fn(() => '<p>Different content</p>'),
505
- };
506
-
507
- const mockTransaction = {
508
- isDone: false,
509
- };
510
-
511
- editorConfig.onUpdate({ editor: mockEditor, transaction: mockTransaction });
512
-
513
- expect(onChange).not.toHaveBeenCalled();
514
- });
515
-
516
- it('does not call onChange when transaction.isDone is false and markup matches editor HTML', async () => {
517
- const onChange = jest.fn();
518
- const markup = '<p>Same content</p>';
519
-
520
- render(<EditableHtml {...defaultProps} markup={markup} onChange={onChange} />);
521
-
522
- await waitFor(() => {
523
- expect(useEditor).toHaveBeenCalled();
524
- });
525
-
526
- const editorConfig = useEditor.mock.calls[useEditor.mock.calls.length - 1][0];
527
- const mockEditor = {
528
- getHTML: jest.fn(() => '<p>Same content</p>'),
529
- };
530
-
531
- const mockTransaction = {
532
- isDone: false,
533
- };
534
-
535
- editorConfig.onUpdate({ editor: mockEditor, transaction: mockTransaction });
536
-
537
- expect(onChange).not.toHaveBeenCalled();
538
- });
539
-
540
- it('calls onChange when transaction.isDone is true even if markup matches', async () => {
541
- const onChange = jest.fn();
542
- const markup = '<p>Same content</p>';
543
-
544
- render(<EditableHtml {...defaultProps} markup={markup} onChange={onChange} />);
545
-
546
- await waitFor(() => {
547
- expect(useEditor).toHaveBeenCalled();
548
- });
549
-
550
- const editorConfig = useEditor.mock.calls[useEditor.mock.calls.length - 1][0];
551
- const mockEditor = {
552
- getHTML: jest.fn(() => '<p>Same content</p>'),
553
- };
554
-
555
- const mockTransaction = {
556
- isDone: true,
557
- };
558
-
559
- editorConfig.onUpdate({ editor: mockEditor, transaction: mockTransaction });
560
-
561
- expect(onChange).toHaveBeenCalledWith('<p>Same content</p>');
562
- });
563
-
564
- it('does not call onChange when onChange is not provided', async () => {
565
- const markup = '<p>Content</p>';
566
-
567
- render(<EditableHtml {...defaultProps} markup={markup} onChange={undefined} />);
568
-
569
- await waitFor(() => {
570
- expect(useEditor).toHaveBeenCalled();
571
- });
572
-
573
- const editorConfig = useEditor.mock.calls[useEditor.mock.calls.length - 1][0];
574
- const mockEditor = {
575
- getHTML: jest.fn(() => '<p>Updated content</p>'),
576
- };
577
-
578
- const mockTransaction = {
579
- isDone: true,
580
- };
581
-
582
- // Should not throw error when onChange is undefined
583
- expect(() => {
584
- editorConfig.onUpdate({ editor: mockEditor, transaction: mockTransaction });
585
- }).not.toThrow();
586
- });
587
- });
588
- });
@@ -1,19 +0,0 @@
1
- import constants, { PIE_TOOLBAR__CLASS } from '../constants';
2
-
3
- describe('Constants', () => {
4
- describe('PIE_TOOLBAR__CLASS', () => {
5
- it('is defined', () => {
6
- expect(PIE_TOOLBAR__CLASS).toBeDefined();
7
- });
8
-
9
- it('has the correct value', () => {
10
- expect(PIE_TOOLBAR__CLASS).toBe('pie-toolbar');
11
- });
12
- });
13
-
14
- describe('default export', () => {
15
- it('contains PIE_TOOLBAR__CLASS', () => {
16
- expect(constants.PIE_TOOLBAR__CLASS).toBe('pie-toolbar');
17
- });
18
- });
19
- });