@contentful/field-editor-radio 3.1.0 → 3.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.
|
@@ -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 _RadioEditor = require("./RadioEditor");
|
|
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('RadioEditor', ()=>{
|
|
55
|
-
afterEach(_react1.cleanup);
|
|
56
|
-
it('renders a warning if no options are present', ()=>{
|
|
54
|
+
(0, _vitest.describe)('RadioEditor', ()=>{
|
|
55
|
+
(0, _vitest.afterEach)(_react1.cleanup);
|
|
56
|
+
(0, _vitest.it)('renders a warning if no options are present', ()=>{
|
|
57
57
|
const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((mock)=>{
|
|
58
58
|
return {
|
|
59
59
|
...mock,
|
|
@@ -65,10 +65,10 @@ describe('RadioEditor', ()=>{
|
|
|
65
65
|
locales: (0, _fieldeditortestutils.createFakeLocalesAPI)(),
|
|
66
66
|
isInitiallyDisabled: false
|
|
67
67
|
}));
|
|
68
|
-
expect(getByTestId('predefined-values-warning')).toBeInTheDocument();
|
|
69
|
-
expect(queryByTestId('radio-editor')).not.toBeInTheDocument();
|
|
68
|
+
(0, _vitest.expect)(getByTestId('predefined-values-warning')).toBeInTheDocument();
|
|
69
|
+
(0, _vitest.expect)(queryByTestId('radio-editor')).not.toBeInTheDocument();
|
|
70
70
|
});
|
|
71
|
-
it('renders inputs for predefined values', ()=>{
|
|
71
|
+
(0, _vitest.it)('renders inputs for predefined values', ()=>{
|
|
72
72
|
const predefined = [
|
|
73
73
|
'banana',
|
|
74
74
|
'orange',
|
|
@@ -90,15 +90,15 @@ describe('RadioEditor', ()=>{
|
|
|
90
90
|
isInitiallyDisabled: false
|
|
91
91
|
}));
|
|
92
92
|
const $inputs = container.querySelectorAll('input[type="radio"]');
|
|
93
|
-
expect($inputs).toHaveLength(3);
|
|
93
|
+
(0, _vitest.expect)($inputs).toHaveLength(3);
|
|
94
94
|
predefined.forEach((item, index)=>{
|
|
95
|
-
expect($inputs[index].value).toEqual(item);
|
|
95
|
+
(0, _vitest.expect)($inputs[index].value).toEqual(item);
|
|
96
96
|
});
|
|
97
97
|
});
|
|
98
|
-
it('calls setValue and removeValue properly', ()=>{
|
|
98
|
+
(0, _vitest.it)('calls setValue and removeValue properly', ()=>{
|
|
99
99
|
const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((field)=>{
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
_vitest.vi.spyOn(field, 'setValue');
|
|
101
|
+
_vitest.vi.spyOn(field, 'removeValue');
|
|
102
102
|
return {
|
|
103
103
|
...field,
|
|
104
104
|
validations: [
|
|
@@ -117,26 +117,26 @@ describe('RadioEditor', ()=>{
|
|
|
117
117
|
locales: (0, _fieldeditortestutils.createFakeLocalesAPI)(),
|
|
118
118
|
isInitiallyDisabled: false
|
|
119
119
|
}));
|
|
120
|
-
expect(queryByText('Clear')).not.toBeInTheDocument();
|
|
120
|
+
(0, _vitest.expect)(queryByText('Clear')).not.toBeInTheDocument();
|
|
121
121
|
const $inputs = container.querySelectorAll('input[type="radio"]');
|
|
122
122
|
_react1.fireEvent.click($inputs[0]);
|
|
123
|
-
expect(field.setValue).toHaveBeenCalledWith('banana');
|
|
123
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenCalledWith('banana');
|
|
124
124
|
_react1.fireEvent.click($inputs[1]);
|
|
125
|
-
expect(field.setValue).toHaveBeenCalledWith('orange');
|
|
126
|
-
expect(field.removeValue).toHaveBeenCalledTimes(0);
|
|
125
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenCalledWith('orange');
|
|
126
|
+
(0, _vitest.expect)(field.removeValue).toHaveBeenCalledTimes(0);
|
|
127
127
|
_react1.fireEvent.click(getByText('Clear'));
|
|
128
|
-
expect(field.removeValue).toHaveBeenCalledTimes(1);
|
|
128
|
+
(0, _vitest.expect)(field.removeValue).toHaveBeenCalledTimes(1);
|
|
129
129
|
});
|
|
130
|
-
describe('Number field', ()=>{
|
|
131
|
-
it('calls setValue and removeValue properly', function() {
|
|
130
|
+
(0, _vitest.describe)('Number field', ()=>{
|
|
131
|
+
(0, _vitest.it)('calls setValue and removeValue properly', function() {
|
|
132
132
|
const predefined = [
|
|
133
133
|
1,
|
|
134
134
|
'2.71',
|
|
135
135
|
'0'
|
|
136
136
|
];
|
|
137
137
|
const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((field)=>{
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
_vitest.vi.spyOn(field, 'setValue');
|
|
139
|
+
_vitest.vi.spyOn(field, 'removeValue');
|
|
140
140
|
return {
|
|
141
141
|
...field,
|
|
142
142
|
type: 'Number',
|
|
@@ -154,21 +154,21 @@ describe('RadioEditor', ()=>{
|
|
|
154
154
|
}));
|
|
155
155
|
const $inputs = container.querySelectorAll('input[type="radio"]');
|
|
156
156
|
_react1.fireEvent.click($inputs[0]);
|
|
157
|
-
expect(field.setValue).toHaveBeenCalledWith(1);
|
|
158
|
-
expect(field.setValue).toHaveBeenCalledTimes(1);
|
|
157
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenCalledWith(1);
|
|
158
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenCalledTimes(1);
|
|
159
159
|
_react1.fireEvent.click($inputs[1]);
|
|
160
|
-
expect(field.setValue).toHaveBeenCalledWith(2.71);
|
|
161
|
-
expect(field.setValue).toHaveBeenCalledTimes(2);
|
|
160
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenCalledWith(2.71);
|
|
161
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenCalledTimes(2);
|
|
162
162
|
_react1.fireEvent.click($inputs[2]);
|
|
163
|
-
expect(field.setValue).toHaveBeenCalledWith(0);
|
|
164
|
-
expect(field.setValue).toHaveBeenCalledTimes(3);
|
|
165
|
-
expect(field.removeValue).toHaveBeenCalledTimes(0);
|
|
163
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenCalledWith(0);
|
|
164
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenCalledTimes(3);
|
|
165
|
+
(0, _vitest.expect)(field.removeValue).toHaveBeenCalledTimes(0);
|
|
166
166
|
_react1.fireEvent.click(getByText('Clear'));
|
|
167
|
-
expect(field.removeValue).toHaveBeenCalledTimes(1);
|
|
167
|
+
(0, _vitest.expect)(field.removeValue).toHaveBeenCalledTimes(1);
|
|
168
168
|
});
|
|
169
169
|
});
|
|
170
|
-
describe('Integer field', ()=>{
|
|
171
|
-
it('calls setValue and removeValue properly', function() {
|
|
170
|
+
(0, _vitest.describe)('Integer field', ()=>{
|
|
171
|
+
(0, _vitest.it)('calls setValue and removeValue properly', function() {
|
|
172
172
|
const predefined = [
|
|
173
173
|
0,
|
|
174
174
|
'65',
|
|
@@ -176,8 +176,8 @@ describe('RadioEditor', ()=>{
|
|
|
176
176
|
100
|
|
177
177
|
];
|
|
178
178
|
const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((field)=>{
|
|
179
|
-
|
|
180
|
-
|
|
179
|
+
_vitest.vi.spyOn(field, 'setValue');
|
|
180
|
+
_vitest.vi.spyOn(field, 'removeValue');
|
|
181
181
|
return {
|
|
182
182
|
...field,
|
|
183
183
|
type: 'Number',
|
|
@@ -195,17 +195,17 @@ describe('RadioEditor', ()=>{
|
|
|
195
195
|
}));
|
|
196
196
|
const $inputs = container.querySelectorAll('input[type="radio"]');
|
|
197
197
|
_react1.fireEvent.click($inputs[0]);
|
|
198
|
-
expect(field.setValue).toHaveBeenCalledWith(0);
|
|
199
|
-
expect(field.setValue).toHaveBeenCalledTimes(1);
|
|
198
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenCalledWith(0);
|
|
199
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenCalledTimes(1);
|
|
200
200
|
_react1.fireEvent.click($inputs[1]);
|
|
201
|
-
expect(field.setValue).toHaveBeenCalledWith(65);
|
|
202
|
-
expect(field.setValue).toHaveBeenCalledTimes(2);
|
|
201
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenCalledWith(65);
|
|
202
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenCalledTimes(2);
|
|
203
203
|
_react1.fireEvent.click($inputs[2]);
|
|
204
|
-
expect(field.setValue).toHaveBeenCalledWith(99);
|
|
205
|
-
expect(field.setValue).toHaveBeenCalledTimes(3);
|
|
206
|
-
expect(field.removeValue).toHaveBeenCalledTimes(0);
|
|
204
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenCalledWith(99);
|
|
205
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenCalledTimes(3);
|
|
206
|
+
(0, _vitest.expect)(field.removeValue).toHaveBeenCalledTimes(0);
|
|
207
207
|
_react1.fireEvent.click(getByText('Clear'));
|
|
208
|
-
expect(field.removeValue).toHaveBeenCalledTimes(1);
|
|
208
|
+
(0, _vitest.expect)(field.removeValue).toHaveBeenCalledTimes(1);
|
|
209
209
|
});
|
|
210
210
|
});
|
|
211
211
|
});
|
|
@@ -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 { cleanup, configure, fireEvent, render } from '@testing-library/react';
|
|
4
|
+
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
5
5
|
import { RadioEditor } from './RadioEditor';
|
|
6
6
|
configure({
|
|
7
7
|
testIdAttribute: 'data-test-id'
|
|
@@ -52,8 +52,8 @@ describe('RadioEditor', ()=>{
|
|
|
52
52
|
});
|
|
53
53
|
it('calls setValue and removeValue properly', ()=>{
|
|
54
54
|
const [field] = createFakeFieldAPI((field)=>{
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
vi.spyOn(field, 'setValue');
|
|
56
|
+
vi.spyOn(field, 'removeValue');
|
|
57
57
|
return {
|
|
58
58
|
...field,
|
|
59
59
|
validations: [
|
|
@@ -90,8 +90,8 @@ describe('RadioEditor', ()=>{
|
|
|
90
90
|
'0'
|
|
91
91
|
];
|
|
92
92
|
const [field] = createFakeFieldAPI((field)=>{
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
vi.spyOn(field, 'setValue');
|
|
94
|
+
vi.spyOn(field, 'removeValue');
|
|
95
95
|
return {
|
|
96
96
|
...field,
|
|
97
97
|
type: 'Number',
|
|
@@ -131,8 +131,8 @@ describe('RadioEditor', ()=>{
|
|
|
131
131
|
100
|
|
132
132
|
];
|
|
133
133
|
const [field] = createFakeFieldAPI((field)=>{
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
vi.spyOn(field, 'setValue');
|
|
135
|
+
vi.spyOn(field, 'removeValue');
|
|
136
136
|
return {
|
|
137
137
|
...field,
|
|
138
138
|
type: 'Number',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-radio",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.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,19 +31,19 @@
|
|
|
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-dropdown": "^3.1.
|
|
42
|
-
"@contentful/field-editor-shared": "^4.4.
|
|
41
|
+
"@contentful/field-editor-dropdown": "^3.1.1-canary.5+3e29f973",
|
|
42
|
+
"@contentful/field-editor-shared": "^4.4.1-canary.5+3e29f973",
|
|
43
43
|
"@emotion/css": "^11.13.5"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@contentful/field-editor-test-utils": "^3.1.
|
|
46
|
+
"@contentful/field-editor-test-utils": "^3.1.1-canary.5+3e29f973",
|
|
47
47
|
"@lingui/core": "5.3.0",
|
|
48
48
|
"contentful-management": "^12.3.0"
|
|
49
49
|
},
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"publishConfig": {
|
|
56
56
|
"registry": "https://npm.pkg.github.com/"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "3e29f9734b46d8ca738457c87cc76a0aeca459e9"
|
|
59
59
|
}
|