@contentful/default-field-editors 4.1.3-canary.0 → 4.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/Field.spec.js
CHANGED
|
@@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
6
6
|
const _fieldeditorreference = require("@contentful/field-editor-reference");
|
|
7
7
|
const _fieldeditortestutils = require("@contentful/field-editor-test-utils");
|
|
8
|
-
require("@testing-library/jest-dom/extend-expect");
|
|
9
8
|
const _react1 = require("@testing-library/react");
|
|
9
|
+
const _vitest = require("vitest");
|
|
10
10
|
const _Field = require("./Field");
|
|
11
11
|
function _getRequireWildcardCache(nodeInterop) {
|
|
12
12
|
if (typeof WeakMap !== "function") return null;
|
|
@@ -52,9 +52,13 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
52
52
|
(0, _react1.configure)({
|
|
53
53
|
testIdAttribute: 'data-test-id'
|
|
54
54
|
});
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
_vitest.vi.mock('@contentful/field-editor-reference', async ()=>{
|
|
56
|
+
const actual = await _vitest.vi.importActual('@contentful/field-editor-reference');
|
|
57
|
+
return {
|
|
58
|
+
...actual,
|
|
59
|
+
SingleEntryReferenceEditor: _vitest.vi.fn(()=>/*#__PURE__*/ _react.createElement("div", null, "mock"))
|
|
60
|
+
};
|
|
61
|
+
});
|
|
58
62
|
const getSdk = (customize, initialValue)=>{
|
|
59
63
|
const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)(customize, initialValue);
|
|
60
64
|
const sdk = {
|
|
@@ -66,9 +70,9 @@ const getSdk = (customize, initialValue)=>{
|
|
|
66
70
|
};
|
|
67
71
|
return sdk;
|
|
68
72
|
};
|
|
69
|
-
describe('Field', ()=>{
|
|
70
|
-
afterEach(_react1.cleanup);
|
|
71
|
-
it('renders custom field editor specified by renderFieldEditor', ()=>{
|
|
73
|
+
(0, _vitest.describe)('Field', ()=>{
|
|
74
|
+
(0, _vitest.afterEach)(_react1.cleanup);
|
|
75
|
+
(0, _vitest.it)('renders custom field editor specified by renderFieldEditor', ()=>{
|
|
72
76
|
const sdk = getSdk();
|
|
73
77
|
const { queryByTestId } = (0, _react1.render)(/*#__PURE__*/ _react.createElement(_Field.Field, {
|
|
74
78
|
sdk: sdk,
|
|
@@ -80,14 +84,14 @@ describe('Field', ()=>{
|
|
|
80
84
|
}, "custom editor");
|
|
81
85
|
}
|
|
82
86
|
}));
|
|
83
|
-
expect(queryByTestId('customEditor')).toBeInTheDocument();
|
|
87
|
+
(0, _vitest.expect)(queryByTestId('customEditor')).toBeInTheDocument();
|
|
84
88
|
});
|
|
85
|
-
it('renders with specified options', ()=>{
|
|
89
|
+
(0, _vitest.it)('renders with specified options', ()=>{
|
|
86
90
|
const sdk = getSdk();
|
|
87
91
|
const options = {
|
|
88
92
|
entryLinkEditor: {
|
|
89
|
-
onAction:
|
|
90
|
-
renderCustomCard:
|
|
93
|
+
onAction: _vitest.vi.fn(),
|
|
94
|
+
renderCustomCard: _vitest.vi.fn()
|
|
91
95
|
}
|
|
92
96
|
};
|
|
93
97
|
(0, _react1.render)(/*#__PURE__*/ _react.createElement(_Field.Field, {
|
|
@@ -96,12 +100,12 @@ describe('Field', ()=>{
|
|
|
96
100
|
widgetId: "entryLinkEditor",
|
|
97
101
|
getOptions: ()=>options
|
|
98
102
|
}));
|
|
99
|
-
expect(_fieldeditorreference.SingleEntryReferenceEditor.mock.calls[0][0]).toMatchObject({
|
|
103
|
+
(0, _vitest.expect)(_fieldeditorreference.SingleEntryReferenceEditor.mock.calls[0][0]).toMatchObject({
|
|
100
104
|
onAction: options.entryLinkEditor.onAction,
|
|
101
105
|
renderCustomCard: options.entryLinkEditor.renderCustomCard
|
|
102
106
|
});
|
|
103
107
|
});
|
|
104
|
-
it('re-renders single field editor when locale changes', ()=>{
|
|
108
|
+
(0, _vitest.it)('re-renders single field editor when locale changes', ()=>{
|
|
105
109
|
const props = {
|
|
106
110
|
isInitiallyDisabled: false,
|
|
107
111
|
widgetId: 'singleLine'
|
|
@@ -113,7 +117,7 @@ describe('Field', ()=>{
|
|
|
113
117
|
return field;
|
|
114
118
|
}, 'english value')
|
|
115
119
|
}));
|
|
116
|
-
expect(container.querySelector('input')?.value).toBe('english value');
|
|
120
|
+
(0, _vitest.expect)(container.querySelector('input')?.value).toBe('english value');
|
|
117
121
|
rerender(/*#__PURE__*/ _react.createElement(_Field.Field, {
|
|
118
122
|
...props,
|
|
119
123
|
sdk: getSdk((field)=>{
|
|
@@ -121,6 +125,6 @@ describe('Field', ()=>{
|
|
|
121
125
|
return field;
|
|
122
126
|
}, 'german value')
|
|
123
127
|
}));
|
|
124
|
-
expect(container.querySelector('input')?.value).toBe('german value');
|
|
128
|
+
(0, _vitest.expect)(container.querySelector('input')?.value).toBe('german value');
|
|
125
129
|
});
|
|
126
130
|
});
|
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
6
6
|
const _fieldeditortestutils = require("@contentful/field-editor-test-utils");
|
|
7
|
-
require("@testing-library/jest-dom/extend-expect");
|
|
8
7
|
const _react1 = require("@testing-library/react");
|
|
8
|
+
const _vitest = require("vitest");
|
|
9
9
|
const _FieldWrapper = require("./FieldWrapper");
|
|
10
10
|
function _getRequireWildcardCache(nodeInterop) {
|
|
11
11
|
if (typeof WeakMap !== "function") return null;
|
|
@@ -62,9 +62,9 @@ const sdk = {
|
|
|
62
62
|
locales: (0, _fieldeditortestutils.createFakeLocalesAPI)()
|
|
63
63
|
};
|
|
64
64
|
const getEntryURL = ()=>'';
|
|
65
|
-
describe('Field', ()=>{
|
|
66
|
-
afterEach(_react1.cleanup);
|
|
67
|
-
it('renders children, label, validation errors and help text', ()=>{
|
|
65
|
+
(0, _vitest.describe)('Field', ()=>{
|
|
66
|
+
(0, _vitest.afterEach)(_react1.cleanup);
|
|
67
|
+
(0, _vitest.it)('renders children, label, validation errors and help text', ()=>{
|
|
68
68
|
sdk.parameters = {
|
|
69
69
|
instance: {
|
|
70
70
|
helpText: 'help'
|
|
@@ -82,13 +82,13 @@ describe('Field', ()=>{
|
|
|
82
82
|
'error'
|
|
83
83
|
]);
|
|
84
84
|
});
|
|
85
|
-
expect(queryByTestId('entity-field-controls')).toBeInTheDocument();
|
|
86
|
-
expect(queryByTestId('cf-ui-form-label')).toBeInTheDocument();
|
|
87
|
-
expect(queryByTestId('children')).toBeInTheDocument();
|
|
88
|
-
expect(queryByTestId('validation-errors')).toBeInTheDocument();
|
|
89
|
-
expect(queryByTestId('field-hint')).toBeInTheDocument();
|
|
85
|
+
(0, _vitest.expect)(queryByTestId('entity-field-controls')).toBeInTheDocument();
|
|
86
|
+
(0, _vitest.expect)(queryByTestId('cf-ui-form-label')).toBeInTheDocument();
|
|
87
|
+
(0, _vitest.expect)(queryByTestId('children')).toBeInTheDocument();
|
|
88
|
+
(0, _vitest.expect)(queryByTestId('validation-errors')).toBeInTheDocument();
|
|
89
|
+
(0, _vitest.expect)(queryByTestId('field-hint')).toBeInTheDocument();
|
|
90
90
|
});
|
|
91
|
-
it('renders custom label', ()=>{
|
|
91
|
+
(0, _vitest.it)('renders custom label', ()=>{
|
|
92
92
|
const { queryByTestId } = (0, _react1.render)(/*#__PURE__*/ _react.createElement(_FieldWrapper.FieldWrapper, {
|
|
93
93
|
name: "field",
|
|
94
94
|
sdk: sdk,
|
|
@@ -97,9 +97,9 @@ describe('Field', ()=>{
|
|
|
97
97
|
"data-test-id": "custom-label"
|
|
98
98
|
}, "custom label")
|
|
99
99
|
}, /*#__PURE__*/ _react.createElement("div", null, "children")));
|
|
100
|
-
expect(queryByTestId('custom-label')).toBeInTheDocument();
|
|
100
|
+
(0, _vitest.expect)(queryByTestId('custom-label')).toBeInTheDocument();
|
|
101
101
|
});
|
|
102
|
-
it('renders custom help text', ()=>{
|
|
102
|
+
(0, _vitest.it)('renders custom help text', ()=>{
|
|
103
103
|
const { queryByTestId } = (0, _react1.render)(/*#__PURE__*/ _react.createElement(_FieldWrapper.FieldWrapper, {
|
|
104
104
|
name: "field",
|
|
105
105
|
sdk: sdk,
|
|
@@ -108,6 +108,6 @@ describe('Field', ()=>{
|
|
|
108
108
|
"data-test-id": "custom-hint"
|
|
109
109
|
}, "custom hint")
|
|
110
110
|
}, /*#__PURE__*/ _react.createElement("div", null, "children")));
|
|
111
|
-
expect(queryByTestId('custom-hint')).toBeInTheDocument();
|
|
111
|
+
(0, _vitest.expect)(queryByTestId('custom-hint')).toBeInTheDocument();
|
|
112
112
|
});
|
|
113
113
|
});
|
package/dist/esm/Field.spec.js
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { SingleEntryReferenceEditor } from '@contentful/field-editor-reference';
|
|
3
3
|
import { createFakeFieldAPI, createFakeLocalesAPI } from '@contentful/field-editor-test-utils';
|
|
4
|
-
import '@testing-library/jest-dom/extend-expect';
|
|
5
4
|
import { cleanup, configure, render } from '@testing-library/react';
|
|
5
|
+
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
6
6
|
import { Field } from './Field';
|
|
7
7
|
configure({
|
|
8
8
|
testIdAttribute: 'data-test-id'
|
|
9
9
|
});
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
vi.mock('@contentful/field-editor-reference', async ()=>{
|
|
11
|
+
const actual = await vi.importActual('@contentful/field-editor-reference');
|
|
12
|
+
return {
|
|
13
|
+
...actual,
|
|
14
|
+
SingleEntryReferenceEditor: vi.fn(()=>/*#__PURE__*/ React.createElement("div", null, "mock"))
|
|
15
|
+
};
|
|
16
|
+
});
|
|
13
17
|
const getSdk = (customize, initialValue)=>{
|
|
14
18
|
const [field] = createFakeFieldAPI(customize, initialValue);
|
|
15
19
|
const sdk = {
|
|
@@ -41,8 +45,8 @@ describe('Field', ()=>{
|
|
|
41
45
|
const sdk = getSdk();
|
|
42
46
|
const options = {
|
|
43
47
|
entryLinkEditor: {
|
|
44
|
-
onAction:
|
|
45
|
-
renderCustomCard:
|
|
48
|
+
onAction: vi.fn(),
|
|
49
|
+
renderCustomCard: vi.fn()
|
|
46
50
|
}
|
|
47
51
|
};
|
|
48
52
|
render(/*#__PURE__*/ React.createElement(Field, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { createFakeFieldAPI, createFakeLocalesAPI } from '@contentful/field-editor-test-utils';
|
|
3
|
-
import '@testing-library/jest-dom/extend-expect';
|
|
4
3
|
import { act, cleanup, configure, render } from '@testing-library/react';
|
|
4
|
+
import { afterEach, describe, expect, it } from 'vitest';
|
|
5
5
|
import { FieldWrapper } from './FieldWrapper';
|
|
6
6
|
configure({
|
|
7
7
|
testIdAttribute: 'data-test-id'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/default-field-editors",
|
|
3
|
-
"version": "4.1.3
|
|
3
|
+
"version": "4.1.3",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -31,39 +31,39 @@
|
|
|
31
31
|
"build:types": "tsc --outDir dist/types --emitDeclarationOnly",
|
|
32
32
|
"build:cjs": "swc src --config-file ../../.swcrc -d dist/cjs -C module.type=commonjs",
|
|
33
33
|
"build:esm": "swc src --config-file ../../.swcrc -d dist/esm",
|
|
34
|
-
"test": "
|
|
35
|
-
"test:ci": "
|
|
34
|
+
"test": "vitest",
|
|
35
|
+
"test:ci": "vitest run",
|
|
36
36
|
"tsc": "tsc -p ./ --noEmit"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@contentful/f36-components": "^6.7.1",
|
|
40
40
|
"@contentful/f36-icons": "^6.7.1",
|
|
41
41
|
"@contentful/f36-tokens": "^6.1.2",
|
|
42
|
-
"@contentful/field-editor-boolean": "^2.1.
|
|
43
|
-
"@contentful/field-editor-checkbox": "^2.1.
|
|
44
|
-
"@contentful/field-editor-date": "^2.1.
|
|
45
|
-
"@contentful/field-editor-dropdown": "^3.1.
|
|
46
|
-
"@contentful/field-editor-json": "^4.2.
|
|
47
|
-
"@contentful/field-editor-list": "^2.1.
|
|
48
|
-
"@contentful/field-editor-location": "^2.1.
|
|
49
|
-
"@contentful/field-editor-markdown": "^2.2.
|
|
50
|
-
"@contentful/field-editor-multiple-line": "^2.1.
|
|
51
|
-
"@contentful/field-editor-number": "^2.1.
|
|
52
|
-
"@contentful/field-editor-radio": "^3.1.
|
|
53
|
-
"@contentful/field-editor-rating": "^2.1.
|
|
54
|
-
"@contentful/field-editor-reference": "^8.3.
|
|
55
|
-
"@contentful/field-editor-rich-text": "^6.3.8
|
|
56
|
-
"@contentful/field-editor-shared": "^4.4.
|
|
57
|
-
"@contentful/field-editor-single-line": "^2.1.
|
|
58
|
-
"@contentful/field-editor-slug": "^3.3.
|
|
59
|
-
"@contentful/field-editor-tags": "^2.1.
|
|
60
|
-
"@contentful/field-editor-url": "^2.1.
|
|
61
|
-
"@contentful/field-editor-validation-errors": "^3.1.
|
|
42
|
+
"@contentful/field-editor-boolean": "^2.1.1",
|
|
43
|
+
"@contentful/field-editor-checkbox": "^2.1.1",
|
|
44
|
+
"@contentful/field-editor-date": "^2.1.1",
|
|
45
|
+
"@contentful/field-editor-dropdown": "^3.1.1",
|
|
46
|
+
"@contentful/field-editor-json": "^4.2.1",
|
|
47
|
+
"@contentful/field-editor-list": "^2.1.1",
|
|
48
|
+
"@contentful/field-editor-location": "^2.1.1",
|
|
49
|
+
"@contentful/field-editor-markdown": "^2.2.1",
|
|
50
|
+
"@contentful/field-editor-multiple-line": "^2.1.1",
|
|
51
|
+
"@contentful/field-editor-number": "^2.1.1",
|
|
52
|
+
"@contentful/field-editor-radio": "^3.1.1",
|
|
53
|
+
"@contentful/field-editor-rating": "^2.1.1",
|
|
54
|
+
"@contentful/field-editor-reference": "^8.3.2",
|
|
55
|
+
"@contentful/field-editor-rich-text": "^6.3.8",
|
|
56
|
+
"@contentful/field-editor-shared": "^4.4.1",
|
|
57
|
+
"@contentful/field-editor-single-line": "^2.1.1",
|
|
58
|
+
"@contentful/field-editor-slug": "^3.3.1",
|
|
59
|
+
"@contentful/field-editor-tags": "^2.1.1",
|
|
60
|
+
"@contentful/field-editor-url": "^2.1.1",
|
|
61
|
+
"@contentful/field-editor-validation-errors": "^3.1.1",
|
|
62
62
|
"@emotion/css": "^11.13.5",
|
|
63
63
|
"contentful-management": "^12.3.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@contentful/field-editor-test-utils": "^3.1.
|
|
66
|
+
"@contentful/field-editor-test-utils": "^3.1.1"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
69
|
"react": ">=18.3.1",
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"publishConfig": {
|
|
73
73
|
"registry": "https://npm.pkg.github.com/"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "5fb6c32d2590e72e56a53cb180a155f84d6505d9"
|
|
76
76
|
}
|