@pie-lib/editable-html 13.1.0-beta.1 → 13.1.0-beta.3

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 (59) hide show
  1. package/lib/editor.js +1 -1
  2. package/package.json +3 -3
  3. package/lib/__tests__/editor-utils.test.js +0 -164
  4. package/lib/__tests__/editor-utils.test.js.map +0 -1
  5. package/lib/__tests__/serialization.test.js +0 -241
  6. package/lib/__tests__/serialization.test.js.map +0 -1
  7. package/lib/__tests__/utils.js +0 -79
  8. package/lib/__tests__/utils.js.map +0 -1
  9. package/lib/plugins/image/__tests__/component.test.js +0 -96
  10. package/lib/plugins/image/__tests__/component.test.js.map +0 -1
  11. package/lib/plugins/image/__tests__/image-toolbar-logic.test.js +0 -131
  12. package/lib/plugins/image/__tests__/image-toolbar-logic.test.js.map +0 -1
  13. package/lib/plugins/image/__tests__/image-toolbar.test.js +0 -21
  14. package/lib/plugins/image/__tests__/image-toolbar.test.js.map +0 -1
  15. package/lib/plugins/image/__tests__/index.test.js +0 -86
  16. package/lib/plugins/image/__tests__/index.test.js.map +0 -1
  17. package/lib/plugins/image/__tests__/insert-image-handler.test.js +0 -112
  18. package/lib/plugins/image/__tests__/insert-image-handler.test.js.map +0 -1
  19. package/lib/plugins/image/__tests__/mock-change.js +0 -22
  20. package/lib/plugins/image/__tests__/mock-change.js.map +0 -1
  21. package/lib/plugins/list/__tests__/index.test.js +0 -63
  22. package/lib/plugins/list/__tests__/index.test.js.map +0 -1
  23. package/lib/plugins/math/__tests__/index.test.js +0 -284
  24. package/lib/plugins/math/__tests__/index.test.js.map +0 -1
  25. package/lib/plugins/media/__tests__/index.test.js +0 -69
  26. package/lib/plugins/media/__tests__/index.test.js.map +0 -1
  27. package/lib/plugins/respArea/drag-in-the-blank/__tests__/choice.test.js +0 -93
  28. package/lib/plugins/respArea/drag-in-the-blank/__tests__/choice.test.js.map +0 -1
  29. package/lib/plugins/table/__tests__/index.test.js +0 -416
  30. package/lib/plugins/table/__tests__/index.test.js.map +0 -1
  31. package/lib/plugins/table/__tests__/table-toolbar.test.js +0 -81
  32. package/lib/plugins/table/__tests__/table-toolbar.test.js.map +0 -1
  33. package/lib/plugins/toolbar/__tests__/default-toolbar.test.js +0 -153
  34. package/lib/plugins/toolbar/__tests__/default-toolbar.test.js.map +0 -1
  35. package/lib/plugins/toolbar/__tests__/editor-and-toolbar.test.js +0 -47
  36. package/lib/plugins/toolbar/__tests__/editor-and-toolbar.test.js.map +0 -1
  37. package/lib/plugins/toolbar/__tests__/toolbar-buttons.test.js +0 -112
  38. package/lib/plugins/toolbar/__tests__/toolbar-buttons.test.js.map +0 -1
  39. package/lib/plugins/toolbar/__tests__/toolbar.test.js +0 -118
  40. package/lib/plugins/toolbar/__tests__/toolbar.test.js.map +0 -1
  41. package/src/__tests__/editor-utils.test.js +0 -162
  42. package/src/__tests__/serialization.test.js +0 -290
  43. package/src/__tests__/utils.js +0 -36
  44. package/src/plugins/image/__tests__/component.test.jsx +0 -73
  45. package/src/plugins/image/__tests__/image-toolbar-logic.test.jsx +0 -90
  46. package/src/plugins/image/__tests__/image-toolbar.test.jsx +0 -12
  47. package/src/plugins/image/__tests__/index.test.js +0 -92
  48. package/src/plugins/image/__tests__/insert-image-handler.test.js +0 -113
  49. package/src/plugins/image/__tests__/mock-change.js +0 -15
  50. package/src/plugins/list/__tests__/index.test.js +0 -52
  51. package/src/plugins/math/__tests__/index.test.jsx +0 -264
  52. package/src/plugins/media/__tests__/index.test.js +0 -75
  53. package/src/plugins/respArea/drag-in-the-blank/__tests__/choice.test.js +0 -71
  54. package/src/plugins/table/__tests__/index.test.jsx +0 -401
  55. package/src/plugins/table/__tests__/table-toolbar.test.jsx +0 -75
  56. package/src/plugins/toolbar/__tests__/default-toolbar.test.jsx +0 -123
  57. package/src/plugins/toolbar/__tests__/editor-and-toolbar.test.jsx +0 -40
  58. package/src/plugins/toolbar/__tests__/toolbar-buttons.test.jsx +0 -97
  59. package/src/plugins/toolbar/__tests__/toolbar.test.jsx +0 -112
