@contentful/field-editor-tags 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.
|
@@ -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 _TagsEditorContainer = require("./TagsEditorContainer");
|
|
10
10
|
function _getRequireWildcardCache(nodeInterop) {
|
|
11
11
|
if (typeof WeakMap !== "function") return null;
|
|
@@ -51,23 +51,23 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
51
51
|
(0, _react1.configure)({
|
|
52
52
|
testIdAttribute: 'data-test-id'
|
|
53
53
|
});
|
|
54
|
-
describe('TagsEditor', ()=>{
|
|
55
|
-
afterEach(_react1.cleanup);
|
|
54
|
+
(0, _vitest.describe)('TagsEditor', ()=>{
|
|
55
|
+
(0, _vitest.afterEach)(_react1.cleanup);
|
|
56
56
|
function expectNoConstraints({ queryByTestId }) {
|
|
57
57
|
const $constraints = queryByTestId('tag-editor-constraints');
|
|
58
|
-
expect($constraints).not.toBeInTheDocument();
|
|
58
|
+
(0, _vitest.expect)($constraints).not.toBeInTheDocument();
|
|
59
59
|
}
|
|
60
60
|
function expectInputValue({ getByTestId }, expected) {
|
|
61
61
|
const $input = getByTestId('tag-editor-input');
|
|
62
|
-
expect($input).toHaveValue(expected);
|
|
62
|
+
(0, _vitest.expect)($input).toHaveValue(expected);
|
|
63
63
|
}
|
|
64
64
|
function expectTagsCount({ queryAllByTestId }, expectedCount) {
|
|
65
65
|
const $values = queryAllByTestId('tag-editor-pill');
|
|
66
|
-
expect($values).toHaveLength(expectedCount);
|
|
66
|
+
(0, _vitest.expect)($values).toHaveLength(expectedCount);
|
|
67
67
|
}
|
|
68
68
|
function expectTag({ queryAllByTestId }, index, content) {
|
|
69
69
|
const $values = queryAllByTestId('tag-editor-pill');
|
|
70
|
-
expect($values[index].textContent).toEqual(content);
|
|
70
|
+
(0, _vitest.expect)($values[index].textContent).toEqual(content);
|
|
71
71
|
}
|
|
72
72
|
function typePendingValueAndHitEnter({ getByTestId }, value) {
|
|
73
73
|
const $input = getByTestId('tag-editor-input');
|
|
@@ -83,7 +83,7 @@ describe('TagsEditor', ()=>{
|
|
|
83
83
|
function clickRemoveTag({ getAllByTestId }, index) {
|
|
84
84
|
_react1.fireEvent.click(getAllByTestId('tag-editor-pill')[index].querySelector('button'));
|
|
85
85
|
}
|
|
86
|
-
it('renders empty value properly', ()=>{
|
|
86
|
+
(0, _vitest.it)('renders empty value properly', ()=>{
|
|
87
87
|
const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((mock)=>{
|
|
88
88
|
return {
|
|
89
89
|
...mock,
|
|
@@ -98,7 +98,7 @@ describe('TagsEditor', ()=>{
|
|
|
98
98
|
expectInputValue(renderResult, '');
|
|
99
99
|
expectTagsCount(renderResult, 0);
|
|
100
100
|
});
|
|
101
|
-
it('renders non-empty value properly', ()=>{
|
|
101
|
+
(0, _vitest.it)('renders non-empty value properly', ()=>{
|
|
102
102
|
const initialValue = [
|
|
103
103
|
'test1',
|
|
104
104
|
'test2',
|
|
@@ -121,7 +121,7 @@ describe('TagsEditor', ()=>{
|
|
|
121
121
|
expectTag(renderResult, 1, 'test2');
|
|
122
122
|
expectTag(renderResult, 2, 'test3');
|
|
123
123
|
});
|
|
124
|
-
describe('renders constraints message', ()=>{
|
|
124
|
+
(0, _vitest.describe)('renders constraints message', ()=>{
|
|
125
125
|
const conditions = [
|
|
126
126
|
{
|
|
127
127
|
testType: 'max',
|
|
@@ -169,7 +169,7 @@ describe('TagsEditor', ()=>{
|
|
|
169
169
|
}
|
|
170
170
|
];
|
|
171
171
|
conditions.forEach((condition)=>{
|
|
172
|
-
it(condition.testType, ()=>{
|
|
172
|
+
(0, _vitest.it)(condition.testType, ()=>{
|
|
173
173
|
const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((mock)=>{
|
|
174
174
|
return {
|
|
175
175
|
...mock,
|
|
@@ -185,14 +185,14 @@ describe('TagsEditor', ()=>{
|
|
|
185
185
|
isInitiallyDisabled: false
|
|
186
186
|
}));
|
|
187
187
|
const $constraints = getByTestId('tag-editor-constraints');
|
|
188
|
-
expect($constraints.textContent).toEqual(condition.expected);
|
|
188
|
+
(0, _vitest.expect)($constraints.textContent).toEqual(condition.expected);
|
|
189
189
|
});
|
|
190
190
|
});
|
|
191
191
|
});
|
|
192
|
-
it('adds and removes values', ()=>{
|
|
192
|
+
(0, _vitest.it)('adds and removes values', ()=>{
|
|
193
193
|
const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((field)=>{
|
|
194
|
-
|
|
195
|
-
|
|
194
|
+
_vitest.vi.spyOn(field, 'setValue');
|
|
195
|
+
_vitest.vi.spyOn(field, 'removeValue');
|
|
196
196
|
return {
|
|
197
197
|
...field,
|
|
198
198
|
validations: []
|
|
@@ -203,26 +203,26 @@ describe('TagsEditor', ()=>{
|
|
|
203
203
|
isInitiallyDisabled: false
|
|
204
204
|
}));
|
|
205
205
|
typePendingValueAndHitEnter(renderResult, 'first item');
|
|
206
|
-
expect(field.setValue).toHaveBeenCalledWith([
|
|
206
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenCalledWith([
|
|
207
207
|
'first item'
|
|
208
208
|
]);
|
|
209
|
-
expect(field.setValue).toHaveBeenCalledTimes(1);
|
|
210
|
-
expect(field.removeValue).toHaveBeenCalledTimes(0);
|
|
209
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenCalledTimes(1);
|
|
210
|
+
(0, _vitest.expect)(field.removeValue).toHaveBeenCalledTimes(0);
|
|
211
211
|
expectInputValue(renderResult, '');
|
|
212
212
|
typePendingValueAndHitEnter(renderResult, 'second item');
|
|
213
|
-
expect(field.setValue).toHaveBeenCalledWith([
|
|
213
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenCalledWith([
|
|
214
214
|
'first item',
|
|
215
215
|
'second item'
|
|
216
216
|
]);
|
|
217
|
-
expect(field.setValue).toHaveBeenCalledTimes(2);
|
|
217
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenCalledTimes(2);
|
|
218
218
|
expectInputValue(renderResult, '');
|
|
219
219
|
clickRemoveTag(renderResult, 0);
|
|
220
|
-
expect(field.setValue).toHaveBeenCalledWith([
|
|
220
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenCalledWith([
|
|
221
221
|
'second item'
|
|
222
222
|
]);
|
|
223
|
-
expect(field.setValue).toHaveBeenCalledTimes(3);
|
|
223
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenCalledTimes(3);
|
|
224
224
|
clickRemoveTag(renderResult, 0);
|
|
225
|
-
expect(field.setValue).toHaveBeenCalledTimes(3);
|
|
226
|
-
expect(field.removeValue).toHaveBeenCalledTimes(1);
|
|
225
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenCalledTimes(3);
|
|
226
|
+
(0, _vitest.expect)(field.removeValue).toHaveBeenCalledTimes(1);
|
|
227
227
|
});
|
|
228
228
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { createFakeFieldAPI } 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 { TagsEditorContainer } from './TagsEditorContainer';
|
|
6
6
|
configure({
|
|
7
7
|
testIdAttribute: 'data-test-id'
|
|
@@ -146,8 +146,8 @@ describe('TagsEditor', ()=>{
|
|
|
146
146
|
});
|
|
147
147
|
it('adds and removes values', ()=>{
|
|
148
148
|
const [field] = createFakeFieldAPI((field)=>{
|
|
149
|
-
|
|
150
|
-
|
|
149
|
+
vi.spyOn(field, 'setValue');
|
|
150
|
+
vi.spyOn(field, 'removeValue');
|
|
151
151
|
return {
|
|
152
152
|
...field,
|
|
153
153
|
validations: []
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-tags",
|
|
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,15 +31,15 @@
|
|
|
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 --passWithNoTests",
|
|
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-shared": "^4.4.
|
|
42
|
+
"@contentful/field-editor-shared": "^4.4.1",
|
|
43
43
|
"@dnd-kit/core": "^6.0.8",
|
|
44
44
|
"@dnd-kit/modifiers": "^7.0.0",
|
|
45
45
|
"@dnd-kit/sortable": "^8.0.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"lodash": "^4.17.15"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@contentful/field-editor-test-utils": "^3.1.
|
|
51
|
+
"@contentful/field-editor-test-utils": "^3.1.1",
|
|
52
52
|
"@lingui/core": "5.3.0"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"publishConfig": {
|
|
60
60
|
"registry": "https://npm.pkg.github.com/"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "5fb6c32d2590e72e56a53cb180a155f84d6505d9"
|
|
63
63
|
}
|