@contentful/field-editor-checkbox 2.0.14-canary.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.
|
@@ -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 _CheckboxEditor = require("./CheckboxEditor");
|
|
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('CheckboxEditor', ()=>{
|
|
55
|
-
afterEach(_react1.cleanup);
|
|
56
|
-
it('renders a warning if no options are present', ()=>{
|
|
54
|
+
(0, _vitest.describe)('CheckboxEditor', ()=>{
|
|
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,
|
|
@@ -69,10 +69,10 @@ describe('CheckboxEditor', ()=>{
|
|
|
69
69
|
locales: (0, _fieldeditortestutils.createFakeLocalesAPI)(),
|
|
70
70
|
isInitiallyDisabled: false
|
|
71
71
|
}));
|
|
72
|
-
expect(getByTestId('predefined-values-warning')).toBeInTheDocument();
|
|
73
|
-
expect(queryByTestId('dropdown-editor')).not.toBeInTheDocument();
|
|
72
|
+
(0, _vitest.expect)(getByTestId('predefined-values-warning')).toBeInTheDocument();
|
|
73
|
+
(0, _vitest.expect)(queryByTestId('dropdown-editor')).not.toBeInTheDocument();
|
|
74
74
|
});
|
|
75
|
-
it('renders checkboxes for predefined values', ()=>{
|
|
75
|
+
(0, _vitest.it)('renders checkboxes for predefined values', ()=>{
|
|
76
76
|
const predefined = [
|
|
77
77
|
'banana',
|
|
78
78
|
'orange',
|
|
@@ -98,20 +98,20 @@ describe('CheckboxEditor', ()=>{
|
|
|
98
98
|
isInitiallyDisabled: false
|
|
99
99
|
}));
|
|
100
100
|
const $inputs = container.querySelectorAll('input[type="checkbox"]');
|
|
101
|
-
expect($inputs).toHaveLength(3);
|
|
101
|
+
(0, _vitest.expect)($inputs).toHaveLength(3);
|
|
102
102
|
predefined.forEach((item, index)=>{
|
|
103
|
-
expect($inputs[index].value).toEqual(item);
|
|
103
|
+
(0, _vitest.expect)($inputs[index].value).toEqual(item);
|
|
104
104
|
});
|
|
105
105
|
});
|
|
106
|
-
it('calls setValue for every check event and removeValue if all items are unclicked', ()=>{
|
|
106
|
+
(0, _vitest.it)('calls setValue for every check event and removeValue if all items are unclicked', ()=>{
|
|
107
107
|
const predefined = [
|
|
108
108
|
'banana',
|
|
109
109
|
'orange',
|
|
110
110
|
'strawberry'
|
|
111
111
|
];
|
|
112
112
|
const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((mock)=>{
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
_vitest.vi.spyOn(mock, 'setValue');
|
|
114
|
+
_vitest.vi.spyOn(mock, 'removeValue');
|
|
115
115
|
return {
|
|
116
116
|
...mock,
|
|
117
117
|
items: {
|
|
@@ -132,37 +132,37 @@ describe('CheckboxEditor', ()=>{
|
|
|
132
132
|
}));
|
|
133
133
|
const $inputs = container.querySelectorAll('input[type="checkbox"]');
|
|
134
134
|
_react1.fireEvent.click($inputs[0]);
|
|
135
|
-
expect(field.setValue).toHaveBeenCalledWith([
|
|
135
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenCalledWith([
|
|
136
136
|
predefined[0]
|
|
137
137
|
]);
|
|
138
|
-
expect(field.setValue).toHaveBeenCalledTimes(1);
|
|
138
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenCalledTimes(1);
|
|
139
139
|
_react1.fireEvent.click($inputs[2]);
|
|
140
|
-
expect(field.setValue).toHaveBeenCalledWith([
|
|
140
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenCalledWith([
|
|
141
141
|
predefined[0],
|
|
142
142
|
predefined[2]
|
|
143
143
|
]);
|
|
144
|
-
expect(field.setValue).toHaveBeenCalledTimes(2);
|
|
144
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenCalledTimes(2);
|
|
145
145
|
_react1.fireEvent.click($inputs[1]);
|
|
146
|
-
expect(field.setValue).toHaveBeenCalledWith([
|
|
146
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenCalledWith([
|
|
147
147
|
predefined[0],
|
|
148
148
|
predefined[2],
|
|
149
149
|
predefined[1]
|
|
150
150
|
]);
|
|
151
|
-
expect(field.setValue).toHaveBeenCalledTimes(3);
|
|
151
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenCalledTimes(3);
|
|
152
152
|
$inputs.forEach(($input)=>{
|
|
153
153
|
_react1.fireEvent.click($input);
|
|
154
154
|
});
|
|
155
|
-
expect(field.removeValue).toHaveBeenCalledTimes(1);
|
|
155
|
+
(0, _vitest.expect)(field.removeValue).toHaveBeenCalledTimes(1);
|
|
156
156
|
});
|
|
157
|
-
it('renders invalid text and remove link when value set is not in predefined values', ()=>{
|
|
157
|
+
(0, _vitest.it)('renders invalid text and remove link when value set is not in predefined values', ()=>{
|
|
158
158
|
const predefined = [
|
|
159
159
|
'banana',
|
|
160
160
|
'orange',
|
|
161
161
|
'strawberry'
|
|
162
162
|
];
|
|
163
163
|
const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((mock)=>{
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
_vitest.vi.spyOn(mock, 'setValue');
|
|
165
|
+
_vitest.vi.spyOn(mock, 'removeValue');
|
|
166
166
|
return {
|
|
167
167
|
...mock,
|
|
168
168
|
items: {
|
|
@@ -184,12 +184,12 @@ describe('CheckboxEditor', ()=>{
|
|
|
184
184
|
locales: (0, _fieldeditortestutils.createFakeLocalesAPI)(),
|
|
185
185
|
isInitiallyDisabled: false
|
|
186
186
|
}));
|
|
187
|
-
expect(getByTestId('invalid-text')).toBeInTheDocument();
|
|
188
|
-
expect(getByTestId('cf-ui-text-link')).toBeInTheDocument();
|
|
187
|
+
(0, _vitest.expect)(getByTestId('invalid-text')).toBeInTheDocument();
|
|
188
|
+
(0, _vitest.expect)(getByTestId('cf-ui-text-link')).toBeInTheDocument();
|
|
189
189
|
_react1.fireEvent.click(getByTestId('cf-ui-text-link'));
|
|
190
|
-
expect(field.removeValue).toHaveBeenCalledTimes(1);
|
|
190
|
+
(0, _vitest.expect)(field.removeValue).toHaveBeenCalledTimes(1);
|
|
191
191
|
});
|
|
192
|
-
it('renders checkboxes with unique ids', async ()=>{
|
|
192
|
+
(0, _vitest.it)('renders checkboxes with unique ids', async ()=>{
|
|
193
193
|
const predefined = [
|
|
194
194
|
'banana',
|
|
195
195
|
'orange',
|
|
@@ -221,6 +221,6 @@ describe('CheckboxEditor', ()=>{
|
|
|
221
221
|
})));
|
|
222
222
|
const $labels = await findAllByTestId('cf-ui-checkbox');
|
|
223
223
|
const uniqueIds = Array.from(new Set($labels.map((label)=>label.getAttribute('for'))));
|
|
224
|
-
expect(uniqueIds).toHaveLength(6);
|
|
224
|
+
(0, _vitest.expect)(uniqueIds).toHaveLength(6);
|
|
225
225
|
});
|
|
226
226
|
});
|
|
@@ -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 { CheckboxEditor } from './CheckboxEditor';
|
|
6
6
|
configure({
|
|
7
7
|
testIdAttribute: 'data-test-id'
|
|
@@ -65,8 +65,8 @@ describe('CheckboxEditor', ()=>{
|
|
|
65
65
|
'strawberry'
|
|
66
66
|
];
|
|
67
67
|
const [field] = createFakeFieldAPI((mock)=>{
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
vi.spyOn(mock, 'setValue');
|
|
69
|
+
vi.spyOn(mock, 'removeValue');
|
|
70
70
|
return {
|
|
71
71
|
...mock,
|
|
72
72
|
items: {
|
|
@@ -116,8 +116,8 @@ describe('CheckboxEditor', ()=>{
|
|
|
116
116
|
'strawberry'
|
|
117
117
|
];
|
|
118
118
|
const [field] = createFakeFieldAPI((mock)=>{
|
|
119
|
-
|
|
120
|
-
|
|
119
|
+
vi.spyOn(mock, 'setValue');
|
|
120
|
+
vi.spyOn(mock, 'removeValue');
|
|
121
121
|
return {
|
|
122
122
|
...mock,
|
|
123
123
|
items: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-checkbox",
|
|
3
|
-
"version": "2.
|
|
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,20 +31,20 @@
|
|
|
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.
|
|
41
|
+
"@contentful/field-editor-shared": "^4.4.1-canary.5+3e29f973",
|
|
42
42
|
"@emotion/css": "^11.13.5",
|
|
43
43
|
"lodash": "^4.17.15",
|
|
44
44
|
"nanoid": "^3.1.3"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@contentful/field-editor-test-utils": "^3.
|
|
47
|
+
"@contentful/field-editor-test-utils": "^3.1.1-canary.5+3e29f973",
|
|
48
48
|
"@lingui/core": "5.3.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"publishConfig": {
|
|
56
56
|
"registry": "https://npm.pkg.github.com/"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "3e29f9734b46d8ca738457c87cc76a0aeca459e9"
|
|
59
59
|
}
|