@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
|
@@ -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)("hp", 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('wraps orphaned text nodes in a paragraph', ()=>{
|
|
26
|
+
(0, _vitest.it)('wraps orphaned text nodes in a paragraph', ()=>{
|
|
26
27
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "valid text"), /*#__PURE__*/ (0, _testutils.jsx)("hh1", null, "valid text"), /*#__PURE__*/ (0, _testutils.jsx)("htable", null, /*#__PURE__*/ (0, _testutils.jsx)("htr", null, /*#__PURE__*/ (0, _testutils.jsx)("htd", null, "invalid text"))));
|
|
27
28
|
const expected = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "valid text"), /*#__PURE__*/ (0, _testutils.jsx)("hh1", null, "valid text"), /*#__PURE__*/ (0, _testutils.jsx)("htable", null, /*#__PURE__*/ (0, _testutils.jsx)("htr", null, /*#__PURE__*/ (0, _testutils.jsx)("htd", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "invalid text")))), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null)));
|
|
28
29
|
(0, _testutils.assertOutput)({
|
|
@@ -30,7 +31,7 @@ describe('normalization', ()=>{
|
|
|
30
31
|
expected
|
|
31
32
|
});
|
|
32
33
|
});
|
|
33
|
-
it('unwraps nested paragraphs', ()=>{
|
|
34
|
+
(0, _vitest.it)('unwraps nested paragraphs', ()=>{
|
|
34
35
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "some", /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", {
|
|
35
36
|
bold: true,
|
|
36
37
|
italic: true,
|
|
@@ -46,8 +47,8 @@ describe('normalization', ()=>{
|
|
|
46
47
|
expected
|
|
47
48
|
});
|
|
48
49
|
});
|
|
49
|
-
describe('lifts other invalid children', ()=>{
|
|
50
|
-
it('block void elements', ()=>{
|
|
50
|
+
(0, _vitest.describe)('lifts other invalid children', ()=>{
|
|
51
|
+
(0, _vitest.it)('block void elements', ()=>{
|
|
51
52
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("hembed", {
|
|
52
53
|
type: "Asset",
|
|
53
54
|
id: "1"
|
|
@@ -91,7 +92,7 @@ describe('normalization', ()=>{
|
|
|
91
92
|
expected
|
|
92
93
|
});
|
|
93
94
|
});
|
|
94
|
-
it('handles heading', ()=>{
|
|
95
|
+
(0, _vitest.it)('handles heading', ()=>{
|
|
95
96
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "some", /*#__PURE__*/ (0, _testutils.jsx)("hh1", null, "heading"), "text"));
|
|
96
97
|
const expected = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "some"), /*#__PURE__*/ (0, _testutils.jsx)("hh1", null, "heading"), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "text"));
|
|
97
98
|
(0, _testutils.assertOutput)({
|
|
@@ -99,7 +100,7 @@ describe('normalization', ()=>{
|
|
|
99
100
|
expected
|
|
100
101
|
});
|
|
101
102
|
});
|
|
102
|
-
it('handles quotes', ()=>{
|
|
103
|
+
(0, _vitest.it)('handles quotes', ()=>{
|
|
103
104
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "some", /*#__PURE__*/ (0, _testutils.jsx)("hquote", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "quote")), "text"));
|
|
104
105
|
const expected = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "some"), /*#__PURE__*/ (0, _testutils.jsx)("hquote", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "quote")), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "text"));
|
|
105
106
|
(0, _testutils.assertOutput)({
|
|
@@ -107,7 +108,7 @@ describe('normalization', ()=>{
|
|
|
107
108
|
expected
|
|
108
109
|
});
|
|
109
110
|
});
|
|
110
|
-
it('handles lists', ()=>{
|
|
111
|
+
(0, _vitest.it)('handles lists', ()=>{
|
|
111
112
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "some", /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "list item"))), "text"));
|
|
112
113
|
const expected = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", 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)("hp", null, "text"));
|
|
113
114
|
(0, _testutils.assertOutput)({
|
|
@@ -115,7 +116,7 @@ describe('normalization', ()=>{
|
|
|
115
116
|
expected
|
|
116
117
|
});
|
|
117
118
|
});
|
|
118
|
-
it('handles tables', ()=>{
|
|
119
|
+
(0, _vitest.it)('handles tables', ()=>{
|
|
119
120
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", 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"));
|
|
120
121
|
const expected = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", 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)("hp", null, "text"));
|
|
121
122
|
(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 _sanitizeHTML = require("../sanitizeHTML");
|
|
6
|
-
describe('HTML Sanitization', ()=>{
|
|
7
|
-
it('removes unsupported elements from <a>', ()=>{
|
|
7
|
+
(0, _vitest.describe)('HTML Sanitization', ()=>{
|
|
8
|
+
(0, _vitest.it)('removes unsupported elements from <a>', ()=>{
|
|
8
9
|
const cases = [
|
|
9
10
|
{
|
|
10
11
|
input: '<h1><a href="#">Link in h1</a></h1>',
|
|
@@ -48,7 +49,7 @@ describe('HTML Sanitization', ()=>{
|
|
|
48
49
|
}
|
|
49
50
|
];
|
|
50
51
|
cases.forEach((case_)=>{
|
|
51
|
-
expect((0, _sanitizeHTML.sanitizeHTML)(case_.input)).toBe(case_.output === 'unchanged' ? case_.input : case_.output);
|
|
52
|
+
(0, _vitest.expect)((0, _sanitizeHTML.sanitizeHTML)(case_.input)).toBe(case_.output === 'unchanged' ? case_.input : case_.output);
|
|
52
53
|
});
|
|
53
54
|
});
|
|
54
55
|
});
|
|
@@ -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)("hquote", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", 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 quotes', ()=>{
|
|
26
|
+
(0, _vitest.it)('unwraps nested quotes', ()=>{
|
|
26
27
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hquote", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "some"), /*#__PURE__*/ (0, _testutils.jsx)("hquote", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", {
|
|
27
28
|
bold: true,
|
|
28
29
|
italic: true,
|
|
@@ -38,8 +39,8 @@ describe('normalization', ()=>{
|
|
|
38
39
|
expected
|
|
39
40
|
});
|
|
40
41
|
});
|
|
41
|
-
describe('lifts other invalid children', ()=>{
|
|
42
|
-
it('block void elements', ()=>{
|
|
42
|
+
(0, _vitest.describe)('lifts other invalid children', ()=>{
|
|
43
|
+
(0, _vitest.it)('block void elements', ()=>{
|
|
43
44
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hquote", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "this"), /*#__PURE__*/ (0, _testutils.jsx)("hembed", {
|
|
44
45
|
type: "Asset",
|
|
45
46
|
id: "1"
|
|
@@ -59,7 +60,7 @@ describe('normalization', ()=>{
|
|
|
59
60
|
expected
|
|
60
61
|
});
|
|
61
62
|
});
|
|
62
|
-
it('handles lists', ()=>{
|
|
63
|
+
(0, _vitest.it)('handles lists', ()=>{
|
|
63
64
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hquote", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "some", /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "list item"))), "text")));
|
|
64
65
|
const expected = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hquote", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", 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)("hquote", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "text")), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("text", null)));
|
|
65
66
|
(0, _testutils.assertOutput)({
|
|
@@ -67,7 +68,7 @@ describe('normalization', ()=>{
|
|
|
67
68
|
expected
|
|
68
69
|
});
|
|
69
70
|
});
|
|
70
|
-
it('handles tables', ()=>{
|
|
71
|
+
(0, _vitest.it)('handles tables', ()=>{
|
|
71
72
|
const table = /*#__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"))));
|
|
72
73
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hquote", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "some", table, "text")));
|
|
73
74
|
const expected = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hquote", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "some")), table, /*#__PURE__*/ (0, _testutils.jsx)("hquote", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "text")), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("text", null)));
|
|
@@ -2,10 +2,11 @@
|
|
|
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
|
-
describe('Table', ()=>{
|
|
8
|
-
it('removes empty table nodes', ()=>{
|
|
7
|
+
(0, _vitest.describe)('normalization', ()=>{
|
|
8
|
+
(0, _vitest.describe)('Table', ()=>{
|
|
9
|
+
(0, _vitest.it)('removes empty table nodes', ()=>{
|
|
9
10
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("htable", null));
|
|
10
11
|
const expected = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("text", null)));
|
|
11
12
|
(0, _testutils.assertOutput)({
|
|
@@ -13,7 +14,7 @@ describe('normalization', ()=>{
|
|
|
13
14
|
expected
|
|
14
15
|
});
|
|
15
16
|
});
|
|
16
|
-
it('moves tables to the root level except nested tables', ()=>{
|
|
17
|
+
(0, _vitest.it)('moves tables to the root level except nested tables', ()=>{
|
|
17
18
|
const table = /*#__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"))));
|
|
18
19
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "hello", table), /*#__PURE__*/ (0, _testutils.jsx)("hquote", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "quote", table)), /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "item", table))), /*#__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 with table: ", table)))));
|
|
19
20
|
const expected = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "hello"), table, /*#__PURE__*/ (0, _testutils.jsx)("hquote", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "quote")), table, /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "item"))), table, /*#__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 with table: "), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "Cell 1"), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "Cell 2")))), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null)));
|
|
@@ -22,7 +23,7 @@ describe('normalization', ()=>{
|
|
|
22
23
|
expected
|
|
23
24
|
});
|
|
24
25
|
});
|
|
25
|
-
it('removes invalid children', ()=>{
|
|
26
|
+
(0, _vitest.it)('removes invalid children', ()=>{
|
|
26
27
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__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)("htd", null, "invalid cell"), "invalid text"), /*#__PURE__*/ (0, _testutils.jsx)("hp", null));
|
|
27
28
|
const expected = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__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)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null)));
|
|
28
29
|
(0, _testutils.assertOutput)({
|
|
@@ -31,8 +32,8 @@ describe('normalization', ()=>{
|
|
|
31
32
|
});
|
|
32
33
|
});
|
|
33
34
|
});
|
|
34
|
-
describe('Table cell', ()=>{
|
|
35
|
-
it('converts invalid children to paragraphs', ()=>{
|
|
35
|
+
(0, _vitest.describe)('Table cell', ()=>{
|
|
36
|
+
(0, _vitest.it)('converts invalid children to paragraphs', ()=>{
|
|
36
37
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__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)("hquote", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", {
|
|
37
38
|
bold: true,
|
|
38
39
|
italic: true,
|
|
@@ -55,8 +56,8 @@ describe('normalization', ()=>{
|
|
|
55
56
|
});
|
|
56
57
|
});
|
|
57
58
|
});
|
|
58
|
-
describe('Table row', ()=>{
|
|
59
|
-
it('must be wrapped in a table', ()=>{
|
|
59
|
+
(0, _vitest.describe)('Table row', ()=>{
|
|
60
|
+
(0, _vitest.it)('must be wrapped in a table', ()=>{
|
|
60
61
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("htr", null, /*#__PURE__*/ (0, _testutils.jsx)("htd", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "cell"))));
|
|
61
62
|
const expected = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__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")))), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("text", null)));
|
|
62
63
|
(0, _testutils.assertOutput)({
|
|
@@ -64,7 +65,7 @@ describe('normalization', ()=>{
|
|
|
64
65
|
expected
|
|
65
66
|
});
|
|
66
67
|
});
|
|
67
|
-
it('removes empty rows', ()=>{
|
|
68
|
+
(0, _vitest.it)('removes empty rows', ()=>{
|
|
68
69
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("htr", null));
|
|
69
70
|
const expected = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("text", null)));
|
|
70
71
|
(0, _testutils.assertOutput)({
|
|
@@ -72,7 +73,7 @@ describe('normalization', ()=>{
|
|
|
72
73
|
expected
|
|
73
74
|
});
|
|
74
75
|
});
|
|
75
|
-
it('wraps invalid children in table cells', ()=>{
|
|
76
|
+
(0, _vitest.it)('wraps invalid children in table cells', ()=>{
|
|
76
77
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__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)("hp", null, "cell 2"))));
|
|
77
78
|
const expected = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__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)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("text", null)));
|
|
78
79
|
(0, _testutils.assertOutput)({
|
|
@@ -80,7 +81,7 @@ describe('normalization', ()=>{
|
|
|
80
81
|
expected
|
|
81
82
|
});
|
|
82
83
|
});
|
|
83
|
-
it('ensures all table rows have the same width', ()=>{
|
|
84
|
+
(0, _vitest.it)('ensures all table rows have the same width', ()=>{
|
|
84
85
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__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)("htr", null, /*#__PURE__*/ (0, _testutils.jsx)("htd", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "cell 2")), /*#__PURE__*/ (0, _testutils.jsx)("htd", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "cell 3")), /*#__PURE__*/ (0, _testutils.jsx)("htd", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "cell 4"))), /*#__PURE__*/ (0, _testutils.jsx)("htr", null, /*#__PURE__*/ (0, _testutils.jsx)("htd", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "cell 5")), /*#__PURE__*/ (0, _testutils.jsx)("htd", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "cell 6")))));
|
|
85
86
|
const expected = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__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, /*#__PURE__*/ (0, _testutils.jsx)("text", null))), /*#__PURE__*/ (0, _testutils.jsx)("htd", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("text", null)))), /*#__PURE__*/ (0, _testutils.jsx)("htr", null, /*#__PURE__*/ (0, _testutils.jsx)("htd", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "cell 2")), /*#__PURE__*/ (0, _testutils.jsx)("htd", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "cell 3")), /*#__PURE__*/ (0, _testutils.jsx)("htd", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "cell 4"))), /*#__PURE__*/ (0, _testutils.jsx)("htr", null, /*#__PURE__*/ (0, _testutils.jsx)("htd", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "cell 5")), /*#__PURE__*/ (0, _testutils.jsx)("htd", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "cell 6")), /*#__PURE__*/ (0, _testutils.jsx)("htd", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("text", null))))), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("text", null)));
|
|
86
87
|
(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
7
|
const _helpers = require("../helpers");
|
|
7
|
-
test('insertTableAndFocusFirstCell', ()=>{
|
|
8
|
+
(0, _vitest.test)('insertTableAndFocusFirstCell', ()=>{
|
|
8
9
|
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null), /*#__PURE__*/ (0, _testutils.jsx)("cursor", null)), /*#__PURE__*/ (0, _testutils.jsx)("hp", null));
|
|
9
10
|
const { editor } = (0, _testutils.createTestEditor)({
|
|
10
11
|
input
|
|
@@ -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('delete backward', ()=>{
|
|
7
|
+
(0, _vitest.describe)('delete backward', ()=>{
|
|
7
8
|
const tests = [
|
|
8
9
|
{
|
|
9
10
|
title: 'deletes a character of the text inside li',
|
|
@@ -18,7 +19,7 @@ describe('delete backward', ()=>{
|
|
|
18
19
|
];
|
|
19
20
|
const render = (children)=>/*#__PURE__*/ (0, _testutils.jsx)("editor", null, children, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null)));
|
|
20
21
|
for (const t of tests){
|
|
21
|
-
test(t.title, ()=>{
|
|
22
|
+
(0, _vitest.test)(t.title, ()=>{
|
|
22
23
|
const { editor } = (0, _testutils.createTestEditor)({
|
|
23
24
|
input: render(t.input)
|
|
24
25
|
});
|
|
@@ -30,7 +31,7 @@ describe('delete backward', ()=>{
|
|
|
30
31
|
});
|
|
31
32
|
}
|
|
32
33
|
});
|
|
33
|
-
describe('delete forward', ()=>{
|
|
34
|
+
(0, _vitest.describe)('delete forward', ()=>{
|
|
34
35
|
const tests = [
|
|
35
36
|
{
|
|
36
37
|
title: 'deletes a character of the text inside li',
|
|
@@ -55,7 +56,7 @@ describe('delete forward', ()=>{
|
|
|
55
56
|
];
|
|
56
57
|
const render = (children)=>/*#__PURE__*/ (0, _testutils.jsx)("editor", null, children, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null)));
|
|
57
58
|
for (const t of tests){
|
|
58
|
-
test(t.title, ()=>{
|
|
59
|
+
(0, _vitest.test)(t.title, ()=>{
|
|
59
60
|
const { editor } = (0, _testutils.createTestEditor)({
|
|
60
61
|
input: render(t.input)
|
|
61
62
|
});
|
|
@@ -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 _EmbeddedBlockUtil = require("../EmbeddedBlockUtil");
|
|
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('EmbeddedBlockUtil selectEntityAndInsert', ()=>{
|
|
16
|
-
it('inserts an embedded entry block for newly created entries from an empty paragraph', async ()=>{
|
|
17
|
+
(0, _vitest.describe)('EmbeddedBlockUtil selectEntityAndInsert', ()=>{
|
|
18
|
+
(0, _vitest.it)('inserts an embedded entry block for newly created entries from an empty paragraph', async ()=>{
|
|
17
19
|
const editor = (0, _platetestutils.createEditor)('test-editor', {}, [
|
|
18
20
|
{
|
|
19
21
|
type: _richtexttypes.BLOCKS.PARAGRAPH,
|
|
@@ -48,7 +50,7 @@ describe('EmbeddedBlockUtil selectEntityAndInsert', ()=>{
|
|
|
48
50
|
validations: []
|
|
49
51
|
},
|
|
50
52
|
dialogs: {
|
|
51
|
-
selectSingleEntry:
|
|
53
|
+
selectSingleEntry: _vitest.vi.fn(async ()=>({
|
|
52
54
|
sys: {
|
|
53
55
|
id: 'entry-1',
|
|
54
56
|
type: 'Entry'
|
|
@@ -56,14 +58,14 @@ describe('EmbeddedBlockUtil selectEntityAndInsert', ()=>{
|
|
|
56
58
|
}))
|
|
57
59
|
},
|
|
58
60
|
navigator: {
|
|
59
|
-
onSlideInNavigation:
|
|
61
|
+
onSlideInNavigation: _vitest.vi.fn(()=>()=>{})
|
|
60
62
|
}
|
|
61
63
|
};
|
|
62
|
-
const logAction =
|
|
64
|
+
const logAction = _vitest.vi.fn();
|
|
63
65
|
await (0, _EmbeddedBlockUtil.selectEntityAndInsert)(_richtexttypes.BLOCKS.EMBEDDED_ENTRY, sdk, editor, logAction);
|
|
64
|
-
expect(editor.children.some((n)=>n.type === _richtexttypes.BLOCKS.EMBEDDED_ENTRY)).toBe(true);
|
|
66
|
+
(0, _vitest.expect)(editor.children.some((n)=>n.type === _richtexttypes.BLOCKS.EMBEDDED_ENTRY)).toBe(true);
|
|
65
67
|
});
|
|
66
|
-
it('inserts an embedded entry block when selection is inside a nested list item paragraph', async ()=>{
|
|
68
|
+
(0, _vitest.it)('inserts an embedded entry block when selection is inside a nested list item paragraph', async ()=>{
|
|
67
69
|
const editor = (0, _platetestutils.createEditor)('test-editor', {}, [
|
|
68
70
|
{
|
|
69
71
|
type: _richtexttypes.BLOCKS.UL_LIST,
|
|
@@ -116,7 +118,7 @@ describe('EmbeddedBlockUtil selectEntityAndInsert', ()=>{
|
|
|
116
118
|
validations: []
|
|
117
119
|
},
|
|
118
120
|
dialogs: {
|
|
119
|
-
selectSingleEntry:
|
|
121
|
+
selectSingleEntry: _vitest.vi.fn(async ()=>({
|
|
120
122
|
sys: {
|
|
121
123
|
id: 'entry-1',
|
|
122
124
|
type: 'Entry'
|
|
@@ -124,10 +126,10 @@ describe('EmbeddedBlockUtil selectEntityAndInsert', ()=>{
|
|
|
124
126
|
}))
|
|
125
127
|
},
|
|
126
128
|
navigator: {
|
|
127
|
-
onSlideInNavigation:
|
|
129
|
+
onSlideInNavigation: _vitest.vi.fn(()=>()=>{})
|
|
128
130
|
}
|
|
129
131
|
};
|
|
130
|
-
const logAction =
|
|
132
|
+
const logAction = _vitest.vi.fn();
|
|
131
133
|
await (0, _EmbeddedBlockUtil.selectEntityAndInsert)(_richtexttypes.BLOCKS.EMBEDDED_ENTRY, sdk, editor, logAction);
|
|
132
134
|
const containsType = (node, type)=>{
|
|
133
135
|
if (!node) return false;
|
|
@@ -135,6 +137,6 @@ describe('EmbeddedBlockUtil selectEntityAndInsert', ()=>{
|
|
|
135
137
|
if (Array.isArray(node.children)) return node.children.some((c)=>containsType(c, type));
|
|
136
138
|
return false;
|
|
137
139
|
};
|
|
138
|
-
expect(editor.children.some((n)=>containsType(n, _richtexttypes.BLOCKS.EMBEDDED_ENTRY))).toBe(true);
|
|
140
|
+
(0, _vitest.expect)(editor.children.some((n)=>containsType(n, _richtexttypes.BLOCKS.EMBEDDED_ENTRY))).toBe(true);
|
|
139
141
|
});
|
|
140
142
|
});
|
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
6
6
|
const _fieldeditorreference = require("@contentful/field-editor-reference");
|
|
7
|
-
require("@testing-library/jest-dom/extend-expect");
|
|
8
7
|
const _react1 = require("@testing-library/react");
|
|
8
|
+
const _vitest = require("vitest");
|
|
9
9
|
const _published_assetjson = /*#__PURE__*/ _interop_require_default(require("../__fixtures__/published_asset.json"));
|
|
10
10
|
const _FetchingWrappedAssetCard = require("../FetchingWrappedAssetCard");
|
|
11
11
|
function _interop_require_default(obj) {
|
|
@@ -58,7 +58,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
58
58
|
testIdAttribute: 'data-test-id'
|
|
59
59
|
});
|
|
60
60
|
let sdk;
|
|
61
|
-
beforeEach(()=>{
|
|
61
|
+
(0, _vitest.beforeEach)(()=>{
|
|
62
62
|
sdk = {
|
|
63
63
|
locales: {
|
|
64
64
|
default: 'en-US',
|
|
@@ -71,20 +71,20 @@ beforeEach(()=>{
|
|
|
71
71
|
},
|
|
72
72
|
cma: {
|
|
73
73
|
asset: {
|
|
74
|
-
get:
|
|
74
|
+
get: _vitest.vi.fn().mockResolvedValue(_published_assetjson.default)
|
|
75
75
|
},
|
|
76
76
|
scheduledAction: {
|
|
77
|
-
getMany:
|
|
77
|
+
getMany: _vitest.vi.fn().mockResolvedValue({
|
|
78
78
|
items: [],
|
|
79
79
|
total: 0
|
|
80
80
|
})
|
|
81
81
|
}
|
|
82
82
|
},
|
|
83
83
|
space: {
|
|
84
|
-
getEntityScheduledActions:
|
|
84
|
+
getEntityScheduledActions: _vitest.vi.fn().mockResolvedValue([])
|
|
85
85
|
},
|
|
86
86
|
navigator: {
|
|
87
|
-
onSlideInNavigation:
|
|
87
|
+
onSlideInNavigation: _vitest.vi.fn()
|
|
88
88
|
},
|
|
89
89
|
ids: {
|
|
90
90
|
space: 'space-id',
|
|
@@ -98,7 +98,7 @@ beforeEach(()=>{
|
|
|
98
98
|
}
|
|
99
99
|
};
|
|
100
100
|
});
|
|
101
|
-
test('some dropdown actions should be disabled', async ()=>{
|
|
101
|
+
(0, _vitest.test)('some dropdown actions should be disabled', async ()=>{
|
|
102
102
|
const { getByTestId, queryByTestId } = (0, _react1.render)(/*#__PURE__*/ _react.createElement(_fieldeditorreference.EntityProvider, {
|
|
103
103
|
sdk: sdk
|
|
104
104
|
}, /*#__PURE__*/ _react.createElement(_FetchingWrappedAssetCard.FetchingWrappedAssetCard, {
|
|
@@ -110,11 +110,11 @@ test('some dropdown actions should be disabled', async ()=>{
|
|
|
110
110
|
isDisabled: true,
|
|
111
111
|
isSelected: true
|
|
112
112
|
})));
|
|
113
|
-
await (0, _react1.waitFor)(()=>expect(getByTestId('cf-ui-asset').textContent).toBe('asset title'));
|
|
113
|
+
await (0, _react1.waitFor)(()=>(0, _vitest.expect)(getByTestId('cf-ui-asset').textContent).toBe('asset title'));
|
|
114
114
|
_react1.fireEvent.click(getByTestId('cf-ui-card-actions'));
|
|
115
115
|
await (0, _react1.waitFor)(()=>{
|
|
116
|
-
expect(getByTestId('card-action-edit')).not.toBeDisabled();
|
|
117
|
-
expect(queryByTestId('card-action-remove')).toBeNull();
|
|
118
|
-
expect(getByTestId('card-action-download')).not.toBeDisabled();
|
|
116
|
+
(0, _vitest.expect)(getByTestId('card-action-edit')).not.toBeDisabled();
|
|
117
|
+
(0, _vitest.expect)(queryByTestId('card-action-remove')).toBeNull();
|
|
118
|
+
(0, _vitest.expect)(getByTestId('card-action-download')).not.toBeDisabled();
|
|
119
119
|
});
|
|
120
120
|
});
|
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
6
6
|
const _fieldeditorreference = require("@contentful/field-editor-reference");
|
|
7
|
-
require("@testing-library/jest-dom/extend-expect");
|
|
8
7
|
const _react1 = require("@testing-library/react");
|
|
8
|
+
const _vitest = require("vitest");
|
|
9
9
|
const _published_content_typejson = /*#__PURE__*/ _interop_require_default(require("../__fixtures__/published_content_type.json"));
|
|
10
10
|
const _published_entryjson = /*#__PURE__*/ _interop_require_default(require("../__fixtures__/published_entry.json"));
|
|
11
11
|
const _FetchingWrappedEntryCard = require("../FetchingWrappedEntryCard");
|
|
@@ -59,7 +59,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
59
59
|
testIdAttribute: 'data-test-id'
|
|
60
60
|
});
|
|
61
61
|
let sdk;
|
|
62
|
-
beforeEach(()=>{
|
|
62
|
+
(0, _vitest.beforeEach)(()=>{
|
|
63
63
|
sdk = {
|
|
64
64
|
locales: {
|
|
65
65
|
default: 'en-US',
|
|
@@ -72,23 +72,23 @@ beforeEach(()=>{
|
|
|
72
72
|
},
|
|
73
73
|
cma: {
|
|
74
74
|
entry: {
|
|
75
|
-
get:
|
|
75
|
+
get: _vitest.vi.fn().mockResolvedValue(_published_entryjson.default)
|
|
76
76
|
},
|
|
77
77
|
scheduledAction: {
|
|
78
|
-
getMany:
|
|
78
|
+
getMany: _vitest.vi.fn().mockResolvedValue({
|
|
79
79
|
items: [],
|
|
80
80
|
total: 0
|
|
81
81
|
})
|
|
82
82
|
},
|
|
83
83
|
contentType: {
|
|
84
|
-
get:
|
|
84
|
+
get: _vitest.vi.fn().mockResolvedValue(_published_content_typejson.default)
|
|
85
85
|
}
|
|
86
86
|
},
|
|
87
87
|
space: {
|
|
88
|
-
getEntityScheduledActions:
|
|
88
|
+
getEntityScheduledActions: _vitest.vi.fn().mockResolvedValue([])
|
|
89
89
|
},
|
|
90
90
|
navigator: {
|
|
91
|
-
onSlideInNavigation:
|
|
91
|
+
onSlideInNavigation: _vitest.vi.fn()
|
|
92
92
|
},
|
|
93
93
|
ids: {
|
|
94
94
|
space: 'space-id',
|
|
@@ -102,7 +102,7 @@ beforeEach(()=>{
|
|
|
102
102
|
}
|
|
103
103
|
};
|
|
104
104
|
});
|
|
105
|
-
test('some dropdown actions should be disabled/removed', async ()=>{
|
|
105
|
+
(0, _vitest.test)('some dropdown actions should be disabled/removed', async ()=>{
|
|
106
106
|
const { getByTestId, queryByTestId } = (0, _react1.render)(/*#__PURE__*/ _react.createElement(_fieldeditorreference.EntityProvider, {
|
|
107
107
|
sdk: sdk
|
|
108
108
|
}, /*#__PURE__*/ _react.createElement(_FetchingWrappedEntryCard.FetchingWrappedEntryCard, {
|
|
@@ -114,10 +114,10 @@ test('some dropdown actions should be disabled/removed', async ()=>{
|
|
|
114
114
|
isDisabled: true,
|
|
115
115
|
isSelected: true
|
|
116
116
|
})));
|
|
117
|
-
await (0, _react1.waitFor)(()=>expect(getByTestId('title').textContent).toBe('The best article ever'));
|
|
117
|
+
await (0, _react1.waitFor)(()=>(0, _vitest.expect)(getByTestId('title').textContent).toBe('The best article ever'));
|
|
118
118
|
_react1.fireEvent.click(getByTestId('cf-ui-card-actions'));
|
|
119
119
|
await (0, _react1.waitFor)(()=>{
|
|
120
|
-
expect(getByTestId('edit')).not.toBeDisabled();
|
|
121
|
-
expect(queryByTestId('delete')).toBeNull();
|
|
120
|
+
(0, _vitest.expect)(getByTestId('edit')).not.toBeDisabled();
|
|
121
|
+
(0, _vitest.expect)(queryByTestId('delete')).toBeNull();
|
|
122
122
|
});
|
|
123
123
|
});
|
|
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
6
|
-
require("@testing-library/jest-dom/extend-expect");
|
|
7
6
|
const _fieldeditorreference = require("@contentful/field-editor-reference");
|
|
8
7
|
const _reactquery = require("@contentful/field-editor-shared/react-query");
|
|
9
8
|
const _fieldeditortestutils = require("@contentful/field-editor-test-utils");
|
|
10
9
|
const _react1 = require("@testing-library/react");
|
|
10
|
+
const _vitest = require("vitest");
|
|
11
11
|
const _published_content_typejson = /*#__PURE__*/ _interop_require_default(require("../__fixtures__/published_content_type.json"));
|
|
12
12
|
const _published_entryjson = /*#__PURE__*/ _interop_require_default(require("../__fixtures__/published_entry.json"));
|
|
13
13
|
const _spacejson = /*#__PURE__*/ _interop_require_default(require("../__fixtures__/space.json"));
|
|
@@ -64,7 +64,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
64
64
|
let sdk;
|
|
65
65
|
const resolvableEntryUrn = 'crn:contentful:::content:spaces/space-id/entries/linked-entry-urn';
|
|
66
66
|
const unknownEntryUrn = 'crn:contentful:::content:spaces/space-id/entries/unknown-entry-urn';
|
|
67
|
-
beforeEach(()=>{
|
|
67
|
+
(0, _vitest.beforeEach)(()=>{
|
|
68
68
|
sdk = {
|
|
69
69
|
locales: {
|
|
70
70
|
default: 'en-US',
|
|
@@ -77,10 +77,10 @@ beforeEach(()=>{
|
|
|
77
77
|
},
|
|
78
78
|
cma: {
|
|
79
79
|
contentType: {
|
|
80
|
-
get:
|
|
80
|
+
get: _vitest.vi.fn().mockReturnValue(_published_content_typejson.default)
|
|
81
81
|
},
|
|
82
82
|
entry: {
|
|
83
|
-
get:
|
|
83
|
+
get: _vitest.vi.fn().mockImplementation(({ entryId })=>{
|
|
84
84
|
if (entryId === 'linked-entry-urn') {
|
|
85
85
|
return Promise.resolve(_published_entryjson.default);
|
|
86
86
|
}
|
|
@@ -88,7 +88,7 @@ beforeEach(()=>{
|
|
|
88
88
|
})
|
|
89
89
|
},
|
|
90
90
|
locale: {
|
|
91
|
-
getMany:
|
|
91
|
+
getMany: _vitest.vi.fn().mockResolvedValue({
|
|
92
92
|
items: [
|
|
93
93
|
{
|
|
94
94
|
default: true,
|
|
@@ -98,17 +98,17 @@ beforeEach(()=>{
|
|
|
98
98
|
})
|
|
99
99
|
},
|
|
100
100
|
scheduledAction: {
|
|
101
|
-
getMany:
|
|
101
|
+
getMany: _vitest.vi.fn().mockResolvedValue({
|
|
102
102
|
items: [],
|
|
103
103
|
total: 0
|
|
104
104
|
})
|
|
105
105
|
},
|
|
106
106
|
space: {
|
|
107
|
-
get:
|
|
107
|
+
get: _vitest.vi.fn().mockResolvedValue(_spacejson.default)
|
|
108
108
|
}
|
|
109
109
|
},
|
|
110
110
|
space: {
|
|
111
|
-
onEntityChanged:
|
|
111
|
+
onEntityChanged: _vitest.vi.fn()
|
|
112
112
|
},
|
|
113
113
|
navigator: {},
|
|
114
114
|
ids: {
|
|
@@ -137,13 +137,13 @@ function renderResourceCard({ linkType = 'Contentful:Entry', entryUrn = resolvab
|
|
|
137
137
|
}
|
|
138
138
|
})));
|
|
139
139
|
}
|
|
140
|
-
test('renders entry card', async ()=>{
|
|
140
|
+
(0, _vitest.test)('renders entry card', async ()=>{
|
|
141
141
|
const { getByTestId, getByText } = renderResourceCard();
|
|
142
|
-
await (0, _react1.waitFor)(()=>expect(getByTestId('cf-ui-entry-card')).toBeDefined());
|
|
143
|
-
expect(getByText(_published_entryjson.default.fields.exField.en)).toBeDefined();
|
|
144
|
-
expect(getByText(_spacejson.default.name)).toBeDefined();
|
|
142
|
+
await (0, _react1.waitFor)(()=>(0, _vitest.expect)(getByTestId('cf-ui-entry-card')).toBeDefined());
|
|
143
|
+
(0, _vitest.expect)(getByText(_published_entryjson.default.fields.exField.en)).toBeDefined();
|
|
144
|
+
(0, _vitest.expect)(getByText(_spacejson.default.name)).toBeDefined();
|
|
145
145
|
});
|
|
146
|
-
test('renders skeleton while data is loading', async ()=>{
|
|
146
|
+
(0, _vitest.test)('renders skeleton while data is loading', async ()=>{
|
|
147
147
|
const queryClient = (0, _fieldeditortestutils.createTestQueryClient)();
|
|
148
148
|
let resolveEntry;
|
|
149
149
|
const pendingPromise = new Promise((resolve)=>{
|
|
@@ -164,21 +164,21 @@ test('renders skeleton while data is loading', async ()=>{
|
|
|
164
164
|
urn: resolvableEntryUrn
|
|
165
165
|
}
|
|
166
166
|
}))));
|
|
167
|
-
expect(getByTestId('cf-ui-skeleton-form')).toBeDefined();
|
|
168
|
-
expect(queryByTestId('cf-ui-entry-card')).toBeNull();
|
|
167
|
+
(0, _vitest.expect)(getByTestId('cf-ui-skeleton-form')).toBeDefined();
|
|
168
|
+
(0, _vitest.expect)(queryByTestId('cf-ui-entry-card')).toBeNull();
|
|
169
169
|
resolveEntry(_published_entryjson.default);
|
|
170
|
-
await (0, _react1.waitFor)(()=>expect(getByTestId('cf-ui-entry-card')).toBeDefined());
|
|
171
|
-
expect(queryByTestId('cf-ui-skeleton-form')).toBeNull();
|
|
170
|
+
await (0, _react1.waitFor)(()=>(0, _vitest.expect)(getByTestId('cf-ui-entry-card')).toBeDefined());
|
|
171
|
+
(0, _vitest.expect)(queryByTestId('cf-ui-skeleton-form')).toBeNull();
|
|
172
172
|
});
|
|
173
|
-
test('renders unsupported entity card when unsupported link is passed', async ()=>{
|
|
173
|
+
(0, _vitest.test)('renders unsupported entity card when unsupported link is passed', async ()=>{
|
|
174
174
|
const { getByText } = renderResourceCard({
|
|
175
175
|
linkType: 'Contentful:UnsupportedLink'
|
|
176
176
|
});
|
|
177
|
-
await (0, _react1.waitFor)(()=>expect(getByText('Unsupported API information')).toBeDefined());
|
|
177
|
+
await (0, _react1.waitFor)(()=>(0, _vitest.expect)(getByText('Unsupported API information')).toBeDefined());
|
|
178
178
|
});
|
|
179
|
-
test('renders missing entity card when unknown error is returned', async ()=>{
|
|
179
|
+
(0, _vitest.test)('renders missing entity card when unknown error is returned', async ()=>{
|
|
180
180
|
const { getByTestId } = renderResourceCard({
|
|
181
181
|
entryUrn: unknownEntryUrn
|
|
182
182
|
});
|
|
183
|
-
await (0, _react1.waitFor)(()=>expect(getByTestId('cf-ui-missing-entity-card')).toBeDefined());
|
|
183
|
+
await (0, _react1.waitFor)(()=>(0, _vitest.expect)(getByTestId('cf-ui-missing-entity-card')).toBeDefined());
|
|
184
184
|
});
|