@contentful/field-editor-url 2.1.0 → 2.1.1
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.
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
6
6
|
const _fieldeditortestutils = require("@contentful/field-editor-test-utils");
|
|
7
7
|
const _react1 = require("@testing-library/react");
|
|
8
|
-
require("
|
|
8
|
+
const _vitest = require("vitest");
|
|
9
9
|
const _UrlEditor = require("./UrlEditor");
|
|
10
10
|
function _getRequireWildcardCache(nodeInterop) {
|
|
11
11
|
if (typeof WeakMap !== "function") return null;
|
|
@@ -51,16 +51,16 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
51
51
|
(0, _react1.configure)({
|
|
52
52
|
testIdAttribute: 'data-test-id'
|
|
53
53
|
});
|
|
54
|
-
describe('UrlEditor', ()=>{
|
|
55
|
-
afterEach(_react1.cleanup);
|
|
56
|
-
it('renders without crashing', ()=>{
|
|
54
|
+
(0, _vitest.describe)('UrlEditor', ()=>{
|
|
55
|
+
(0, _vitest.afterEach)(_react1.cleanup);
|
|
56
|
+
(0, _vitest.it)('renders without crashing', ()=>{
|
|
57
57
|
const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)();
|
|
58
58
|
(0, _react1.render)(/*#__PURE__*/ _react.createElement(_UrlEditor.UrlEditor, {
|
|
59
59
|
field: field,
|
|
60
60
|
isInitiallyDisabled: false
|
|
61
61
|
}));
|
|
62
62
|
});
|
|
63
|
-
it('reads initial value from field.getValue', ()=>{
|
|
63
|
+
(0, _vitest.it)('reads initial value from field.getValue', ()=>{
|
|
64
64
|
const initialValue = 'initial-value';
|
|
65
65
|
const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((field)=>{
|
|
66
66
|
return {
|
|
@@ -75,12 +75,12 @@ describe('UrlEditor', ()=>{
|
|
|
75
75
|
field: field,
|
|
76
76
|
isInitiallyDisabled: false
|
|
77
77
|
}));
|
|
78
|
-
expect(getByTestId('cf-ui-text-input')).toHaveValue(initialValue);
|
|
78
|
+
(0, _vitest.expect)(getByTestId('cf-ui-text-input')).toHaveValue(initialValue);
|
|
79
79
|
});
|
|
80
|
-
it('calls field.setValue when user types and calls field.removeValue when user clears the input', async ()=>{
|
|
80
|
+
(0, _vitest.it)('calls field.setValue when user types and calls field.removeValue when user clears the input', async ()=>{
|
|
81
81
|
const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((field)=>{
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
_vitest.vi.spyOn(field, 'setValue');
|
|
83
|
+
_vitest.vi.spyOn(field, 'removeValue');
|
|
84
84
|
return {
|
|
85
85
|
...field,
|
|
86
86
|
id: 'field-id'
|
|
@@ -91,16 +91,16 @@ describe('UrlEditor', ()=>{
|
|
|
91
91
|
isInitiallyDisabled: false
|
|
92
92
|
}));
|
|
93
93
|
const $input = getByTestId('cf-ui-text-input');
|
|
94
|
-
expect($input).toHaveValue('');
|
|
94
|
+
(0, _vitest.expect)($input).toHaveValue('');
|
|
95
95
|
_react1.fireEvent.change($input, {
|
|
96
96
|
target: {
|
|
97
97
|
value: 'new-value'
|
|
98
98
|
}
|
|
99
99
|
});
|
|
100
100
|
await (0, _react1.waitFor)(()=>{
|
|
101
|
-
expect($input).toHaveValue('new-value');
|
|
102
|
-
expect(field.setValue).toHaveBeenCalledTimes(1);
|
|
103
|
-
expect(field.setValue).toHaveBeenLastCalledWith('new-value');
|
|
101
|
+
(0, _vitest.expect)($input).toHaveValue('new-value');
|
|
102
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenCalledTimes(1);
|
|
103
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenLastCalledWith('new-value');
|
|
104
104
|
});
|
|
105
105
|
_react1.fireEvent.change($input, {
|
|
106
106
|
target: {
|
|
@@ -108,12 +108,12 @@ describe('UrlEditor', ()=>{
|
|
|
108
108
|
}
|
|
109
109
|
});
|
|
110
110
|
await (0, _react1.waitFor)(()=>{
|
|
111
|
-
expect($input).toHaveValue('');
|
|
112
|
-
expect(field.removeValue).toHaveBeenCalledTimes(1);
|
|
113
|
-
expect(field.removeValue).toHaveBeenLastCalledWith();
|
|
111
|
+
(0, _vitest.expect)($input).toHaveValue('');
|
|
112
|
+
(0, _vitest.expect)(field.removeValue).toHaveBeenCalledTimes(1);
|
|
113
|
+
(0, _vitest.expect)(field.removeValue).toHaveBeenLastCalledWith();
|
|
114
114
|
});
|
|
115
115
|
});
|
|
116
|
-
it('gives an ability to render custom preview', ()=>{
|
|
116
|
+
(0, _vitest.it)('gives an ability to render custom preview', ()=>{
|
|
117
117
|
const initialValue = 'initial-value';
|
|
118
118
|
const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((field)=>{
|
|
119
119
|
return {
|
|
@@ -131,13 +131,13 @@ describe('UrlEditor', ()=>{
|
|
|
131
131
|
return /*#__PURE__*/ _react.createElement("div", null, "Custom preview: ", value);
|
|
132
132
|
}));
|
|
133
133
|
const $input = getByTestId('cf-ui-text-input');
|
|
134
|
-
expect($input).toHaveValue(initialValue);
|
|
135
|
-
expect(getByText('Custom preview: initial-value')).toBeInTheDocument();
|
|
134
|
+
(0, _vitest.expect)($input).toHaveValue(initialValue);
|
|
135
|
+
(0, _vitest.expect)(getByText('Custom preview: initial-value')).toBeInTheDocument();
|
|
136
136
|
_react1.fireEvent.change($input, {
|
|
137
137
|
target: {
|
|
138
138
|
value: 'new-value'
|
|
139
139
|
}
|
|
140
140
|
});
|
|
141
|
-
expect(getByText('Custom preview: new-value')).toBeInTheDocument();
|
|
141
|
+
(0, _vitest.expect)(getByText('Custom preview: new-value')).toBeInTheDocument();
|
|
142
142
|
});
|
|
143
143
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { createFakeFieldAPI } from '@contentful/field-editor-test-utils';
|
|
3
3
|
import { cleanup, configure, fireEvent, render, waitFor } from '@testing-library/react';
|
|
4
|
-
import
|
|
4
|
+
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
5
5
|
import { UrlEditor } from './UrlEditor';
|
|
6
6
|
configure({
|
|
7
7
|
testIdAttribute: 'data-test-id'
|
|
@@ -34,8 +34,8 @@ describe('UrlEditor', ()=>{
|
|
|
34
34
|
});
|
|
35
35
|
it('calls field.setValue when user types and calls field.removeValue when user clears the input', async ()=>{
|
|
36
36
|
const [field] = createFakeFieldAPI((field)=>{
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
vi.spyOn(field, 'setValue');
|
|
38
|
+
vi.spyOn(field, 'removeValue');
|
|
39
39
|
return {
|
|
40
40
|
...field,
|
|
41
41
|
id: 'field-id'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-url",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -31,16 +31,16 @@
|
|
|
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
|
-
"@contentful/field-editor-shared": "^4.4.
|
|
40
|
+
"@contentful/field-editor-shared": "^4.4.1"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@contentful/field-editor-test-utils": "^3.1.
|
|
43
|
+
"@contentful/field-editor-test-utils": "^3.1.1"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"react": ">=18.3.1",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"publishConfig": {
|
|
50
50
|
"registry": "https://npm.pkg.github.com/"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "5fb6c32d2590e72e56a53cb180a155f84d6505d9"
|
|
53
53
|
}
|