@contentful/field-editor-single-line 2.1.0 → 2.1.1-canary.5
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 _SingleLineEditor = require("./SingleLineEditor");
|
|
10
10
|
function _getRequireWildcardCache(nodeInterop) {
|
|
11
11
|
if (typeof WeakMap !== "function") return null;
|
|
@@ -51,9 +51,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
51
51
|
(0, _react1.configure)({
|
|
52
52
|
testIdAttribute: 'data-test-id'
|
|
53
53
|
});
|
|
54
|
-
describe('SingleLineEditor', ()=>{
|
|
55
|
-
afterEach(_react1.cleanup);
|
|
56
|
-
it('renders without crashing', ()=>{
|
|
54
|
+
(0, _vitest.describe)('SingleLineEditor', ()=>{
|
|
55
|
+
(0, _vitest.afterEach)(_react1.cleanup);
|
|
56
|
+
(0, _vitest.it)('renders without crashing', ()=>{
|
|
57
57
|
const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((field)=>{
|
|
58
58
|
return {
|
|
59
59
|
...field,
|
|
@@ -66,7 +66,7 @@ describe('SingleLineEditor', ()=>{
|
|
|
66
66
|
locales: (0, _fieldeditortestutils.createFakeLocalesAPI)()
|
|
67
67
|
}));
|
|
68
68
|
});
|
|
69
|
-
it('reads initial value from field.getValue', ()=>{
|
|
69
|
+
(0, _vitest.it)('reads initial value from field.getValue', ()=>{
|
|
70
70
|
const initialValue = 'initial-value';
|
|
71
71
|
const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((field)=>{
|
|
72
72
|
return {
|
|
@@ -83,14 +83,14 @@ describe('SingleLineEditor', ()=>{
|
|
|
83
83
|
isInitiallyDisabled: false,
|
|
84
84
|
locales: (0, _fieldeditortestutils.createFakeLocalesAPI)()
|
|
85
85
|
}));
|
|
86
|
-
expect(getByTestId('cf-ui-text-input')).toHaveValue(initialValue);
|
|
87
|
-
expect(getByText(`${initialValue.length} characters`)).toBeInTheDocument();
|
|
88
|
-
expect(getByText('Maximum 256 characters')).toBeInTheDocument();
|
|
86
|
+
(0, _vitest.expect)(getByTestId('cf-ui-text-input')).toHaveValue(initialValue);
|
|
87
|
+
(0, _vitest.expect)(getByText(`${initialValue.length} characters`)).toBeInTheDocument();
|
|
88
|
+
(0, _vitest.expect)(getByText('Maximum 256 characters')).toBeInTheDocument();
|
|
89
89
|
});
|
|
90
|
-
it('calls field.setValue when user types and calls field.removeValue when user clears the input', async ()=>{
|
|
90
|
+
(0, _vitest.it)('calls field.setValue when user types and calls field.removeValue when user clears the input', async ()=>{
|
|
91
91
|
const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((field)=>{
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
_vitest.vi.spyOn(field, 'setValue');
|
|
93
|
+
_vitest.vi.spyOn(field, 'removeValue');
|
|
94
94
|
return {
|
|
95
95
|
...field,
|
|
96
96
|
id: 'field-id',
|
|
@@ -103,16 +103,16 @@ describe('SingleLineEditor', ()=>{
|
|
|
103
103
|
locales: (0, _fieldeditortestutils.createFakeLocalesAPI)()
|
|
104
104
|
}));
|
|
105
105
|
const $input = getByTestId('cf-ui-text-input');
|
|
106
|
-
expect($input).toHaveValue('');
|
|
106
|
+
(0, _vitest.expect)($input).toHaveValue('');
|
|
107
107
|
_react1.fireEvent.change($input, {
|
|
108
108
|
target: {
|
|
109
109
|
value: 'new-value'
|
|
110
110
|
}
|
|
111
111
|
});
|
|
112
112
|
await (0, _react1.waitFor)(()=>{
|
|
113
|
-
expect($input).toHaveValue('new-value');
|
|
114
|
-
expect(field.setValue).toHaveBeenCalledTimes(1);
|
|
115
|
-
expect(field.setValue).toHaveBeenLastCalledWith('new-value');
|
|
113
|
+
(0, _vitest.expect)($input).toHaveValue('new-value');
|
|
114
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenCalledTimes(1);
|
|
115
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenLastCalledWith('new-value');
|
|
116
116
|
});
|
|
117
117
|
_react1.fireEvent.change($input, {
|
|
118
118
|
target: {
|
|
@@ -120,12 +120,12 @@ describe('SingleLineEditor', ()=>{
|
|
|
120
120
|
}
|
|
121
121
|
});
|
|
122
122
|
await (0, _react1.waitFor)(()=>{
|
|
123
|
-
expect($input).toHaveValue('');
|
|
124
|
-
expect(field.removeValue).toHaveBeenCalledTimes(1);
|
|
125
|
-
expect(field.removeValue).toHaveBeenLastCalledWith();
|
|
123
|
+
(0, _vitest.expect)($input).toHaveValue('');
|
|
124
|
+
(0, _vitest.expect)(field.removeValue).toHaveBeenCalledTimes(1);
|
|
125
|
+
(0, _vitest.expect)(field.removeValue).toHaveBeenLastCalledWith();
|
|
126
126
|
});
|
|
127
127
|
});
|
|
128
|
-
it('shows proper validation message (Symbol)', ()=>{
|
|
128
|
+
(0, _vitest.it)('shows proper validation message (Symbol)', ()=>{
|
|
129
129
|
const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((field)=>{
|
|
130
130
|
return {
|
|
131
131
|
...field,
|
|
@@ -138,10 +138,10 @@ describe('SingleLineEditor', ()=>{
|
|
|
138
138
|
isInitiallyDisabled: false,
|
|
139
139
|
locales: (0, _fieldeditortestutils.createFakeLocalesAPI)()
|
|
140
140
|
}));
|
|
141
|
-
expect(getByText('0 characters')).toBeInTheDocument();
|
|
142
|
-
expect(getByText('Maximum 256 characters')).toBeInTheDocument();
|
|
141
|
+
(0, _vitest.expect)(getByText('0 characters')).toBeInTheDocument();
|
|
142
|
+
(0, _vitest.expect)(getByText('Maximum 256 characters')).toBeInTheDocument();
|
|
143
143
|
});
|
|
144
|
-
it('shows proper validation message (Text)', ()=>{
|
|
144
|
+
(0, _vitest.it)('shows proper validation message (Text)', ()=>{
|
|
145
145
|
const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((field)=>{
|
|
146
146
|
return {
|
|
147
147
|
...field,
|
|
@@ -154,10 +154,10 @@ describe('SingleLineEditor', ()=>{
|
|
|
154
154
|
isInitiallyDisabled: false,
|
|
155
155
|
locales: (0, _fieldeditortestutils.createFakeLocalesAPI)()
|
|
156
156
|
}));
|
|
157
|
-
expect(getByText('0 characters')).toBeInTheDocument();
|
|
158
|
-
expect(getByText('Maximum 50000 characters')).toBeInTheDocument();
|
|
157
|
+
(0, _vitest.expect)(getByText('0 characters')).toBeInTheDocument();
|
|
158
|
+
(0, _vitest.expect)(getByText('Maximum 50000 characters')).toBeInTheDocument();
|
|
159
159
|
});
|
|
160
|
-
it('shows proper min-max validation message', ()=>{
|
|
160
|
+
(0, _vitest.it)('shows proper min-max validation message', ()=>{
|
|
161
161
|
const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((field)=>{
|
|
162
162
|
return {
|
|
163
163
|
...field,
|
|
@@ -178,10 +178,10 @@ describe('SingleLineEditor', ()=>{
|
|
|
178
178
|
isInitiallyDisabled: false,
|
|
179
179
|
locales: (0, _fieldeditortestutils.createFakeLocalesAPI)()
|
|
180
180
|
}));
|
|
181
|
-
expect(getByText('0 characters')).toBeInTheDocument();
|
|
182
|
-
expect(getByText('Requires between 100 and 1000 characters')).toBeInTheDocument();
|
|
181
|
+
(0, _vitest.expect)(getByText('0 characters')).toBeInTheDocument();
|
|
182
|
+
(0, _vitest.expect)(getByText('Requires between 100 and 1000 characters')).toBeInTheDocument();
|
|
183
183
|
});
|
|
184
|
-
it('shows proper min validation message', ()=>{
|
|
184
|
+
(0, _vitest.it)('shows proper min validation message', ()=>{
|
|
185
185
|
const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((field)=>{
|
|
186
186
|
return {
|
|
187
187
|
...field,
|
|
@@ -201,10 +201,10 @@ describe('SingleLineEditor', ()=>{
|
|
|
201
201
|
isInitiallyDisabled: false,
|
|
202
202
|
locales: (0, _fieldeditortestutils.createFakeLocalesAPI)()
|
|
203
203
|
}));
|
|
204
|
-
expect(getByText('0 characters')).toBeInTheDocument();
|
|
205
|
-
expect(getByText('Requires at least 1000 characters')).toBeInTheDocument();
|
|
204
|
+
(0, _vitest.expect)(getByText('0 characters')).toBeInTheDocument();
|
|
205
|
+
(0, _vitest.expect)(getByText('Requires at least 1000 characters')).toBeInTheDocument();
|
|
206
206
|
});
|
|
207
|
-
it('renders no validation message if withCharValidation is falsy', ()=>{
|
|
207
|
+
(0, _vitest.it)('renders no validation message if withCharValidation is falsy', ()=>{
|
|
208
208
|
const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((field)=>{
|
|
209
209
|
return {
|
|
210
210
|
...field,
|
|
@@ -226,10 +226,10 @@ describe('SingleLineEditor', ()=>{
|
|
|
226
226
|
isInitiallyDisabled: false,
|
|
227
227
|
locales: (0, _fieldeditortestutils.createFakeLocalesAPI)()
|
|
228
228
|
}));
|
|
229
|
-
expect(getByText('0 characters')).toBeInTheDocument();
|
|
230
|
-
expect(queryByText('Requires between 100 and 1000 characters')).not.toBeInTheDocument();
|
|
229
|
+
(0, _vitest.expect)(getByText('0 characters')).toBeInTheDocument();
|
|
230
|
+
(0, _vitest.expect)(queryByText('Requires between 100 and 1000 characters')).not.toBeInTheDocument();
|
|
231
231
|
});
|
|
232
|
-
it('renders no validation message or counter if withCharInformation is false', ()=>{
|
|
232
|
+
(0, _vitest.it)('renders no validation message or counter if withCharInformation is false', ()=>{
|
|
233
233
|
const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((field)=>{
|
|
234
234
|
return {
|
|
235
235
|
...field,
|
|
@@ -252,7 +252,7 @@ describe('SingleLineEditor', ()=>{
|
|
|
252
252
|
withCharInformation: false,
|
|
253
253
|
locales: (0, _fieldeditortestutils.createFakeLocalesAPI)()
|
|
254
254
|
}));
|
|
255
|
-
expect(queryByText('0 characters')).not.toBeInTheDocument();
|
|
256
|
-
expect(queryByText('Requires between 100 and 1000 characters')).not.toBeInTheDocument();
|
|
255
|
+
(0, _vitest.expect)(queryByText('0 characters')).not.toBeInTheDocument();
|
|
256
|
+
(0, _vitest.expect)(queryByText('Requires between 100 and 1000 characters')).not.toBeInTheDocument();
|
|
257
257
|
});
|
|
258
258
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { createFakeFieldAPI, createFakeLocalesAPI } 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 { SingleLineEditor } from './SingleLineEditor';
|
|
6
6
|
configure({
|
|
7
7
|
testIdAttribute: 'data-test-id'
|
|
@@ -44,8 +44,8 @@ describe('SingleLineEditor', ()=>{
|
|
|
44
44
|
});
|
|
45
45
|
it('calls field.setValue when user types and calls field.removeValue when user clears the input', async ()=>{
|
|
46
46
|
const [field] = createFakeFieldAPI((field)=>{
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
vi.spyOn(field, 'setValue');
|
|
48
|
+
vi.spyOn(field, 'removeValue');
|
|
49
49
|
return {
|
|
50
50
|
...field,
|
|
51
51
|
id: 'field-id',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-single-line",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.1-canary.5+3e29f973",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -31,18 +31,18 @@
|
|
|
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-tokens": "^6.1.2",
|
|
41
|
-
"@contentful/field-editor-shared": "^4.4.
|
|
41
|
+
"@contentful/field-editor-shared": "^4.4.1-canary.5+3e29f973",
|
|
42
42
|
"@emotion/css": "^11.13.5"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@contentful/field-editor-test-utils": "^3.1.
|
|
45
|
+
"@contentful/field-editor-test-utils": "^3.1.1-canary.5+3e29f973",
|
|
46
46
|
"@lingui/core": "5.3.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"publishConfig": {
|
|
54
54
|
"registry": "https://npm.pkg.github.com/"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "3e29f9734b46d8ca738457c87cc76a0aeca459e9"
|
|
57
57
|
}
|