@pie-lib/editable-html 13.1.0-beta.2 → 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.
- package/package.json +3 -3
- package/src/__tests__/editor-utils.test.js +0 -162
- package/src/__tests__/serialization.test.js +0 -290
- package/src/__tests__/utils.js +0 -36
- package/src/plugins/image/__tests__/component.test.jsx +0 -73
- package/src/plugins/image/__tests__/image-toolbar-logic.test.jsx +0 -90
- package/src/plugins/image/__tests__/image-toolbar.test.jsx +0 -12
- package/src/plugins/image/__tests__/index.test.js +0 -92
- package/src/plugins/image/__tests__/insert-image-handler.test.js +0 -113
- package/src/plugins/image/__tests__/mock-change.js +0 -15
- package/src/plugins/list/__tests__/index.test.js +0 -52
- package/src/plugins/math/__tests__/index.test.jsx +0 -264
- package/src/plugins/media/__tests__/index.test.js +0 -75
- package/src/plugins/respArea/drag-in-the-blank/__tests__/choice.test.js +0 -71
- package/src/plugins/table/__tests__/index.test.jsx +0 -401
- package/src/plugins/table/__tests__/table-toolbar.test.jsx +0 -75
- package/src/plugins/toolbar/__tests__/default-toolbar.test.jsx +0 -123
- package/src/plugins/toolbar/__tests__/editor-and-toolbar.test.jsx +0 -40
- package/src/plugins/toolbar/__tests__/toolbar-buttons.test.jsx +0 -97
- 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
|
-
});
|