@contentful/field-editor-dropdown 3.1.0 → 3.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 _DropdownEditor = require("./DropdownEditor");
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('DropdownEditor', ()=>{
55
- afterEach(_react1.cleanup);
56
- it('renders a warning if no options are present', ()=>{
54
+ (0, _vitest.describe)('DropdownEditor', ()=>{
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('DropdownEditor', ()=>{
65
65
  locales: (0, _fieldeditortestutils.createFakeLocalesAPI)(),
66
66
  isInitiallyDisabled: false
67
67
  }));
68
- expect(getByTestId('predefined-values-warning')).toBeInTheDocument();
69
- expect(queryByTestId('dropdown-editor')).not.toBeInTheDocument();
68
+ (0, _vitest.expect)(getByTestId('predefined-values-warning')).toBeInTheDocument();
69
+ (0, _vitest.expect)(queryByTestId('dropdown-editor')).not.toBeInTheDocument();
70
70
  });
71
- it('renders option tags for predefined values', ()=>{
71
+ (0, _vitest.it)('renders option tags for predefined values', ()=>{
72
72
  const predefined = [
73
73
  'banana',
74
74
  'orange',
@@ -89,16 +89,16 @@ describe('DropdownEditor', ()=>{
89
89
  locales: (0, _fieldeditortestutils.createFakeLocalesAPI)(),
90
90
  isInitiallyDisabled: false
91
91
  }));
92
- expect(container.querySelectorAll('option')).toHaveLength(4);
93
- expect(getByText('Choose a value')).toHaveValue('');
92
+ (0, _vitest.expect)(container.querySelectorAll('option')).toHaveLength(4);
93
+ (0, _vitest.expect)(getByText('Choose a value')).toHaveValue('');
94
94
  predefined.forEach((item)=>{
95
- expect(getByText(item)).toHaveValue(item);
95
+ (0, _vitest.expect)(getByText(item)).toHaveValue(item);
96
96
  });
97
97
  });
98
- it('calls setValue if user select on default option', ()=>{
98
+ (0, _vitest.it)('calls setValue if user select on default option', ()=>{
99
99
  const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((field)=>{
100
- jest.spyOn(field, 'setValue');
101
- jest.spyOn(field, 'removeValue');
100
+ _vitest.vi.spyOn(field, 'setValue');
101
+ _vitest.vi.spyOn(field, 'removeValue');
102
102
  return {
103
103
  ...field,
104
104
  validations: [
@@ -120,14 +120,14 @@ describe('DropdownEditor', ()=>{
120
120
  value
121
121
  }
122
122
  });
123
- expect(getByTestId('dropdown-editor')).toHaveValue('');
123
+ (0, _vitest.expect)(getByTestId('dropdown-editor')).toHaveValue('');
124
124
  changeDropdownValue('initial');
125
- expect(field.setValue).toHaveBeenCalledWith('initial');
126
- expect(field.setValue).toHaveBeenCalledTimes(1);
125
+ (0, _vitest.expect)(field.setValue).toHaveBeenCalledWith('initial');
126
+ (0, _vitest.expect)(field.setValue).toHaveBeenCalledTimes(1);
127
127
  });
128
- it('calls removeValue if user selects default option', ()=>{
128
+ (0, _vitest.it)('calls removeValue if user selects default option', ()=>{
129
129
  const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((field)=>{
130
- jest.spyOn(field, 'removeValue');
130
+ _vitest.vi.spyOn(field, 'removeValue');
131
131
  return {
132
132
  ...field,
133
133
  getValue: ()=>'initial',
@@ -150,19 +150,19 @@ describe('DropdownEditor', ()=>{
150
150
  value
151
151
  }
152
152
  });
153
- expect(getByTestId('dropdown-editor')).toHaveValue('initial');
153
+ (0, _vitest.expect)(getByTestId('dropdown-editor')).toHaveValue('initial');
154
154
  changeDropdownValue('');
155
- expect(field.removeValue).toHaveBeenCalledTimes(1);
155
+ (0, _vitest.expect)(field.removeValue).toHaveBeenCalledTimes(1);
156
156
  });
157
- it('calls #setValue with number for Number fields', function() {
157
+ (0, _vitest.it)('calls #setValue with number for Number fields', function() {
158
158
  const predefined = [
159
159
  1,
160
160
  '2.71',
161
161
  3
162
162
  ];
163
163
  const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((field)=>{
164
- jest.spyOn(field, 'setValue');
165
- jest.spyOn(field, 'removeValue');
164
+ _vitest.vi.spyOn(field, 'setValue');
165
+ _vitest.vi.spyOn(field, 'removeValue');
166
166
  return {
167
167
  ...field,
168
168
  type: 'Number',
@@ -184,13 +184,13 @@ describe('DropdownEditor', ()=>{
184
184
  value
185
185
  }
186
186
  });
187
- expect($editorInput).toHaveValue('');
187
+ (0, _vitest.expect)($editorInput).toHaveValue('');
188
188
  changeDropdownValue('2.71');
189
- expect($editorInput).toHaveValue('2.71');
190
- expect(field.setValue).toHaveBeenCalledWith(2.71);
191
- expect(field.setValue).toHaveBeenCalledTimes(1);
189
+ (0, _vitest.expect)($editorInput).toHaveValue('2.71');
190
+ (0, _vitest.expect)(field.setValue).toHaveBeenCalledWith(2.71);
191
+ (0, _vitest.expect)(field.setValue).toHaveBeenCalledTimes(1);
192
192
  });
193
- it('calls #setValue with number for Integer fields', function() {
193
+ (0, _vitest.it)('calls #setValue with number for Integer fields', function() {
194
194
  const predefined = [
195
195
  0,
196
196
  1,
@@ -198,8 +198,8 @@ describe('DropdownEditor', ()=>{
198
198
  3
199
199
  ];
200
200
  const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((field)=>{
201
- jest.spyOn(field, 'setValue');
202
- jest.spyOn(field, 'removeValue');
201
+ _vitest.vi.spyOn(field, 'setValue');
202
+ _vitest.vi.spyOn(field, 'removeValue');
203
203
  return {
204
204
  ...field,
205
205
  type: 'Number',
@@ -221,14 +221,14 @@ describe('DropdownEditor', ()=>{
221
221
  value
222
222
  }
223
223
  });
224
- expect($editorInput).toHaveValue('');
224
+ (0, _vitest.expect)($editorInput).toHaveValue('');
225
225
  changeDropdownValue('1');
226
- expect(field.setValue).toHaveBeenCalledWith(1);
227
- expect(field.setValue).toHaveBeenCalledTimes(1);
228
- expect($editorInput).toHaveValue('1');
226
+ (0, _vitest.expect)(field.setValue).toHaveBeenCalledWith(1);
227
+ (0, _vitest.expect)(field.setValue).toHaveBeenCalledTimes(1);
228
+ (0, _vitest.expect)($editorInput).toHaveValue('1');
229
229
  changeDropdownValue('0');
230
- expect(field.setValue).toHaveBeenCalledWith(0);
231
- expect(field.setValue).toHaveBeenCalledTimes(2);
232
- expect($editorInput).toHaveValue('0');
230
+ (0, _vitest.expect)(field.setValue).toHaveBeenCalledWith(0);
231
+ (0, _vitest.expect)(field.setValue).toHaveBeenCalledTimes(2);
232
+ (0, _vitest.expect)($editorInput).toHaveValue('0');
233
233
  });
234
234
  });
@@ -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 { DropdownEditor } from './DropdownEditor';
6
6
  configure({
7
7
  testIdAttribute: 'data-test-id'
@@ -52,8 +52,8 @@ describe('DropdownEditor', ()=>{
52
52
  });
53
53
  it('calls setValue if user select on default option', ()=>{
54
54
  const [field] = createFakeFieldAPI((field)=>{
55
- jest.spyOn(field, 'setValue');
56
- jest.spyOn(field, 'removeValue');
55
+ vi.spyOn(field, 'setValue');
56
+ vi.spyOn(field, 'removeValue');
57
57
  return {
58
58
  ...field,
59
59
  validations: [
@@ -82,7 +82,7 @@ describe('DropdownEditor', ()=>{
82
82
  });
83
83
  it('calls removeValue if user selects default option', ()=>{
84
84
  const [field] = createFakeFieldAPI((field)=>{
85
- jest.spyOn(field, 'removeValue');
85
+ vi.spyOn(field, 'removeValue');
86
86
  return {
87
87
  ...field,
88
88
  getValue: ()=>'initial',
@@ -116,8 +116,8 @@ describe('DropdownEditor', ()=>{
116
116
  3
117
117
  ];
118
118
  const [field] = createFakeFieldAPI((field)=>{
119
- jest.spyOn(field, 'setValue');
120
- jest.spyOn(field, 'removeValue');
119
+ vi.spyOn(field, 'setValue');
120
+ vi.spyOn(field, 'removeValue');
121
121
  return {
122
122
  ...field,
123
123
  type: 'Number',
@@ -153,8 +153,8 @@ describe('DropdownEditor', ()=>{
153
153
  3
154
154
  ];
155
155
  const [field] = createFakeFieldAPI((field)=>{
156
- jest.spyOn(field, 'setValue');
157
- jest.spyOn(field, 'removeValue');
156
+ vi.spyOn(field, 'setValue');
157
+ vi.spyOn(field, 'removeValue');
158
158
  return {
159
159
  ...field,
160
160
  type: 'Number',
@@ -1 +1 @@
1
- import '@testing-library/jest-dom/extend-expect';
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/field-editor-dropdown",
3
- "version": "3.1.0",
3
+ "version": "3.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,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": "jest --watch",
35
- "test:ci": "jest --ci --passWithNoTests",
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
- "@contentful/field-editor-shared": "^4.4.0",
40
+ "@contentful/field-editor-shared": "^4.4.1",
41
41
  "@emotion/css": "^11.13.5",
42
42
  "nanoid": "^3.1.3"
43
43
  },
44
44
  "devDependencies": {
45
- "@contentful/field-editor-test-utils": "^3.1.0",
45
+ "@contentful/field-editor-test-utils": "^3.1.1",
46
46
  "@lingui/core": "5.3.0",
47
47
  "contentful-management": "^12.3.0"
48
48
  },
@@ -54,5 +54,5 @@
54
54
  "publishConfig": {
55
55
  "registry": "https://npm.pkg.github.com/"
56
56
  },
57
- "gitHead": "b3a1d791df55536d6de78bb138b97224d6c0c70e"
57
+ "gitHead": "5fb6c32d2590e72e56a53cb180a155f84d6505d9"
58
58
  }