@pie-lib/mask-markup 3.1.0-beta.7 → 3.1.0-beta.8
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 +2 -2
- package/lib/__tests__/drag-in-the-blank.test.js +0 -129
- package/lib/__tests__/drag-in-the-blank.test.js.map +0 -1
- package/lib/__tests__/index.test.js +0 -39
- package/lib/__tests__/index.test.js.map +0 -1
- package/lib/__tests__/mask.test.js +0 -344
- package/lib/__tests__/mask.test.js.map +0 -1
- package/lib/__tests__/serialization.test.js +0 -44
- package/lib/__tests__/serialization.test.js.map +0 -1
- package/lib/__tests__/utils.js +0 -14
- package/lib/__tests__/utils.js.map +0 -1
- package/lib/__tests__/with-mask.test.js +0 -110
- package/lib/__tests__/with-mask.test.js.map +0 -1
- package/lib/choices/__tests__/index.test.js +0 -139
- package/lib/choices/__tests__/index.test.js.map +0 -1
- package/lib/components/__tests__/blank.test.js +0 -293
- package/lib/components/__tests__/blank.test.js.map +0 -1
- package/lib/components/__tests__/correct-input.test.js +0 -132
- package/lib/components/__tests__/correct-input.test.js.map +0 -1
- package/lib/components/__tests__/dropdown.test.js +0 -202
- package/lib/components/__tests__/dropdown.test.js.map +0 -1
- package/lib/components/__tests__/input.test.js +0 -129
- package/lib/components/__tests__/input.test.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-lib/mask-markup",
|
|
3
|
-
"version": "3.1.0-beta.
|
|
3
|
+
"version": "3.1.0-beta.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"@mui/icons-material": "^7.3.4",
|
|
15
15
|
"@mui/material": "^7.3.4",
|
|
16
16
|
"@pie-lib/drag": "^4.0.2",
|
|
17
|
-
"@pie-lib/editable-html-tip-tap": "^2.2.0-beta.
|
|
17
|
+
"@pie-lib/editable-html-tip-tap": "^2.2.0-beta.8",
|
|
18
18
|
"@pie-lib/math-rendering": "^5.0.2",
|
|
19
19
|
"@pie-lib/render-ui": "^6.1.0",
|
|
20
20
|
"classnames": "^2.2.6",
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
6
|
-
var React = _interopRequireWildcard(require("react"));
|
|
7
|
-
var _react2 = require("@testing-library/react");
|
|
8
|
-
var _dragInTheBlank = _interopRequireDefault(require("../drag-in-the-blank"));
|
|
9
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
10
|
-
var markup = "<div>\n <img src=\"https://image.shutterstock.com/image-vector/cow-jumped-over-moon-traditional-260nw-1152899330.jpg\"></img>\n <h5>Hey Diddle Diddle <i>by ?</i></h5>\n <p>1: Hey, diddle, diddle,</p>\n <p>2: The cat and the fiddle,</p>\n <p>3: The cow {{0}} over the moon;</p>\n <p>4: The little dog {{1}},</p>\n <p>5: To see such sport,</p>\n <p>6: And the dish ran away with the {{2}}.</p>\n</div>";
|
|
11
|
-
var choice = function choice(v, id) {
|
|
12
|
-
return {
|
|
13
|
-
value: v,
|
|
14
|
-
id: id
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
// Mock DragProvider and DragDroppablePlaceholder to avoid DndContext requirement
|
|
19
|
-
jest.mock('@pie-lib/drag', function () {
|
|
20
|
-
return {
|
|
21
|
-
DragProvider: function DragProvider(_ref) {
|
|
22
|
-
var children = _ref.children,
|
|
23
|
-
onDragStart = _ref.onDragStart,
|
|
24
|
-
onDragEnd = _ref.onDragEnd;
|
|
25
|
-
// Simple wrapper that doesn't require DndContext
|
|
26
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
27
|
-
"data-testid": "drag-provider"
|
|
28
|
-
}, children);
|
|
29
|
-
},
|
|
30
|
-
DragDroppablePlaceholder: function DragDroppablePlaceholder(_ref2) {
|
|
31
|
-
var children = _ref2.children,
|
|
32
|
-
disabled = _ref2.disabled,
|
|
33
|
-
instanceId = _ref2.instanceId;
|
|
34
|
-
// Simple wrapper that doesn't require useDroppable
|
|
35
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
36
|
-
"data-testid": "drag-droppable-placeholder"
|
|
37
|
-
}, children);
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
// Mock @dnd-kit/core components and hooks used by DragInTheBlank and child components
|
|
43
|
-
jest.mock('@dnd-kit/core', function () {
|
|
44
|
-
return {
|
|
45
|
-
DragOverlay: function DragOverlay(_ref3) {
|
|
46
|
-
var children = _ref3.children;
|
|
47
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
48
|
-
"data-testid": "drag-overlay"
|
|
49
|
-
}, children);
|
|
50
|
-
},
|
|
51
|
-
closestCenter: jest.fn(),
|
|
52
|
-
useDraggable: jest.fn(function () {
|
|
53
|
-
return {
|
|
54
|
-
attributes: {},
|
|
55
|
-
listeners: {},
|
|
56
|
-
setNodeRef: jest.fn(),
|
|
57
|
-
transform: null,
|
|
58
|
-
isDragging: false
|
|
59
|
-
};
|
|
60
|
-
}),
|
|
61
|
-
useDroppable: jest.fn(function () {
|
|
62
|
-
return {
|
|
63
|
-
setNodeRef: jest.fn(),
|
|
64
|
-
isOver: false,
|
|
65
|
-
active: null
|
|
66
|
-
};
|
|
67
|
-
})
|
|
68
|
-
};
|
|
69
|
-
});
|
|
70
|
-
jest.mock('@dnd-kit/utilities', function () {
|
|
71
|
-
return {
|
|
72
|
-
CSS: {
|
|
73
|
-
Translate: {
|
|
74
|
-
toString: jest.fn(function () {
|
|
75
|
-
return 'translate3d(0, 0, 0)';
|
|
76
|
-
})
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
});
|
|
81
|
-
describe('DragInTheBlank', function () {
|
|
82
|
-
var defaultProps = {
|
|
83
|
-
disabled: false,
|
|
84
|
-
feedback: {},
|
|
85
|
-
markup: markup,
|
|
86
|
-
choices: [choice('Jumped', '0'), choice('Laughed', '1'), choice('Spoon', '2'), choice('Fork', '3'), choice('Bumped', '4'), choice('Smiled', '5')],
|
|
87
|
-
value: {
|
|
88
|
-
0: undefined
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
describe('render', function () {
|
|
92
|
-
it('renders correctly with default props', function () {
|
|
93
|
-
var _render = (0, _react2.render)(/*#__PURE__*/React.createElement(_dragInTheBlank["default"], defaultProps)),
|
|
94
|
-
container = _render.container;
|
|
95
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
96
|
-
// Check that markup content is rendered
|
|
97
|
-
expect(_react2.screen.getByText(/Hey Diddle Diddle/)).toBeInTheDocument();
|
|
98
|
-
expect(_react2.screen.getByText(/Hey, diddle, diddle,/)).toBeInTheDocument();
|
|
99
|
-
});
|
|
100
|
-
it('renders correctly with disabled prop as true', function () {
|
|
101
|
-
var _render2 = (0, _react2.render)(/*#__PURE__*/React.createElement(_dragInTheBlank["default"], (0, _extends2["default"])({}, defaultProps, {
|
|
102
|
-
disabled: true
|
|
103
|
-
}))),
|
|
104
|
-
container = _render2.container;
|
|
105
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
106
|
-
});
|
|
107
|
-
it('renders correctly with feedback', function () {
|
|
108
|
-
var _render3 = (0, _react2.render)(/*#__PURE__*/React.createElement(_dragInTheBlank["default"], (0, _extends2["default"])({}, defaultProps, {
|
|
109
|
-
feedback: {
|
|
110
|
-
0: {
|
|
111
|
-
value: 'Jumped',
|
|
112
|
-
correct: 'Jumped'
|
|
113
|
-
},
|
|
114
|
-
1: {
|
|
115
|
-
value: 'Laughed',
|
|
116
|
-
correct: 'Laughed'
|
|
117
|
-
},
|
|
118
|
-
2: {
|
|
119
|
-
value: 'Spoon',
|
|
120
|
-
correct: 'Spoon'
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}))),
|
|
124
|
-
container = _render3.container;
|
|
125
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
//# sourceMappingURL=drag-in-the-blank.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"drag-in-the-blank.test.js","names":["React","_interopRequireWildcard","require","_react2","_dragInTheBlank","_interopRequireDefault","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","markup","choice","v","id","value","jest","mock","DragProvider","_ref","children","onDragStart","onDragEnd","createElement","DragDroppablePlaceholder","_ref2","disabled","instanceId","DragOverlay","_ref3","closestCenter","fn","useDraggable","attributes","listeners","setNodeRef","transform","isDragging","useDroppable","isOver","active","CSS","Translate","toString","describe","defaultProps","feedback","choices","undefined","it","_render","render","container","expect","firstChild","toBeInTheDocument","screen","getByText","_render2","_extends2","_render3","correct"],"sources":["../../src/__tests__/drag-in-the-blank.test.js"],"sourcesContent":["import * as React from 'react';\nimport { render, screen } from '@testing-library/react';\nimport DragInTheBlank from '../drag-in-the-blank';\n\nconst markup = `<div>\n <img src=\"https://image.shutterstock.com/image-vector/cow-jumped-over-moon-traditional-260nw-1152899330.jpg\"></img>\n <h5>Hey Diddle Diddle <i>by ?</i></h5>\n <p>1: Hey, diddle, diddle,</p>\n <p>2: The cat and the fiddle,</p>\n <p>3: The cow {{0}} over the moon;</p>\n <p>4: The little dog {{1}},</p>\n <p>5: To see such sport,</p>\n <p>6: And the dish ran away with the {{2}}.</p>\n</div>`;\nconst choice = (v, id) => ({ value: v, id });\n\n// Mock DragProvider and DragDroppablePlaceholder to avoid DndContext requirement\njest.mock('@pie-lib/drag', () => ({\n DragProvider: ({ children, onDragStart, onDragEnd }) => {\n // Simple wrapper that doesn't require DndContext\n return <div data-testid=\"drag-provider\">{children}</div>;\n },\n DragDroppablePlaceholder: ({ children, disabled, instanceId }) => {\n // Simple wrapper that doesn't require useDroppable\n return <div data-testid=\"drag-droppable-placeholder\">{children}</div>;\n },\n}));\n\n// Mock @dnd-kit/core components and hooks used by DragInTheBlank and child components\njest.mock('@dnd-kit/core', () => ({\n DragOverlay: ({ children }) => <div data-testid=\"drag-overlay\">{children}</div>,\n closestCenter: jest.fn(),\n useDraggable: jest.fn(() => ({\n attributes: {},\n listeners: {},\n setNodeRef: jest.fn(),\n transform: null,\n isDragging: false,\n })),\n useDroppable: jest.fn(() => ({\n setNodeRef: jest.fn(),\n isOver: false,\n active: null,\n })),\n}));\n\njest.mock('@dnd-kit/utilities', () => ({\n CSS: {\n Translate: {\n toString: jest.fn(() => 'translate3d(0, 0, 0)'),\n },\n },\n}));\n\ndescribe('DragInTheBlank', () => {\n const defaultProps = {\n disabled: false,\n feedback: {},\n markup,\n choices: [\n choice('Jumped', '0'),\n choice('Laughed', '1'),\n choice('Spoon', '2'),\n choice('Fork', '3'),\n choice('Bumped', '4'),\n choice('Smiled', '5'),\n ],\n\n value: {\n 0: undefined,\n },\n };\n\n describe('render', () => {\n it('renders correctly with default props', () => {\n const { container } = render(<DragInTheBlank {...defaultProps} />);\n expect(container.firstChild).toBeInTheDocument();\n // Check that markup content is rendered\n expect(screen.getByText(/Hey Diddle Diddle/)).toBeInTheDocument();\n expect(screen.getByText(/Hey, diddle, diddle,/)).toBeInTheDocument();\n });\n\n it('renders correctly with disabled prop as true', () => {\n const { container } = render(<DragInTheBlank {...defaultProps} disabled={true} />);\n expect(container.firstChild).toBeInTheDocument();\n });\n\n it('renders correctly with feedback', () => {\n const { container } = render(\n <DragInTheBlank\n {...defaultProps}\n feedback={{\n 0: {\n value: 'Jumped',\n correct: 'Jumped',\n },\n 1: {\n value: 'Laughed',\n correct: 'Laughed',\n },\n 2: {\n value: 'Spoon',\n correct: 'Spoon',\n },\n }}\n />,\n );\n expect(container.firstChild).toBeInTheDocument();\n });\n });\n});\n"],"mappings":";;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAC,sBAAA,CAAAH,OAAA;AAAkD,SAAAD,wBAAAK,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAP,uBAAA,YAAAA,wBAAAK,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,mBAAAT,CAAA,iBAAAA,CAAA,gBAAAU,OAAA,CAAAV,CAAA,0BAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,cAAAM,EAAA,IAAAd,CAAA,gBAAAc,EAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,EAAA,OAAAP,CAAA,IAAAD,CAAA,GAAAW,MAAA,CAAAC,cAAA,K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EAAE,OAAO;cACd8C,OAAO,EAAE;YACX;UACF;QAAE,EACH,CACH,CAAC;QAlBOT,SAAS,GAAAQ,QAAA,CAATR,SAAS;MAmBjBC,MAAM,CAACD,SAAS,CAACE,UAAU,CAAC,CAACC,iBAAiB,CAAC,CAAC;IAClD,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _componentize = _interopRequireDefault(require("../componentize"));
|
|
5
|
-
var _serialization = require("../serialization");
|
|
6
|
-
describe('index', function () {
|
|
7
|
-
describe('componentize', function () {
|
|
8
|
-
it('should return an array with the appropriate markup', function () {
|
|
9
|
-
var dropDownMarkup = (0, _componentize["default"])('{{0}} foo {{1}}', 'dropdown');
|
|
10
|
-
expect(dropDownMarkup).toEqual({
|
|
11
|
-
markup: '<span data-component="dropdown" data-id="0"></span> foo <span data-component="dropdown" data-id="1"></span>'
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
describe('serialization', function () {
|
|
16
|
-
it('should have default node a span', function () {
|
|
17
|
-
expect((0, _serialization.deserialize)('something')).toEqual(expect.objectContaining({
|
|
18
|
-
object: 'value',
|
|
19
|
-
document: {
|
|
20
|
-
object: 'document',
|
|
21
|
-
data: {},
|
|
22
|
-
nodes: [{
|
|
23
|
-
object: 'block',
|
|
24
|
-
data: {},
|
|
25
|
-
isVoid: false,
|
|
26
|
-
type: 'span',
|
|
27
|
-
nodes: [{
|
|
28
|
-
object: 'text',
|
|
29
|
-
leaves: [{
|
|
30
|
-
text: 'something'
|
|
31
|
-
}]
|
|
32
|
-
}]
|
|
33
|
-
}]
|
|
34
|
-
}
|
|
35
|
-
}));
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
//# sourceMappingURL=index.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.test.js","names":["_componentize","_interopRequireDefault","require","_serialization","describe","it","dropDownMarkup","componentize","expect","toEqual","markup","deserialize","objectContaining","object","document","data","nodes","isVoid","type","leaves","text"],"sources":["../../src/__tests__/index.test.js"],"sourcesContent":["import componentize from '../componentize';\nimport { deserialize } from '../serialization';\n\ndescribe('index', () => {\n describe('componentize', () => {\n it('should return an array with the appropriate markup', () => {\n const dropDownMarkup = componentize('{{0}} foo {{1}}', 'dropdown');\n\n expect(dropDownMarkup).toEqual({\n markup:\n '<span data-component=\"dropdown\" data-id=\"0\"></span> foo <span data-component=\"dropdown\" data-id=\"1\"></span>',\n });\n });\n });\n\n describe('serialization', () => {\n it('should have default node a span', () => {\n expect(deserialize('something')).toEqual(\n expect.objectContaining({\n object: 'value',\n document: {\n object: 'document',\n data: {},\n nodes: [\n {\n object: 'block',\n data: {},\n isVoid: false,\n type: 'span',\n nodes: [{ object: 'text', leaves: [{ text: 'something' }] }],\n },\n ],\n },\n }),\n );\n });\n });\n});\n"],"mappings":";;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AAEAE,QAAQ,CAAC,OAAO,EAAE,YAAM;EACtBA,QAAQ,CAAC,cAAc,EAAE,YAAM;IAC7BC,EAAE,CAAC,oDAAoD,EAAE,YAAM;MAC7D,IAAMC,cAAc,GAAG,IAAAC,wBAAY,EAAC,iBAAiB,EAAE,UAAU,CAAC;MAElEC,MAAM,CAACF,cAAc,CAAC,CAACG,OAAO,CAAC;QAC7BC,MAAM,EACJ;MACJ,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ,CAAC,CAAC;EAEFN,QAAQ,CAAC,eAAe,EAAE,YAAM;IAC9BC,EAAE,CAAC,iCAAiC,EAAE,YAAM;MAC1CG,MAAM,CAAC,IAAAG,0BAAW,EAAC,WAAW,CAAC,CAAC,CAACF,OAAO,CACtCD,MAAM,CAACI,gBAAgB,CAAC;QACtBC,MAAM,EAAE,OAAO;QACfC,QAAQ,EAAE;UACRD,MAAM,EAAE,UAAU;UAClBE,IAAI,EAAE,CAAC,CAAC;UACRC,KAAK,EAAE,CACL;YACEH,MAAM,EAAE,OAAO;YACfE,IAAI,EAAE,CAAC,CAAC;YACRE,MAAM,EAAE,KAAK;YACbC,IAAI,EAAE,MAAM;YACZF,KAAK,EAAE,CAAC;cAAEH,MAAM,EAAE,MAAM;cAAEM,MAAM,EAAE,CAAC;gBAAEC,IAAI,EAAE;cAAY,CAAC;YAAE,CAAC;UAC7D,CAAC;QAEL;MACF,CAAC,CACH,CAAC;IACH,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,344 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
6
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
7
|
-
var React = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _react2 = require("@testing-library/react");
|
|
9
|
-
var _mask = _interopRequireDefault(require("../mask"));
|
|
10
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
11
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
|
-
describe('Mask', function () {
|
|
14
|
-
// Don't mock renderChildren - let the component render naturally
|
|
15
|
-
var onChange = jest.fn();
|
|
16
|
-
var defaultProps = {
|
|
17
|
-
onChange: onChange,
|
|
18
|
-
layout: {
|
|
19
|
-
nodes: [{
|
|
20
|
-
object: 'text',
|
|
21
|
-
leaves: [{
|
|
22
|
-
text: 'Foo'
|
|
23
|
-
}]
|
|
24
|
-
}]
|
|
25
|
-
},
|
|
26
|
-
value: {}
|
|
27
|
-
};
|
|
28
|
-
beforeEach(function () {
|
|
29
|
-
onChange.mockClear();
|
|
30
|
-
});
|
|
31
|
-
describe('rendering', function () {
|
|
32
|
-
it('renders with default props', function () {
|
|
33
|
-
var _render = (0, _react2.render)(/*#__PURE__*/React.createElement(_mask["default"], defaultProps)),
|
|
34
|
-
container = _render.container;
|
|
35
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
36
|
-
});
|
|
37
|
-
it('renders text content', function () {
|
|
38
|
-
(0, _react2.render)(/*#__PURE__*/React.createElement(_mask["default"], defaultProps));
|
|
39
|
-
expect(_react2.screen.getByText('Foo')).toBeInTheDocument();
|
|
40
|
-
});
|
|
41
|
-
it('renders a paragraph element', function () {
|
|
42
|
-
var _render2 = (0, _react2.render)(/*#__PURE__*/React.createElement(_mask["default"], (0, _extends2["default"])({}, defaultProps, {
|
|
43
|
-
layout: {
|
|
44
|
-
nodes: [{
|
|
45
|
-
type: 'p',
|
|
46
|
-
nodes: [{
|
|
47
|
-
object: 'text',
|
|
48
|
-
leaves: [{
|
|
49
|
-
text: 'Foo'
|
|
50
|
-
}]
|
|
51
|
-
}]
|
|
52
|
-
}]
|
|
53
|
-
}
|
|
54
|
-
}))),
|
|
55
|
-
container = _render2.container;
|
|
56
|
-
|
|
57
|
-
// Paragraph is rendered as a styled div, not a <p> tag
|
|
58
|
-
expect(_react2.screen.getByText('Foo')).toBeInTheDocument();
|
|
59
|
-
});
|
|
60
|
-
it('renders nested div and paragraph', function () {
|
|
61
|
-
var _render3 = (0, _react2.render)(/*#__PURE__*/React.createElement(_mask["default"], (0, _extends2["default"])({}, defaultProps, {
|
|
62
|
-
layout: {
|
|
63
|
-
nodes: [{
|
|
64
|
-
type: 'div',
|
|
65
|
-
data: {
|
|
66
|
-
attributes: {}
|
|
67
|
-
},
|
|
68
|
-
nodes: [{
|
|
69
|
-
type: 'p',
|
|
70
|
-
data: {
|
|
71
|
-
attributes: {}
|
|
72
|
-
},
|
|
73
|
-
nodes: [{
|
|
74
|
-
object: 'text',
|
|
75
|
-
leaves: [{
|
|
76
|
-
text: 'Foo'
|
|
77
|
-
}]
|
|
78
|
-
}]
|
|
79
|
-
}]
|
|
80
|
-
}]
|
|
81
|
-
}
|
|
82
|
-
}))),
|
|
83
|
-
container = _render3.container;
|
|
84
|
-
expect(container.querySelector('div')).toBeInTheDocument();
|
|
85
|
-
// Paragraph is rendered as a styled div, not a <p> tag
|
|
86
|
-
expect(_react2.screen.getByText('Foo')).toBeInTheDocument();
|
|
87
|
-
});
|
|
88
|
-
it('renders text with italic marks', function () {
|
|
89
|
-
var _render4 = (0, _react2.render)(/*#__PURE__*/React.createElement(_mask["default"], (0, _extends2["default"])({}, defaultProps, {
|
|
90
|
-
layout: {
|
|
91
|
-
nodes: [{
|
|
92
|
-
leaves: [{
|
|
93
|
-
text: 'Foo '
|
|
94
|
-
}],
|
|
95
|
-
object: 'text'
|
|
96
|
-
}, {
|
|
97
|
-
leaves: [{
|
|
98
|
-
marks: [{
|
|
99
|
-
data: undefined,
|
|
100
|
-
type: 'italic'
|
|
101
|
-
}],
|
|
102
|
-
text: 'x'
|
|
103
|
-
}],
|
|
104
|
-
object: 'text'
|
|
105
|
-
}, {
|
|
106
|
-
leaves: [{
|
|
107
|
-
text: ' bar'
|
|
108
|
-
}],
|
|
109
|
-
object: 'text'
|
|
110
|
-
}],
|
|
111
|
-
object: 'block',
|
|
112
|
-
type: 'div'
|
|
113
|
-
}
|
|
114
|
-
}))),
|
|
115
|
-
container = _render4.container;
|
|
116
|
-
|
|
117
|
-
// Text "Foo " is split with spaces, use regex
|
|
118
|
-
expect(_react2.screen.getByText(/Foo/)).toBeInTheDocument();
|
|
119
|
-
expect(_react2.screen.getByText('x')).toBeInTheDocument();
|
|
120
|
-
expect(_react2.screen.getByText(/bar/)).toBeInTheDocument();
|
|
121
|
-
// Check for italic/em element
|
|
122
|
-
var em = container.querySelector('em, i');
|
|
123
|
-
expect(em).toBeInTheDocument();
|
|
124
|
-
expect(em.textContent).toBe('x');
|
|
125
|
-
});
|
|
126
|
-
it('renders tbody without extra space', function () {
|
|
127
|
-
var da = function da() {
|
|
128
|
-
return {
|
|
129
|
-
data: {
|
|
130
|
-
attributes: {}
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
};
|
|
134
|
-
var _render5 = (0, _react2.render)(/*#__PURE__*/React.createElement(_mask["default"], (0, _extends2["default"])({}, defaultProps, {
|
|
135
|
-
layout: {
|
|
136
|
-
nodes: [_objectSpread(_objectSpread({
|
|
137
|
-
type: 'table'
|
|
138
|
-
}, da()), {}, {
|
|
139
|
-
nodes: [_objectSpread(_objectSpread({
|
|
140
|
-
type: 'tbody'
|
|
141
|
-
}, da()), {}, {
|
|
142
|
-
nodes: [{
|
|
143
|
-
object: 'text',
|
|
144
|
-
leaves: [{
|
|
145
|
-
text: ' '
|
|
146
|
-
}]
|
|
147
|
-
}, _objectSpread(_objectSpread({
|
|
148
|
-
type: 'tr'
|
|
149
|
-
}, da()), {}, {
|
|
150
|
-
nodes: []
|
|
151
|
-
})]
|
|
152
|
-
})]
|
|
153
|
-
})]
|
|
154
|
-
}
|
|
155
|
-
}))),
|
|
156
|
-
container = _render5.container;
|
|
157
|
-
expect(container.querySelector('table')).toBeInTheDocument();
|
|
158
|
-
expect(container.querySelector('tbody')).toBeInTheDocument();
|
|
159
|
-
expect(container.querySelector('tr')).toBeInTheDocument();
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
describe('spacer rendering for DnD components', function () {
|
|
163
|
-
it('adds spacers before and after DnD blank components', function () {
|
|
164
|
-
var mockRenderChildren = jest.fn(function (n) {
|
|
165
|
-
var _n$data;
|
|
166
|
-
if (((_n$data = n.data) === null || _n$data === void 0 || (_n$data = _n$data.dataset) === null || _n$data === void 0 ? void 0 : _n$data.component) === 'blank') {
|
|
167
|
-
return /*#__PURE__*/React.createElement("span", {
|
|
168
|
-
"data-testid": "blank-component"
|
|
169
|
-
}, "Blank");
|
|
170
|
-
}
|
|
171
|
-
return null;
|
|
172
|
-
});
|
|
173
|
-
var _render6 = (0, _react2.render)(/*#__PURE__*/React.createElement(_mask["default"], (0, _extends2["default"])({}, defaultProps, {
|
|
174
|
-
renderChildren: mockRenderChildren,
|
|
175
|
-
layout: {
|
|
176
|
-
nodes: [{
|
|
177
|
-
type: 'div',
|
|
178
|
-
data: {
|
|
179
|
-
dataset: {
|
|
180
|
-
component: 'blank'
|
|
181
|
-
},
|
|
182
|
-
attributes: {}
|
|
183
|
-
},
|
|
184
|
-
nodes: []
|
|
185
|
-
}]
|
|
186
|
-
}
|
|
187
|
-
}))),
|
|
188
|
-
container = _render6.container;
|
|
189
|
-
|
|
190
|
-
// Check that renderChildren was called and spacers are present
|
|
191
|
-
// Count all children in the container - should be: spacer + blank + spacer = 3 elements
|
|
192
|
-
var maskContainer = container.firstChild;
|
|
193
|
-
expect(maskContainer.childNodes.length).toBe(3);
|
|
194
|
-
expect(_react2.screen.getByTestId('blank-component')).toBeInTheDocument();
|
|
195
|
-
});
|
|
196
|
-
it('does not add spacers for non-DnD components', function () {
|
|
197
|
-
var mockRenderChildren = jest.fn(function (n) {
|
|
198
|
-
return /*#__PURE__*/React.createElement("span", {
|
|
199
|
-
"data-testid": "regular-component"
|
|
200
|
-
}, "Regular");
|
|
201
|
-
});
|
|
202
|
-
var _render7 = (0, _react2.render)(/*#__PURE__*/React.createElement(_mask["default"], (0, _extends2["default"])({}, defaultProps, {
|
|
203
|
-
renderChildren: mockRenderChildren,
|
|
204
|
-
layout: {
|
|
205
|
-
nodes: [{
|
|
206
|
-
type: 'div',
|
|
207
|
-
data: {
|
|
208
|
-
attributes: {}
|
|
209
|
-
},
|
|
210
|
-
nodes: []
|
|
211
|
-
}]
|
|
212
|
-
}
|
|
213
|
-
}))),
|
|
214
|
-
container = _render7.container;
|
|
215
|
-
|
|
216
|
-
// Should not have spacers - only the regular component
|
|
217
|
-
var maskContainer = container.firstChild;
|
|
218
|
-
expect(maskContainer.childNodes.length).toBe(1);
|
|
219
|
-
expect(_react2.screen.getByTestId('regular-component')).toBeInTheDocument();
|
|
220
|
-
});
|
|
221
|
-
it('adds spacers regardless of parent node type', function () {
|
|
222
|
-
var mockRenderChildren = jest.fn(function (n) {
|
|
223
|
-
var _n$data2;
|
|
224
|
-
if (((_n$data2 = n.data) === null || _n$data2 === void 0 || (_n$data2 = _n$data2.dataset) === null || _n$data2 === void 0 ? void 0 : _n$data2.component) === 'blank') {
|
|
225
|
-
return /*#__PURE__*/React.createElement("span", {
|
|
226
|
-
"data-testid": "blank-in-td"
|
|
227
|
-
}, "Blank in TD");
|
|
228
|
-
}
|
|
229
|
-
return null;
|
|
230
|
-
});
|
|
231
|
-
var _render8 = (0, _react2.render)(/*#__PURE__*/React.createElement(_mask["default"], (0, _extends2["default"])({}, defaultProps, {
|
|
232
|
-
renderChildren: mockRenderChildren,
|
|
233
|
-
elementType: "drag-in-the-blank",
|
|
234
|
-
layout: {
|
|
235
|
-
nodes: [{
|
|
236
|
-
type: 'table',
|
|
237
|
-
data: {
|
|
238
|
-
attributes: {}
|
|
239
|
-
},
|
|
240
|
-
nodes: [{
|
|
241
|
-
type: 'tbody',
|
|
242
|
-
data: {
|
|
243
|
-
attributes: {}
|
|
244
|
-
},
|
|
245
|
-
nodes: [{
|
|
246
|
-
type: 'tr',
|
|
247
|
-
data: {
|
|
248
|
-
attributes: {}
|
|
249
|
-
},
|
|
250
|
-
nodes: [{
|
|
251
|
-
type: 'td',
|
|
252
|
-
data: {
|
|
253
|
-
attributes: {}
|
|
254
|
-
},
|
|
255
|
-
nodes: [{
|
|
256
|
-
type: 'div',
|
|
257
|
-
data: {
|
|
258
|
-
dataset: {
|
|
259
|
-
component: 'blank'
|
|
260
|
-
},
|
|
261
|
-
attributes: {}
|
|
262
|
-
},
|
|
263
|
-
nodes: []
|
|
264
|
-
}]
|
|
265
|
-
}]
|
|
266
|
-
}]
|
|
267
|
-
}]
|
|
268
|
-
}]
|
|
269
|
-
}
|
|
270
|
-
}))),
|
|
271
|
-
container = _render8.container;
|
|
272
|
-
|
|
273
|
-
// Should have spacers even inside td element
|
|
274
|
-
var td = container.querySelector('td');
|
|
275
|
-
expect(td.childNodes.length).toBe(3); // spacer + blank + spacer
|
|
276
|
-
expect(_react2.screen.getByTestId('blank-in-td')).toBeInTheDocument();
|
|
277
|
-
});
|
|
278
|
-
it('does not add spacers for text content', function () {
|
|
279
|
-
var _render9 = (0, _react2.render)(/*#__PURE__*/React.createElement(_mask["default"], (0, _extends2["default"])({}, defaultProps, {
|
|
280
|
-
elementType: "drag-in-the-blank",
|
|
281
|
-
layout: {
|
|
282
|
-
nodes: [{
|
|
283
|
-
object: 'text',
|
|
284
|
-
leaves: [{
|
|
285
|
-
text: 'Some text'
|
|
286
|
-
}]
|
|
287
|
-
}]
|
|
288
|
-
}
|
|
289
|
-
}))),
|
|
290
|
-
container = _render9.container;
|
|
291
|
-
|
|
292
|
-
// Should not have spacers for plain text - just text node
|
|
293
|
-
var maskContainer = container.firstChild;
|
|
294
|
-
expect(maskContainer.childNodes.length).toBe(1);
|
|
295
|
-
expect(maskContainer.childNodes[0].nodeType).toBe(Node.TEXT_NODE);
|
|
296
|
-
expect(_react2.screen.getByText('Some text')).toBeInTheDocument();
|
|
297
|
-
});
|
|
298
|
-
it('handles multiple DnD components with correct spacer placement', function () {
|
|
299
|
-
var mockRenderChildren = jest.fn(function (n) {
|
|
300
|
-
var _n$data3;
|
|
301
|
-
if (((_n$data3 = n.data) === null || _n$data3 === void 0 || (_n$data3 = _n$data3.dataset) === null || _n$data3 === void 0 ? void 0 : _n$data3.component) === 'blank') {
|
|
302
|
-
return /*#__PURE__*/React.createElement("span", {
|
|
303
|
-
"data-testid": "blank-".concat(n.data.testId)
|
|
304
|
-
}, "Blank");
|
|
305
|
-
}
|
|
306
|
-
return null;
|
|
307
|
-
});
|
|
308
|
-
var _render0 = (0, _react2.render)(/*#__PURE__*/React.createElement(_mask["default"], (0, _extends2["default"])({}, defaultProps, {
|
|
309
|
-
renderChildren: mockRenderChildren,
|
|
310
|
-
layout: {
|
|
311
|
-
nodes: [{
|
|
312
|
-
type: 'div',
|
|
313
|
-
data: {
|
|
314
|
-
dataset: {
|
|
315
|
-
component: 'blank'
|
|
316
|
-
},
|
|
317
|
-
attributes: {},
|
|
318
|
-
testId: '1'
|
|
319
|
-
},
|
|
320
|
-
nodes: []
|
|
321
|
-
}, {
|
|
322
|
-
type: 'div',
|
|
323
|
-
data: {
|
|
324
|
-
dataset: {
|
|
325
|
-
component: 'blank'
|
|
326
|
-
},
|
|
327
|
-
attributes: {},
|
|
328
|
-
testId: '2'
|
|
329
|
-
},
|
|
330
|
-
nodes: []
|
|
331
|
-
}]
|
|
332
|
-
}
|
|
333
|
-
}))),
|
|
334
|
-
container = _render0.container;
|
|
335
|
-
|
|
336
|
-
// Should have 2 spacers per component = 4 spacers + 2 blanks = 6 total children
|
|
337
|
-
var maskContainer = container.firstChild;
|
|
338
|
-
expect(maskContainer.childNodes.length).toBe(6);
|
|
339
|
-
expect(_react2.screen.getByTestId('blank-1')).toBeInTheDocument();
|
|
340
|
-
expect(_react2.screen.getByTestId('blank-2')).toBeInTheDocument();
|
|
341
|
-
});
|
|
342
|
-
});
|
|
343
|
-
});
|
|
344
|
-
//# sourceMappingURL=mask.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mask.test.js","names":["React","_interopRequireWildcard","require","_react2","_mask","_interopRequireDefault","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ownKeys","keys","getOwnPropertySymbols","filter","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","describe","onChange","jest","fn","defaultProps","layout","nodes","object","leaves","text","value","beforeEach","mockClear","it","_render","render","createElement","container","expect","firstChild","toBeInTheDocument","screen","getByText","_render2","_extends2","type","_render3","data","attributes","querySelector","_render4","marks","undefined","em","textContent","toBe","da","_render5","mockRenderChildren","_n$data","dataset","component","_render6","renderChildren","maskContainer","childNodes","getByTestId","_render7","_n$data2","_render8","elementType","td","_render9","nodeType","Node","TEXT_NODE","_n$data3","concat","testId","_render0"],"sources":["../../src/__tests__/mask.test.js"],"sourcesContent":["import * as React from 'react';\nimport { render, screen } from '@testing-library/react';\nimport Mask from '../mask';\n\ndescribe('Mask', () => {\n // Don't mock renderChildren - let the component render naturally\n const onChange = jest.fn();\n const defaultProps = {\n onChange,\n layout: {\n nodes: [\n {\n object: 'text',\n leaves: [\n {\n text: 'Foo',\n },\n ],\n },\n ],\n },\n value: {},\n };\n\n beforeEach(() => {\n onChange.mockClear();\n });\n\n describe('rendering', () => {\n it('renders with default props', () => {\n const { container } = render(<Mask {...defaultProps} />);\n expect(container.firstChild).toBeInTheDocument();\n });\n\n it('renders text content', () => {\n render(<Mask {...defaultProps} />);\n expect(screen.getByText('Foo')).toBeInTheDocument();\n });\n\n it('renders a paragraph element', () => {\n const { container } = render(\n <Mask\n {...defaultProps}\n layout={{\n nodes: [\n {\n type: 'p',\n nodes: [\n {\n object: 'text',\n leaves: [\n {\n text: 'Foo',\n },\n ],\n },\n ],\n },\n ],\n }}\n />,\n );\n\n // Paragraph is rendered as a styled div, not a <p> tag\n expect(screen.getByText('Foo')).toBeInTheDocument();\n });\n\n it('renders nested div and paragraph', () => {\n const { container } = render(\n <Mask\n {...defaultProps}\n layout={{\n nodes: [\n {\n type: 'div',\n data: {\n attributes: {},\n },\n nodes: [\n {\n type: 'p',\n data: {\n attributes: {},\n },\n nodes: [\n {\n object: 'text',\n leaves: [\n {\n text: 'Foo',\n },\n ],\n },\n ],\n },\n ],\n },\n ],\n }}\n />,\n );\n\n expect(container.querySelector('div')).toBeInTheDocument();\n // Paragraph is rendered as a styled div, not a <p> tag\n expect(screen.getByText('Foo')).toBeInTheDocument();\n });\n\n it('renders text with italic marks', () => {\n const { container } = render(\n <Mask\n {...defaultProps}\n layout={{\n nodes: [\n {\n leaves: [{ text: 'Foo ' }],\n object: 'text',\n },\n {\n leaves: [\n {\n marks: [\n {\n data: undefined,\n type: 'italic',\n },\n ],\n text: 'x',\n },\n ],\n object: 'text',\n },\n {\n leaves: [{ text: ' bar' }],\n object: 'text',\n },\n ],\n object: 'block',\n type: 'div',\n }}\n />,\n );\n\n // Text \"Foo \" is split with spaces, use regex\n expect(screen.getByText(/Foo/)).toBeInTheDocument();\n expect(screen.getByText('x')).toBeInTheDocument();\n expect(screen.getByText(/bar/)).toBeInTheDocument();\n // Check for italic/em element\n const em = container.querySelector('em, i');\n expect(em).toBeInTheDocument();\n expect(em.textContent).toBe('x');\n });\n\n it('renders tbody without extra space', () => {\n const da = () => ({ data: { attributes: {} } });\n const { container } = render(\n <Mask\n {...defaultProps}\n layout={{\n nodes: [\n {\n type: 'table',\n ...da(),\n nodes: [\n {\n type: 'tbody',\n ...da(),\n nodes: [\n {\n object: 'text',\n leaves: [{ text: ' ' }],\n },\n { type: 'tr', ...da(), nodes: [] },\n ],\n },\n ],\n },\n ],\n }}\n />,\n );\n\n expect(container.querySelector('table')).toBeInTheDocument();\n expect(container.querySelector('tbody')).toBeInTheDocument();\n expect(container.querySelector('tr')).toBeInTheDocument();\n });\n });\n\n describe('spacer rendering for DnD components', () => {\n it('adds spacers before and after DnD blank components', () => {\n const mockRenderChildren = jest.fn((n) => {\n if (n.data?.dataset?.component === 'blank') {\n return <span data-testid=\"blank-component\">Blank</span>;\n }\n return null;\n });\n\n const { container } = render(\n <Mask\n {...defaultProps}\n renderChildren={mockRenderChildren}\n layout={{\n nodes: [\n {\n type: 'div',\n data: {\n dataset: { component: 'blank' },\n attributes: {},\n },\n nodes: [],\n },\n ],\n }}\n />,\n );\n\n // Check that renderChildren was called and spacers are present\n // Count all children in the container - should be: spacer + blank + spacer = 3 elements\n const maskContainer = container.firstChild;\n expect(maskContainer.childNodes.length).toBe(3);\n expect(screen.getByTestId('blank-component')).toBeInTheDocument();\n });\n\n it('does not add spacers for non-DnD components', () => {\n const mockRenderChildren = jest.fn((n) => {\n return <span data-testid=\"regular-component\">Regular</span>;\n });\n\n const { container } = render(\n <Mask\n {...defaultProps}\n renderChildren={mockRenderChildren}\n layout={{\n nodes: [\n {\n type: 'div',\n data: {\n attributes: {},\n },\n nodes: [],\n },\n ],\n }}\n />,\n );\n\n // Should not have spacers - only the regular component\n const maskContainer = container.firstChild;\n expect(maskContainer.childNodes.length).toBe(1);\n expect(screen.getByTestId('regular-component')).toBeInTheDocument();\n });\n\n it('adds spacers regardless of parent node type', () => {\n const mockRenderChildren = jest.fn((n) => {\n if (n.data?.dataset?.component === 'blank') {\n return <span data-testid=\"blank-in-td\">Blank in TD</span>;\n }\n return null;\n });\n\n const { container } = render(\n <Mask\n {...defaultProps}\n renderChildren={mockRenderChildren}\n elementType=\"drag-in-the-blank\"\n layout={{\n nodes: [\n {\n type: 'table',\n data: { attributes: {} },\n nodes: [\n {\n type: 'tbody',\n data: { attributes: {} },\n nodes: [\n {\n type: 'tr',\n data: { attributes: {} },\n nodes: [\n {\n type: 'td',\n data: { attributes: {} },\n nodes: [\n {\n type: 'div',\n data: {\n dataset: { component: 'blank' },\n attributes: {},\n },\n nodes: [],\n },\n ],\n },\n ],\n },\n ],\n },\n ],\n },\n ],\n }}\n />,\n );\n\n // Should have spacers even inside td element\n const td = container.querySelector('td');\n expect(td.childNodes.length).toBe(3); // spacer + blank + spacer\n expect(screen.getByTestId('blank-in-td')).toBeInTheDocument();\n });\n\n it('does not add spacers for text content', () => {\n const { container } = render(\n <Mask\n {...defaultProps}\n elementType=\"drag-in-the-blank\"\n layout={{\n nodes: [\n {\n object: 'text',\n leaves: [\n {\n text: 'Some text',\n },\n ],\n },\n ],\n }}\n />,\n );\n\n // Should not have spacers for plain text - just text node\n const maskContainer = container.firstChild;\n expect(maskContainer.childNodes.length).toBe(1);\n expect(maskContainer.childNodes[0].nodeType).toBe(Node.TEXT_NODE);\n expect(screen.getByText('Some text')).toBeInTheDocument();\n });\n\n it('handles multiple DnD components with correct spacer placement', () => {\n const mockRenderChildren = jest.fn((n) => {\n if (n.data?.dataset?.component === 'blank') {\n return <span data-testid={`blank-${n.data.testId}`}>Blank</span>;\n }\n return null;\n });\n\n const { container } = render(\n <Mask\n {...defaultProps}\n renderChildren={mockRenderChildren}\n layout={{\n nodes: [\n {\n type: 'div',\n data: {\n dataset: { component: 'blank' },\n attributes: {},\n testId: '1',\n },\n nodes: [],\n },\n {\n type: 'div',\n data: {\n dataset: { component: 'blank' },\n attributes: {},\n testId: '2',\n },\n nodes: [],\n },\n ],\n }}\n />,\n );\n\n // Should have 2 spacers per component = 4 spacers + 2 blanks = 6 total children\n const maskContainer = container.firstChild;\n expect(maskContainer.childNodes.length).toBe(6);\n expect(screen.getByTestId('blank-1')).toBeIn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,SAAS,GAAA0C,QAAA,CAAT1C,SAAS;;MA6BjB;MACA,IAAM2B,aAAa,GAAG3B,SAAS,CAACE,UAAU;MAC1CD,MAAM,CAAC0B,aAAa,CAACC,UAAU,CAAClD,MAAM,CAAC,CAACwC,IAAI,CAAC,CAAC,CAAC;MAC/CjB,MAAM,CAACG,cAAM,CAACyB,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC1B,iBAAiB,CAAC,CAAC;MACzDF,MAAM,CAACG,cAAM,CAACyB,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC1B,iBAAiB,CAAC,CAAC;IAC3D,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _serialization = require("../serialization");
|
|
4
|
-
describe('serialization', function () {
|
|
5
|
-
it('ignores comments', function () {
|
|
6
|
-
var out = (0, _serialization.deserialize)("<!-- hi -->");
|
|
7
|
-
expect(out.document.nodes[0]).toEqual(expect.objectContaining({
|
|
8
|
-
type: 'span'
|
|
9
|
-
}));
|
|
10
|
-
});
|
|
11
|
-
it('ignores comments', function () {
|
|
12
|
-
var out = (0, _serialization.deserialize)("<!-- hi --><div>foo</div>");
|
|
13
|
-
expect(out.document.nodes[0]).toEqual(expect.objectContaining({
|
|
14
|
-
type: 'div',
|
|
15
|
-
nodes: [expect.objectContaining({
|
|
16
|
-
object: 'text',
|
|
17
|
-
leaves: [{
|
|
18
|
-
text: 'foo'
|
|
19
|
-
}]
|
|
20
|
-
})]
|
|
21
|
-
}));
|
|
22
|
-
});
|
|
23
|
-
it('deserializes an em', function () {
|
|
24
|
-
var out = (0, _serialization.deserialize)("<!-- hi --><div> <em>x</em> </div>");
|
|
25
|
-
expect(out.document.nodes[0]).toEqual(expect.objectContaining({
|
|
26
|
-
type: 'div',
|
|
27
|
-
nodes: [expect.objectContaining({
|
|
28
|
-
object: 'text'
|
|
29
|
-
}), expect.objectContaining({
|
|
30
|
-
leaves: [{
|
|
31
|
-
marks: [{
|
|
32
|
-
data: undefined,
|
|
33
|
-
type: 'italic'
|
|
34
|
-
}],
|
|
35
|
-
text: 'x'
|
|
36
|
-
}],
|
|
37
|
-
object: 'text'
|
|
38
|
-
}), expect.objectContaining({
|
|
39
|
-
object: 'text'
|
|
40
|
-
})]
|
|
41
|
-
}));
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
//# sourceMappingURL=serialization.test.js.map
|