@contentful/field-editor-rich-text 6.3.7 → 6.3.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/dist/cjs/Toolbar/_tests_/toolbar.test.js +13 -13
- package/dist/cjs/helpers/__tests__/extractNodes.test.js +16 -15
- package/dist/cjs/helpers/__tests__/removeInternalMarks.test.js +5 -4
- package/dist/cjs/helpers/__tests__/toSlateDoc.test.js +4 -3
- package/dist/cjs/helpers/__tests__/validations.test.js +9 -8
- package/dist/cjs/helpers/formatDateAndTime.spec.js +44 -43
- package/dist/cjs/helpers/sdkNavigatorSlideIn.spec.js +38 -37
- package/dist/cjs/plugins/Break/createExitBreakPlugin.test.js +5 -4
- package/dist/cjs/plugins/Break/createSoftBreakPlugin.test.js +4 -3
- package/dist/cjs/plugins/CharCounter/utils.spec.js +6 -5
- package/dist/cjs/plugins/CommandPalette/onKeyDown.spec.js +14 -12
- package/dist/cjs/plugins/CommandPalette/utils/insertBlock.test.js +11 -9
- package/dist/cjs/plugins/Heading/__tests__/createHeadingPlugin.test.js +10 -9
- package/dist/cjs/plugins/Hyperlink/__tests__/createHyperlinkPlugin.test.js +3 -2
- package/dist/cjs/plugins/Hyperlink/__tests__/recommendations-searchQuery.test.js +15 -11
- package/dist/cjs/plugins/List/__tests__/createListPlugin.test.js +6 -5
- package/dist/cjs/plugins/List/__tests__/insertListBreak.test.js +3 -2
- package/dist/cjs/plugins/List/__tests__/insertListFragment.test.js +3 -2
- package/dist/cjs/plugins/List/transforms/moveListItems.test.js +5 -4
- package/dist/cjs/plugins/List/transforms/toggleList.spec.js +13 -12
- package/dist/cjs/plugins/Normalizer/createNormalizerPlugin.test.js +11 -10
- package/dist/cjs/plugins/Paragraph/__tests__/createParagraphPlugin.test.js +11 -10
- package/dist/cjs/plugins/PasteHTML/utils/__tests__/sanitizeHTML.test.js +4 -3
- package/dist/cjs/plugins/Quote/__test__/createQuotePlugin.test.js +8 -7
- package/dist/cjs/plugins/Table/__tests__/createTablePlugin.test.js +13 -12
- package/dist/cjs/plugins/Table/__tests__/helpers.test.js +2 -1
- package/dist/cjs/plugins/Text/__tests__/createTextPlugin.test.js +5 -4
- package/dist/cjs/plugins/shared/__tests__/EmbeddedBlockUtil.test.js +16 -14
- package/dist/cjs/plugins/shared/__tests__/FetchingWrappedAssetCard.test.js +11 -11
- package/dist/cjs/plugins/shared/__tests__/FetchingWrappedEntryCard.test.js +11 -11
- package/dist/cjs/plugins/shared/__tests__/FetchingWrappedResourceCard.test.js +21 -21
- package/dist/cjs/test-utils/assertOutput.js +3 -2
- package/dist/cjs/test-utils/createTestEditor.js +2 -1
- package/dist/esm/Toolbar/_tests_/toolbar.test.js +3 -3
- package/dist/esm/helpers/__tests__/extractNodes.test.js +1 -0
- package/dist/esm/helpers/__tests__/removeInternalMarks.test.js +1 -0
- package/dist/esm/helpers/__tests__/toSlateDoc.test.js +1 -0
- package/dist/esm/helpers/__tests__/validations.test.js +1 -0
- package/dist/esm/helpers/formatDateAndTime.spec.js +4 -3
- package/dist/esm/helpers/sdkNavigatorSlideIn.spec.js +4 -3
- package/dist/esm/plugins/Break/createExitBreakPlugin.test.js +1 -0
- package/dist/esm/plugins/Break/createSoftBreakPlugin.test.js +1 -0
- package/dist/esm/plugins/CharCounter/utils.spec.js +3 -2
- package/dist/esm/plugins/CommandPalette/onKeyDown.spec.js +7 -5
- package/dist/esm/plugins/CommandPalette/utils/insertBlock.test.js +5 -3
- package/dist/esm/plugins/Heading/__tests__/createHeadingPlugin.test.js +1 -0
- package/dist/esm/plugins/Hyperlink/__tests__/createHyperlinkPlugin.test.js +1 -0
- package/dist/esm/plugins/Hyperlink/__tests__/recommendations-searchQuery.test.js +4 -3
- package/dist/esm/plugins/List/__tests__/createListPlugin.test.js +1 -0
- package/dist/esm/plugins/List/__tests__/insertListBreak.test.js +1 -0
- package/dist/esm/plugins/List/__tests__/insertListFragment.test.js +1 -0
- package/dist/esm/plugins/List/transforms/moveListItems.test.js +1 -0
- package/dist/esm/plugins/List/transforms/toggleList.spec.js +1 -0
- package/dist/esm/plugins/Normalizer/createNormalizerPlugin.test.js +1 -0
- package/dist/esm/plugins/Paragraph/__tests__/createParagraphPlugin.test.js +1 -0
- package/dist/esm/plugins/PasteHTML/utils/__tests__/sanitizeHTML.test.js +1 -0
- package/dist/esm/plugins/Quote/__test__/createQuotePlugin.test.js +1 -0
- package/dist/esm/plugins/Table/__tests__/createTablePlugin.test.js +1 -0
- package/dist/esm/plugins/Table/__tests__/helpers.test.js +1 -0
- package/dist/esm/plugins/Text/__tests__/createTextPlugin.test.js +1 -0
- package/dist/esm/plugins/shared/__tests__/EmbeddedBlockUtil.test.js +11 -9
- package/dist/esm/plugins/shared/__tests__/FetchingWrappedAssetCard.test.js +5 -5
- package/dist/esm/plugins/shared/__tests__/FetchingWrappedEntryCard.test.js +6 -6
- package/dist/esm/plugins/shared/__tests__/FetchingWrappedResourceCard.test.js +7 -7
- package/dist/esm/test-utils/assertOutput.js +1 -0
- package/dist/esm/test-utils/createTestEditor.js +2 -1
- package/dist/types/Toolbar/_tests_/toolbar.test.d.ts +1 -1
- package/dist/types/plugins/Hyperlink/__tests__/recommendations-searchQuery.test.d.ts +1 -0
- package/dist/types/plugins/shared/__tests__/FetchingWrappedAssetCard.test.d.ts +1 -1
- package/dist/types/plugins/shared/__tests__/FetchingWrappedEntryCard.test.d.ts +1 -1
- package/dist/types/plugins/shared/__tests__/FetchingWrappedResourceCard.test.d.ts +1 -1
- package/package.json +7 -7
|
@@ -3,10 +3,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
const _platebreak = require("@udecode/plate-break");
|
|
6
|
+
const _vitest = require("vitest");
|
|
6
7
|
const _testutils = require("../../test-utils");
|
|
7
8
|
const _createSoftBreakPlugin = require("./createSoftBreakPlugin");
|
|
8
|
-
describe('Soft Break', ()=>{
|
|
9
|
-
it('derives its config from other plugins', ()=>{
|
|
9
|
+
(0, _vitest.describe)('Soft Break', ()=>{
|
|
10
|
+
(0, _vitest.it)('derives its config from other plugins', ()=>{
|
|
10
11
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null)));
|
|
11
12
|
const rules = [
|
|
12
13
|
{
|
|
@@ -40,7 +41,7 @@ describe('Soft Break', ()=>{
|
|
|
40
41
|
]
|
|
41
42
|
});
|
|
42
43
|
const outPlugin = editor.pluginsByKey[_platebreak.KEY_SOFT_BREAK];
|
|
43
|
-
expect(outPlugin.options).toEqual({
|
|
44
|
+
(0, _vitest.expect)(outPlugin.options).toEqual({
|
|
44
45
|
rules
|
|
45
46
|
});
|
|
46
47
|
});
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
const
|
|
5
|
+
const _contentfulslatejsadapter = require("@contentful/contentful-slatejs-adapter");
|
|
6
6
|
const _richtextplaintextrenderer = require("@contentful/rich-text-plain-text-renderer");
|
|
7
|
+
const _vitest = require("vitest");
|
|
8
|
+
const _testutils = require("../../test-utils");
|
|
7
9
|
const _utils = require("./utils");
|
|
8
|
-
|
|
9
|
-
describe('getTextContent', ()=>{
|
|
10
|
+
(0, _vitest.describe)('getTextContent', ()=>{
|
|
10
11
|
const cases = [
|
|
11
12
|
{
|
|
12
13
|
title: 'empty document',
|
|
@@ -40,8 +41,8 @@ describe('getTextContent', ()=>{
|
|
|
40
41
|
}
|
|
41
42
|
];
|
|
42
43
|
cases.forEach(({ title, input })=>{
|
|
43
|
-
it(title, ()=>{
|
|
44
|
-
expect((0, _utils.getTextContent)(input)).toBe((0, _richtextplaintextrenderer.documentToPlainTextString)((0, _contentfulslatejsadapter.toContentfulDocument)({
|
|
44
|
+
(0, _vitest.it)(title, ()=>{
|
|
45
|
+
(0, _vitest.expect)((0, _utils.getTextContent)(input)).toBe((0, _richtextplaintextrenderer.documentToPlainTextString)((0, _contentfulslatejsadapter.toContentfulDocument)({
|
|
45
46
|
document: input.children
|
|
46
47
|
})));
|
|
47
48
|
});
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
+
const _vitest = require("vitest");
|
|
5
6
|
const _transforms = /*#__PURE__*/ _interop_require_wildcard(require("../../internal/transforms"));
|
|
6
7
|
const _testutils = require("../../test-utils");
|
|
7
8
|
const _constants = require("./constants");
|
|
@@ -47,20 +48,21 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
47
48
|
}
|
|
48
49
|
return newObj;
|
|
49
50
|
}
|
|
50
|
-
|
|
51
|
+
_vitest.vi.mock('../../internal/transforms', async ()=>{
|
|
52
|
+
const actual = await _vitest.vi.importActual('../../internal/transforms');
|
|
51
53
|
return {
|
|
52
54
|
__esModule: true,
|
|
53
|
-
...
|
|
55
|
+
...actual
|
|
54
56
|
};
|
|
55
57
|
});
|
|
56
|
-
describe('onKeyDown', ()=>{
|
|
58
|
+
(0, _vitest.describe)('onKeyDown', ()=>{
|
|
57
59
|
const { editor } = (0, _testutils.createTestEditor)({});
|
|
58
|
-
const addMark =
|
|
59
|
-
const onCommandPaletteAction =
|
|
60
|
-
afterEach(()=>{
|
|
61
|
-
|
|
60
|
+
const addMark = _vitest.vi.spyOn(_transforms, 'addMark');
|
|
61
|
+
const onCommandPaletteAction = _vitest.vi.spyOn(editor.tracking, 'onCommandPaletteAction');
|
|
62
|
+
(0, _vitest.afterEach)(()=>{
|
|
63
|
+
_vitest.vi.resetAllMocks();
|
|
62
64
|
});
|
|
63
|
-
test.each`
|
|
65
|
+
_vitest.test.each`
|
|
64
66
|
layout | key
|
|
65
67
|
${'QUERTY'} | ${{
|
|
66
68
|
key: '/',
|
|
@@ -77,9 +79,9 @@ describe('onKeyDown', ()=>{
|
|
|
77
79
|
type: 'keydown',
|
|
78
80
|
...key
|
|
79
81
|
});
|
|
80
|
-
expect(addMark).toHaveBeenCalledTimes(1);
|
|
81
|
-
expect(addMark).toHaveBeenCalledWith(editor, _constants.COMMAND_PROMPT);
|
|
82
|
-
expect(onCommandPaletteAction).toHaveBeenCalledTimes(1);
|
|
83
|
-
expect(onCommandPaletteAction).toHaveBeenCalledWith('openRichTextCommandPalette');
|
|
82
|
+
(0, _vitest.expect)(addMark).toHaveBeenCalledTimes(1);
|
|
83
|
+
(0, _vitest.expect)(addMark).toHaveBeenCalledWith(editor, _constants.COMMAND_PROMPT);
|
|
84
|
+
(0, _vitest.expect)(onCommandPaletteAction).toHaveBeenCalledTimes(1);
|
|
85
|
+
(0, _vitest.expect)(onCommandPaletteAction).toHaveBeenCalledWith('openRichTextCommandPalette');
|
|
84
86
|
});
|
|
85
87
|
});
|
|
@@ -4,16 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
const _richtexttypes = require("@contentful/rich-text-types");
|
|
6
6
|
const _platetestutils = require("@udecode/plate-test-utils");
|
|
7
|
+
const _vitest = require("vitest");
|
|
7
8
|
const _insertBlock = require("./insertBlock");
|
|
8
|
-
|
|
9
|
+
_vitest.vi.mock('../../../helpers/editor', async ()=>{
|
|
10
|
+
const actual = await _vitest.vi.importActual('../../../helpers/editor');
|
|
9
11
|
return {
|
|
10
12
|
__esModule: true,
|
|
11
|
-
...
|
|
12
|
-
focus:
|
|
13
|
+
...actual,
|
|
14
|
+
focus: _vitest.vi.fn()
|
|
13
15
|
};
|
|
14
16
|
});
|
|
15
|
-
describe('CommandPalette insertBlock', ()=>{
|
|
16
|
-
it('inserts an embedded entry block even when selection is in an empty paragraph', ()=>{
|
|
17
|
+
(0, _vitest.describe)('CommandPalette insertBlock', ()=>{
|
|
18
|
+
(0, _vitest.it)('inserts an embedded entry block even when selection is in an empty paragraph', ()=>{
|
|
17
19
|
const editor = (0, _platetestutils.createEditor)('test-editor', {}, [
|
|
18
20
|
{
|
|
19
21
|
type: _richtexttypes.BLOCKS.PARAGRAPH,
|
|
@@ -48,9 +50,9 @@ describe('CommandPalette insertBlock', ()=>{
|
|
|
48
50
|
type: 'Entry'
|
|
49
51
|
}
|
|
50
52
|
});
|
|
51
|
-
expect(editor.children.some((n)=>n.type === _richtexttypes.BLOCKS.EMBEDDED_ENTRY)).toBe(true);
|
|
53
|
+
(0, _vitest.expect)(editor.children.some((n)=>n.type === _richtexttypes.BLOCKS.EMBEDDED_ENTRY)).toBe(true);
|
|
52
54
|
});
|
|
53
|
-
it('does not remove existing paragraph text when inserting from a non-empty paragraph', ()=>{
|
|
55
|
+
(0, _vitest.it)('does not remove existing paragraph text when inserting from a non-empty paragraph', ()=>{
|
|
54
56
|
const editor = (0, _platetestutils.createEditor)('test-editor', {}, [
|
|
55
57
|
{
|
|
56
58
|
type: _richtexttypes.BLOCKS.PARAGRAPH,
|
|
@@ -91,7 +93,7 @@ describe('CommandPalette insertBlock', ()=>{
|
|
|
91
93
|
if (Array.isArray(node.children)) return node.children.some((c)=>containsText(c, text));
|
|
92
94
|
return false;
|
|
93
95
|
};
|
|
94
|
-
expect(editor.children.some((n)=>n.type === _richtexttypes.BLOCKS.EMBEDDED_ENTRY)).toBe(true);
|
|
95
|
-
expect(editor.children.some((n)=>containsText(n, 'hello'))).toBe(true);
|
|
96
|
+
(0, _vitest.expect)(editor.children.some((n)=>n.type === _richtexttypes.BLOCKS.EMBEDDED_ENTRY)).toBe(true);
|
|
97
|
+
(0, _vitest.expect)(editor.children.some((n)=>containsText(n, 'hello'))).toBe(true);
|
|
96
98
|
});
|
|
97
99
|
});
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
+
const _vitest = require("vitest");
|
|
5
6
|
const _testutils = require("../../../test-utils");
|
|
6
|
-
describe('normalization', ()=>{
|
|
7
|
-
it('can contain inline entries & hyperlinks', ()=>{
|
|
7
|
+
(0, _vitest.describe)('normalization', ()=>{
|
|
8
|
+
(0, _vitest.it)('can contain inline entries & hyperlinks', ()=>{
|
|
8
9
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hh1", null, "some text before", /*#__PURE__*/ (0, _testutils.jsx)("hinline", {
|
|
9
10
|
type: "Entry",
|
|
10
11
|
id: "inline-entry"
|
|
@@ -22,7 +23,7 @@ describe('normalization', ()=>{
|
|
|
22
23
|
expected: input
|
|
23
24
|
});
|
|
24
25
|
});
|
|
25
|
-
it('unwraps nested paragraphs', ()=>{
|
|
26
|
+
(0, _vitest.it)('unwraps nested paragraphs', ()=>{
|
|
26
27
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hh1", null, "one", ' ', /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "two ", /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "three ")), "four"));
|
|
27
28
|
const expected = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hh1", null, "one two three four"), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null)));
|
|
28
29
|
(0, _testutils.assertOutput)({
|
|
@@ -30,8 +31,8 @@ describe('normalization', ()=>{
|
|
|
30
31
|
expected
|
|
31
32
|
});
|
|
32
33
|
});
|
|
33
|
-
describe('lifts other invalid children', ()=>{
|
|
34
|
-
it('block void elements', ()=>{
|
|
34
|
+
(0, _vitest.describe)('lifts other invalid children', ()=>{
|
|
35
|
+
(0, _vitest.it)('block void elements', ()=>{
|
|
35
36
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hh1", null, /*#__PURE__*/ (0, _testutils.jsx)("hembed", {
|
|
36
37
|
type: "Asset",
|
|
37
38
|
id: "1"
|
|
@@ -75,7 +76,7 @@ describe('normalization', ()=>{
|
|
|
75
76
|
expected
|
|
76
77
|
});
|
|
77
78
|
});
|
|
78
|
-
it('nested headings', ()=>{
|
|
79
|
+
(0, _vitest.it)('nested headings', ()=>{
|
|
79
80
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hh1", null, "some", /*#__PURE__*/ (0, _testutils.jsx)("hh1", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", {
|
|
80
81
|
bold: true,
|
|
81
82
|
italic: true,
|
|
@@ -91,7 +92,7 @@ describe('normalization', ()=>{
|
|
|
91
92
|
expected
|
|
92
93
|
});
|
|
93
94
|
});
|
|
94
|
-
it('handles quotes', ()=>{
|
|
95
|
+
(0, _vitest.it)('handles quotes', ()=>{
|
|
95
96
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hh1", null, "some", /*#__PURE__*/ (0, _testutils.jsx)("hquote", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "quote")), "text"));
|
|
96
97
|
const expected = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hh1", null, "some"), /*#__PURE__*/ (0, _testutils.jsx)("hquote", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "quote")), /*#__PURE__*/ (0, _testutils.jsx)("hh1", null, "text"), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null)));
|
|
97
98
|
(0, _testutils.assertOutput)({
|
|
@@ -99,7 +100,7 @@ describe('normalization', ()=>{
|
|
|
99
100
|
expected
|
|
100
101
|
});
|
|
101
102
|
});
|
|
102
|
-
it('handles lists', ()=>{
|
|
103
|
+
(0, _vitest.it)('handles lists', ()=>{
|
|
103
104
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hh1", null, "some", /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "list item"))), "text"));
|
|
104
105
|
const expected = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hh1", null, "some"), /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "list item"))), /*#__PURE__*/ (0, _testutils.jsx)("hh1", null, "text"), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null)));
|
|
105
106
|
(0, _testutils.assertOutput)({
|
|
@@ -107,7 +108,7 @@ describe('normalization', ()=>{
|
|
|
107
108
|
expected
|
|
108
109
|
});
|
|
109
110
|
});
|
|
110
|
-
it('handles tables', ()=>{
|
|
111
|
+
(0, _vitest.it)('handles tables', ()=>{
|
|
111
112
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hh1", null, "some", /*#__PURE__*/ (0, _testutils.jsx)("htable", null, /*#__PURE__*/ (0, _testutils.jsx)("htr", null, /*#__PURE__*/ (0, _testutils.jsx)("htd", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "cell 1")), /*#__PURE__*/ (0, _testutils.jsx)("htd", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "cell 2")))), "text"));
|
|
112
113
|
const expected = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hh1", null, "some"), /*#__PURE__*/ (0, _testutils.jsx)("htable", null, /*#__PURE__*/ (0, _testutils.jsx)("htr", null, /*#__PURE__*/ (0, _testutils.jsx)("htd", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "cell 1")), /*#__PURE__*/ (0, _testutils.jsx)("htd", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "cell 2")))), /*#__PURE__*/ (0, _testutils.jsx)("hh1", null, "text"), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null)));
|
|
113
114
|
(0, _testutils.assertOutput)({
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
+
const _vitest = require("vitest");
|
|
5
6
|
const _testutils = require("../../../test-utils");
|
|
6
|
-
describe('normalization', ()=>{
|
|
7
|
-
it('removes empty links from the document structure', ()=>{
|
|
7
|
+
(0, _vitest.describe)('normalization', ()=>{
|
|
8
|
+
(0, _vitest.it)('removes empty links from the document structure', ()=>{
|
|
8
9
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null, "link"), /*#__PURE__*/ (0, _testutils.jsx)("hlink", {
|
|
9
10
|
uri: "https://link.com"
|
|
10
11
|
})), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null, "asset"), /*#__PURE__*/ (0, _testutils.jsx)("hlink", {
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
const _vitest = require("vitest");
|
|
6
|
+
(0, _vitest.describe)('HyperlinkModal recommendations.searchQuery feature', ()=>{
|
|
7
|
+
(0, _vitest.it)('should pass linkText as searchQuery to selectSingleEntry', ()=>{
|
|
8
|
+
const mockSelectSingleEntry = _vitest.vi.fn();
|
|
5
9
|
const linkText = 'example search text';
|
|
6
10
|
const expectedOptions = {
|
|
7
11
|
locale: 'en-US',
|
|
@@ -13,15 +17,15 @@ describe('HyperlinkModal recommendations.searchQuery feature', ()=>{
|
|
|
13
17
|
}
|
|
14
18
|
};
|
|
15
19
|
mockSelectSingleEntry(expectedOptions);
|
|
16
|
-
expect(mockSelectSingleEntry).toHaveBeenCalledWith(expectedOptions);
|
|
17
|
-
expect(mockSelectSingleEntry).toHaveBeenCalledWith(expect.objectContaining({
|
|
20
|
+
(0, _vitest.expect)(mockSelectSingleEntry).toHaveBeenCalledWith(expectedOptions);
|
|
21
|
+
(0, _vitest.expect)(mockSelectSingleEntry).toHaveBeenCalledWith(_vitest.expect.objectContaining({
|
|
18
22
|
recommendations: {
|
|
19
23
|
searchQuery: linkText
|
|
20
24
|
}
|
|
21
25
|
}));
|
|
22
26
|
});
|
|
23
|
-
it('should update searchQuery when linkText changes', ()=>{
|
|
24
|
-
const mockSelectSingleEntry =
|
|
27
|
+
(0, _vitest.it)('should update searchQuery when linkText changes', ()=>{
|
|
28
|
+
const mockSelectSingleEntry = _vitest.vi.fn();
|
|
25
29
|
const modifiedText = 'modified text';
|
|
26
30
|
const expectedOptions = {
|
|
27
31
|
locale: 'en-US',
|
|
@@ -33,14 +37,14 @@ describe('HyperlinkModal recommendations.searchQuery feature', ()=>{
|
|
|
33
37
|
}
|
|
34
38
|
};
|
|
35
39
|
mockSelectSingleEntry(expectedOptions);
|
|
36
|
-
expect(mockSelectSingleEntry).toHaveBeenCalledWith(expect.objectContaining({
|
|
40
|
+
(0, _vitest.expect)(mockSelectSingleEntry).toHaveBeenCalledWith(_vitest.expect.objectContaining({
|
|
37
41
|
recommendations: {
|
|
38
42
|
searchQuery: modifiedText
|
|
39
43
|
}
|
|
40
44
|
}));
|
|
41
45
|
});
|
|
42
|
-
it('should handle empty linkText', ()=>{
|
|
43
|
-
const mockSelectSingleEntry =
|
|
46
|
+
(0, _vitest.it)('should handle empty linkText', ()=>{
|
|
47
|
+
const mockSelectSingleEntry = _vitest.vi.fn();
|
|
44
48
|
const expectedOptions = {
|
|
45
49
|
locale: 'en-US',
|
|
46
50
|
contentTypes: [
|
|
@@ -51,7 +55,7 @@ describe('HyperlinkModal recommendations.searchQuery feature', ()=>{
|
|
|
51
55
|
}
|
|
52
56
|
};
|
|
53
57
|
mockSelectSingleEntry(expectedOptions);
|
|
54
|
-
expect(mockSelectSingleEntry).toHaveBeenCalledWith(expect.objectContaining({
|
|
58
|
+
(0, _vitest.expect)(mockSelectSingleEntry).toHaveBeenCalledWith(_vitest.expect.objectContaining({
|
|
55
59
|
recommendations: {
|
|
56
60
|
searchQuery: ''
|
|
57
61
|
}
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
+
const _vitest = require("vitest");
|
|
5
6
|
const _testutils = require("../../../test-utils");
|
|
6
|
-
describe('normalization', ()=>{
|
|
7
|
-
it('wraps orphaned list items in a list', ()=>{
|
|
7
|
+
(0, _vitest.describe)('normalization', ()=>{
|
|
8
|
+
(0, _vitest.it)('wraps orphaned list items in a list', ()=>{
|
|
8
9
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "Item")), /*#__PURE__*/ (0, _testutils.jsx)("hp", null));
|
|
9
10
|
const expected = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "Item"))), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null)));
|
|
10
11
|
(0, _testutils.assertOutput)({
|
|
@@ -12,7 +13,7 @@ describe('normalization', ()=>{
|
|
|
12
13
|
expected
|
|
13
14
|
});
|
|
14
15
|
});
|
|
15
|
-
it('adds empty paragraph to empty list items', ()=>{
|
|
16
|
+
(0, _vitest.it)('adds empty paragraph to empty list items', ()=>{
|
|
16
17
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null)), /*#__PURE__*/ (0, _testutils.jsx)("hp", null));
|
|
17
18
|
const expected = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null)))), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null)));
|
|
18
19
|
(0, _testutils.assertOutput)({
|
|
@@ -20,7 +21,7 @@ describe('normalization', ()=>{
|
|
|
20
21
|
expected
|
|
21
22
|
});
|
|
22
23
|
});
|
|
23
|
-
it('replaces invalid list items with text', ()=>{
|
|
24
|
+
(0, _vitest.it)('replaces invalid list items with text', ()=>{
|
|
24
25
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "Item"), /*#__PURE__*/ (0, _testutils.jsx)("htd", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", {
|
|
25
26
|
bold: true
|
|
26
27
|
}, "bold text"))), /*#__PURE__*/ (0, _testutils.jsx)("htd", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "Take a look at this ", /*#__PURE__*/ (0, _testutils.jsx)("hlink", {
|
|
@@ -36,7 +37,7 @@ describe('normalization', ()=>{
|
|
|
36
37
|
expected
|
|
37
38
|
});
|
|
38
39
|
});
|
|
39
|
-
it('replaces list items with nested lists as a first child', ()=>{
|
|
40
|
+
(0, _vitest.it)('replaces list items with nested lists as a first child', ()=>{
|
|
40
41
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "Item 1"), /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "Item 1.1")))), /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "Item 2.1"), /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "Item 2.1.1")))), /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "Item 2.2"))))), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null)));
|
|
41
42
|
const expected = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "Item 1"), /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "Item 1.1")))), /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "Item 2.1"), /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "Item 2.1.1")))), /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "Item 2.2"))), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null)));
|
|
42
43
|
(0, _testutils.assertOutput)({
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
+
const _vitest = require("vitest");
|
|
5
6
|
const _testutils = require("../../../test-utils");
|
|
6
|
-
describe('insert line break', ()=>{
|
|
7
|
+
(0, _vitest.describe)('insert line break', ()=>{
|
|
7
8
|
const tests = [
|
|
8
9
|
{
|
|
9
10
|
title: 'at the start of a li',
|
|
@@ -63,7 +64,7 @@ describe('insert line break', ()=>{
|
|
|
63
64
|
];
|
|
64
65
|
const render = (children)=>/*#__PURE__*/ (0, _testutils.jsx)("editor", null, children, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null)));
|
|
65
66
|
for (const t of tests){
|
|
66
|
-
test(t.title, ()=>{
|
|
67
|
+
(0, _vitest.test)(t.title, ()=>{
|
|
67
68
|
const { editor } = (0, _testutils.createTestEditor)({
|
|
68
69
|
input: render(t.input)
|
|
69
70
|
});
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
+
const _vitest = require("vitest");
|
|
5
6
|
const _testutils = require("../../../test-utils");
|
|
6
|
-
describe('insert fragment', ()=>{
|
|
7
|
+
(0, _vitest.describe)('insert fragment', ()=>{
|
|
7
8
|
const tests = [
|
|
8
9
|
{
|
|
9
10
|
title: 'text wrapped in li > p',
|
|
@@ -50,7 +51,7 @@ describe('insert fragment', ()=>{
|
|
|
50
51
|
];
|
|
51
52
|
const render = (children)=>/*#__PURE__*/ (0, _testutils.jsx)("editor", null, children, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null)));
|
|
52
53
|
for (const t of tests){
|
|
53
|
-
test(t.title, ()=>{
|
|
54
|
+
(0, _vitest.test)(t.title, ()=>{
|
|
54
55
|
const { editor } = (0, _testutils.createTestEditor)({
|
|
55
56
|
input: render(t.input)
|
|
56
57
|
});
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
+
const _vitest = require("vitest");
|
|
5
6
|
const _testutils = require("../../../test-utils");
|
|
6
7
|
const _moveListItems = require("./moveListItems");
|
|
7
|
-
describe('moving list items (up/down)', ()=>{
|
|
8
|
+
(0, _vitest.describe)('moving list items (up/down)', ()=>{
|
|
8
9
|
const renderEditor = (children)=>/*#__PURE__*/ (0, _testutils.jsx)("editor", null, children, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null)));
|
|
9
10
|
const assertTab = (t, shift = false)=>{
|
|
10
|
-
test(t.title, ()=>{
|
|
11
|
+
(0, _vitest.test)(t.title, ()=>{
|
|
11
12
|
const { editor } = (0, _testutils.createTestEditor)({
|
|
12
13
|
input: renderEditor(t.input)
|
|
13
14
|
});
|
|
@@ -59,10 +60,10 @@ describe('moving list items (up/down)', ()=>{
|
|
|
59
60
|
})))
|
|
60
61
|
}
|
|
61
62
|
];
|
|
62
|
-
describe('move down (aka. tab)', ()=>{
|
|
63
|
+
(0, _vitest.describe)('move down (aka. tab)', ()=>{
|
|
63
64
|
tests.forEach((t)=>assertTab(t));
|
|
64
65
|
});
|
|
65
|
-
describe('move up (aka. shift+tab)', ()=>{
|
|
66
|
+
(0, _vitest.describe)('move up (aka. shift+tab)', ()=>{
|
|
66
67
|
tests.map((t)=>({
|
|
67
68
|
...t,
|
|
68
69
|
input: t.expected,
|
|
@@ -3,10 +3,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
const _richtexttypes = require("@contentful/rich-text-types");
|
|
6
|
+
const _vitest = require("vitest");
|
|
6
7
|
const _testutils = require("../../../test-utils");
|
|
7
8
|
const _toggleList = require("./toggleList");
|
|
8
|
-
describe('toggle on', ()=>{
|
|
9
|
-
it('should turn a p to list', ()=>{
|
|
9
|
+
(0, _vitest.describe)('toggle on', ()=>{
|
|
10
|
+
(0, _vitest.it)('should turn a p to list', ()=>{
|
|
10
11
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "1", /*#__PURE__*/ (0, _testutils.jsx)("cursor", null)));
|
|
11
12
|
const expected = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "1", /*#__PURE__*/ (0, _testutils.jsx)("cursor", null)))), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null)));
|
|
12
13
|
const { editor } = (0, _testutils.createTestEditor)({
|
|
@@ -20,7 +21,7 @@ describe('toggle on', ()=>{
|
|
|
20
21
|
expected
|
|
21
22
|
});
|
|
22
23
|
});
|
|
23
|
-
it('should turn a p with a selection to list', ()=>{
|
|
24
|
+
(0, _vitest.it)('should turn a p with a selection to list', ()=>{
|
|
24
25
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "Planetas ", /*#__PURE__*/ (0, _testutils.jsx)("anchor", null), "mori in", /*#__PURE__*/ (0, _testutils.jsx)("focus", null), " gandavum!"));
|
|
25
26
|
const expected = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "Planetas ", /*#__PURE__*/ (0, _testutils.jsx)("anchor", null), "mori in", /*#__PURE__*/ (0, _testutils.jsx)("focus", null), " gandavum!"))), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null)));
|
|
26
27
|
const { editor } = (0, _testutils.createTestEditor)({
|
|
@@ -34,7 +35,7 @@ describe('toggle on', ()=>{
|
|
|
34
35
|
expected
|
|
35
36
|
});
|
|
36
37
|
});
|
|
37
|
-
it('should turn multiple p to list', ()=>{
|
|
38
|
+
(0, _vitest.it)('should turn multiple p to list', ()=>{
|
|
38
39
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("anchor", null), "1"), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "2"), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "3", /*#__PURE__*/ (0, _testutils.jsx)("focus", null)));
|
|
39
40
|
const expected = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("anchor", null), "1")), /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "2")), /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "3", /*#__PURE__*/ (0, _testutils.jsx)("focus", null)))), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null)));
|
|
40
41
|
const { editor } = (0, _testutils.createTestEditor)({
|
|
@@ -49,8 +50,8 @@ describe('toggle on', ()=>{
|
|
|
49
50
|
});
|
|
50
51
|
});
|
|
51
52
|
});
|
|
52
|
-
describe('toggle off', ()=>{
|
|
53
|
-
it('should split a simple list to two', ()=>{
|
|
53
|
+
(0, _vitest.describe)('toggle off', ()=>{
|
|
54
|
+
(0, _vitest.it)('should split a simple list to two', ()=>{
|
|
54
55
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "1")), /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "2", /*#__PURE__*/ (0, _testutils.jsx)("cursor", null))), /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "3"))));
|
|
55
56
|
const expected = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "1"))), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "2", /*#__PURE__*/ (0, _testutils.jsx)("cursor", null)), /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "3"))), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null)));
|
|
56
57
|
const { editor } = (0, _testutils.createTestEditor)({
|
|
@@ -64,7 +65,7 @@ describe('toggle off', ()=>{
|
|
|
64
65
|
expected
|
|
65
66
|
});
|
|
66
67
|
});
|
|
67
|
-
it('should split a nested list', ()=>{
|
|
68
|
+
(0, _vitest.it)('should split a nested list', ()=>{
|
|
68
69
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "1"), /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "11")), /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "12", /*#__PURE__*/ (0, _testutils.jsx)("cursor", null))), /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "13"))))));
|
|
69
70
|
const expected = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "1"), /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "11"))))), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "12", /*#__PURE__*/ (0, _testutils.jsx)("cursor", null)), /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "13"))), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null)));
|
|
70
71
|
const { editor } = (0, _testutils.createTestEditor)({
|
|
@@ -78,7 +79,7 @@ describe('toggle off', ()=>{
|
|
|
78
79
|
expected
|
|
79
80
|
});
|
|
80
81
|
});
|
|
81
|
-
it('should turn a list to multiple p', ()=>{
|
|
82
|
+
(0, _vitest.it)('should turn a list to multiple p', ()=>{
|
|
82
83
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("anchor", null), "1")), /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "2")), /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "3", /*#__PURE__*/ (0, _testutils.jsx)("focus", null)))));
|
|
83
84
|
const expected = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("anchor", null), "1"), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "2"), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "3", /*#__PURE__*/ (0, _testutils.jsx)("focus", null)));
|
|
84
85
|
const { editor } = (0, _testutils.createTestEditor)({
|
|
@@ -93,8 +94,8 @@ describe('toggle off', ()=>{
|
|
|
93
94
|
});
|
|
94
95
|
});
|
|
95
96
|
});
|
|
96
|
-
describe('toggle over', ()=>{
|
|
97
|
-
it('should toggle different list types', ()=>{
|
|
97
|
+
(0, _vitest.describe)('toggle over', ()=>{
|
|
98
|
+
(0, _vitest.it)('should toggle different list types', ()=>{
|
|
98
99
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "1", /*#__PURE__*/ (0, _testutils.jsx)("cursor", null)))));
|
|
99
100
|
const expected = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hol", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "1"))), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null)));
|
|
100
101
|
const { editor } = (0, _testutils.createTestEditor)({
|
|
@@ -108,7 +109,7 @@ describe('toggle over', ()=>{
|
|
|
108
109
|
expected
|
|
109
110
|
});
|
|
110
111
|
});
|
|
111
|
-
it('should only toggle the nested list', ()=>{
|
|
112
|
+
(0, _vitest.it)('should only toggle the nested list', ()=>{
|
|
112
113
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "1"), /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "11", /*#__PURE__*/ (0, _testutils.jsx)("cursor", null)))))));
|
|
113
114
|
const expected = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "1"), /*#__PURE__*/ (0, _testutils.jsx)("hol", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "11", /*#__PURE__*/ (0, _testutils.jsx)("cursor", null)))))), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null)));
|
|
114
115
|
const { editor } = (0, _testutils.createTestEditor)({
|
|
@@ -122,7 +123,7 @@ describe('toggle over', ()=>{
|
|
|
122
123
|
expected
|
|
123
124
|
});
|
|
124
125
|
});
|
|
125
|
-
it('should only toggle everything that is selected', ()=>{
|
|
126
|
+
(0, _vitest.it)('should only toggle everything that is selected', ()=>{
|
|
126
127
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("anchor", null), "1"), /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "11", /*#__PURE__*/ (0, _testutils.jsx)("focus", null)))))));
|
|
127
128
|
const expected = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hol", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("anchor", null), "1"), /*#__PURE__*/ (0, _testutils.jsx)("hol", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "11", /*#__PURE__*/ (0, _testutils.jsx)("focus", null)))))), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null)));
|
|
128
129
|
const { editor } = (0, _testutils.createTestEditor)({
|
|
@@ -3,10 +3,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
const _richtexttypes = require("@contentful/rich-text-types");
|
|
6
|
+
const _vitest = require("vitest");
|
|
6
7
|
const _transformers = require("../../helpers/transformers");
|
|
7
8
|
const _testutils = require("../../test-utils");
|
|
8
9
|
const _createNormalizerPlugin = require("./createNormalizerPlugin");
|
|
9
|
-
describe('Normalizer', ()=>{
|
|
10
|
+
(0, _vitest.describe)('Normalizer', ()=>{
|
|
10
11
|
const rules = [
|
|
11
12
|
{
|
|
12
13
|
validChildren: [
|
|
@@ -15,15 +16,15 @@ describe('Normalizer', ()=>{
|
|
|
15
16
|
}
|
|
16
17
|
];
|
|
17
18
|
let input;
|
|
18
|
-
beforeEach(()=>{
|
|
19
|
+
(0, _vitest.beforeEach)(()=>{
|
|
19
20
|
input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hembed", {
|
|
20
21
|
type: "Entry",
|
|
21
22
|
id: "embedded-entry"
|
|
22
23
|
}), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "List item"))));
|
|
23
24
|
});
|
|
24
25
|
const expected = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "List item"))));
|
|
25
|
-
describe('rule.match', ()=>{
|
|
26
|
-
it('matches elements of type "plugin.type" by default', ()=>{
|
|
26
|
+
(0, _vitest.describe)('rule.match', ()=>{
|
|
27
|
+
(0, _vitest.it)('matches elements of type "plugin.type" by default', ()=>{
|
|
27
28
|
const { editor } = (0, _testutils.createTestEditor)({
|
|
28
29
|
input,
|
|
29
30
|
plugins: [
|
|
@@ -40,8 +41,8 @@ describe('Normalizer', ()=>{
|
|
|
40
41
|
expected
|
|
41
42
|
});
|
|
42
43
|
});
|
|
43
|
-
it('rejects rules without "match" in a non-element plugin', ()=>{
|
|
44
|
-
expect(()=>(0, _testutils.createTestEditor)({
|
|
44
|
+
(0, _vitest.it)('rejects rules without "match" in a non-element plugin', ()=>{
|
|
45
|
+
(0, _vitest.expect)(()=>(0, _testutils.createTestEditor)({
|
|
45
46
|
input,
|
|
46
47
|
plugins: [
|
|
47
48
|
(0, _testutils.mockPlugin)({
|
|
@@ -52,8 +53,8 @@ describe('Normalizer', ()=>{
|
|
|
52
53
|
})).toThrow(/rule.match MUST be defined/);
|
|
53
54
|
});
|
|
54
55
|
});
|
|
55
|
-
describe('rule.transform', ()=>{
|
|
56
|
-
it('works with conditional transformation', ()=>{
|
|
56
|
+
(0, _vitest.describe)('rule.transform', ()=>{
|
|
57
|
+
(0, _vitest.it)('works with conditional transformation', ()=>{
|
|
57
58
|
const { editor } = (0, _testutils.createTestEditor)({
|
|
58
59
|
input: /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hembed", {
|
|
59
60
|
type: "Entry",
|
|
@@ -89,8 +90,8 @@ describe('Normalizer', ()=>{
|
|
|
89
90
|
});
|
|
90
91
|
});
|
|
91
92
|
});
|
|
92
|
-
describe('rule.validChildren', ()=>{
|
|
93
|
-
it('supports custom functions', ()=>{
|
|
93
|
+
(0, _vitest.describe)('rule.validChildren', ()=>{
|
|
94
|
+
(0, _vitest.it)('supports custom functions', ()=>{
|
|
94
95
|
const { editor } = (0, _testutils.createTestEditor)({
|
|
95
96
|
input,
|
|
96
97
|
plugins: [
|