@@ -1,97 +0,0 @@
1
- import { classObject } from '../../../__tests__/utils';
2
- import { RawButton, RawMarkButton } from '../toolbar-buttons';
3
- import React from 'react';
4
- import { render, screen } from '@testing-library/react';
5
- import userEvent from '@testing-library/user-event';
6
-
7
- // Mock IconButton
8
- jest.mock('@mui/material/IconButton', () => {
9
- return function IconButton({ children, onClick, className }) {
10
- return (
11
- <button onClick={onClick} className={className} data-testid="icon-button">
12
- {children}
13
- </button>
14
- );
15
- };
16
- });
17
-
18
- describe('Button', () => {
19
- const onClick = jest.fn();
20
-
21
- beforeEach(() => {
22
- onClick.mockClear();
23
- });
24
-
25
- it('renders with children', () => {
26
- const classes = classObject('root');
27
- render(
28
- <RawButton onClick={onClick} classes={classes}>
29
- children
30
- </RawButton>,
31
- );
32
-
33
- expect(screen.getByText('children')).toBeInTheDocument();
34
- });
35
-
36
- it('calls onClick when clicked', async () => {
37
- const user = userEvent.setup();
38
- const classes = classObject('root');
39
- render(
40
- <RawButton onClick={onClick} classes={classes}>
41
- children
42
- </RawButton>,
43
- );
44
-
45
- const button = screen.getByText('children');
46
- await user.click(button);
47
-
48
- expect(onClick).toHaveBeenCalled();
49
- });
50
- });
51
-
52
- describe('MarkButton', () => {
53
- const classes = classObject('button', 'root', 'active');
54
- const onToggle = jest.fn();
55
-
56
- beforeEach(() => {
57
- onToggle.mockClear();
58
- });
59
-
60
- it('renders when not active', () => {
61
- render(
62
- <RawMarkButton mark={'i'} onToggle={onToggle} active={false} classes={classes}>
63
- children
64
- </RawMarkButton>,
65
- );
66
-
67
- const button = screen.getByText('children');
68
- expect(button).toBeInTheDocument();
69
- expect(button).toHaveAttribute('aria-pressed', 'false');
70
- });
71
-
72
- it('renders when active', () => {
73
- render(
74
- <RawMarkButton mark={'i'} onToggle={onToggle} active={true} classes={classes}>
75
- children
76
- </RawMarkButton>,
77
- );
78
-
79
- const button = screen.getByText('children');
80
- expect(button).toBeInTheDocument();
81
- expect(button).toHaveAttribute('aria-pressed', 'true');
82
- });
83
-
84
- it('calls onToggle when clicked', async () => {
85
- const user = userEvent.setup();
86
- render(
87
- <RawMarkButton mark={'i'} onToggle={onToggle} active={false} classes={classes}>
88
- children
89
- </RawMarkButton>,
90
- );
91
-
92
- const button = screen.getByText('children');
93
- await user.click(button);
94
-
95
- expect(onToggle).toHaveBeenCalled();
96
- });
97
- });
@@ -1,112 +0,0 @@
1
- import { classObject, mockMathInput } from '../../../__tests__/utils';
2
- import { Inline, Value } from 'slate';
3
- import { Toolbar } from '../toolbar';
4
- import React from 'react';
5
- import { render, screen } from '@testing-library/react';
6
-
7
- mockMathInput();
8
-
9
- jest.mock('@mui/material/IconButton', () => {
10
- return (props) => {
11
- const { children, onClick, buttonRef, ...rest } = props;
12
- return (
13
- <button onClick={onClick} {...rest}>
14
- {children}
15
- </button>
16
- );
17
- };
18
- });
19
-
20
- let node = Inline.fromJSON({ type: 'i' });
21
- let parentNode = Inline.fromJSON({
22
- type: 'i',
23
- });
24
- let value;
25
-
26
- describe('toolbar', () => {
27
- let onDelete, classes, document, toolbarOpts;
28
-
29
- beforeEach(() => {
30
- onDelete = jest.fn();
31
-
32
- toolbarOpts = {
33
- position: 'bottom',
34
- alwaysVisible: false,
35
- };
36
-
37
- value = Value.fromJSON({});
38
- document = {
39
- getClosestInline: jest.fn().mockReturnValue(node),
40
- getParent: jest.fn().mockReturnValue(),
41
- };
42
-
43
- Object.defineProperties(value, {
44
- isCollapsed: {
45
- get: jest.fn(() => true),
46
- },
47
- startKey: {
48
- get: jest.fn(() => '1'),
49
- },
50
- document: {
51
- get: jest.fn(() => document),
52
- },
53
- });
54
-
55
- classes = classObject('iconRoot', 'inline', 'toolbar', 'focused', 'shared', 'inline', 'pie-toolbar');
56
- });
57
-
58
- test('renders custom toolbar', () => {
59
- const plugins = [
60
- {
61
- deleteNode: () => true,
62
- toolbar: {
63
- supports: () => true,
64
- customToolbar: () => () => <div>custom toolbar content</div>,
65
- },
66
- },
67
- ];
68
-
69
- const { container } = render(
70
- <Toolbar
71
- toolbarOpts={toolbarOpts}
72
- plugins={plugins}
73
- classes={classes}
74
- value={value}
75
- onDone={jest.fn()}
76
- onChange={jest.fn()}
77
- />,
78
- );
79
-
80
- // Verify the custom toolbar content is rendered
81
- expect(container.firstChild).toBeInTheDocument();
82
- expect(screen.getByText('custom toolbar content')).toBeInTheDocument();
83
- });
84
-
85
- describe('default', () => {
86
- let plugins;
87
-
88
- beforeEach(() => {
89
- plugins = [];
90
- });
91
-
92
- test('renders default toolbar', () => {
93
- const { container } = render(
94
- <Toolbar
95
- toolbarOpts={toolbarOpts}
96
- plugins={plugins}
97
- classes={classes}
98
- value={value}
99
- onDone={jest.fn()}
100
- onChange={jest.fn()}
101
- />,
102
- );
103
-
104
- // Verify the toolbar is rendered
105
- expect(container.firstChild).toBeInTheDocument();
106
-
107
- // The default toolbar should render the DefaultToolbar component
108
- // which includes a Done button
109
- expect(screen.getByLabelText('Done')).toBeInTheDocument();
110
- });
111
- });
112
- });