@contentful/field-editor-rating 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.
|
@@ -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 _RatingEditor = require("./RatingEditor");
|
|
10
10
|
function _getRequireWildcardCache(nodeInterop) {
|
|
11
11
|
if (typeof WeakMap !== "function") return null;
|
|
@@ -51,17 +51,17 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
51
51
|
(0, _react1.configure)({
|
|
52
52
|
testIdAttribute: 'data-test-id'
|
|
53
53
|
});
|
|
54
|
-
describe('RatingEditor', ()=>{
|
|
55
|
-
afterEach(_react1.cleanup);
|
|
56
|
-
it('renders 5 stars by default', ()=>{
|
|
54
|
+
(0, _vitest.describe)('RatingEditor', ()=>{
|
|
55
|
+
(0, _vitest.afterEach)(_react1.cleanup);
|
|
56
|
+
(0, _vitest.it)('renders 5 stars by default', ()=>{
|
|
57
57
|
const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)();
|
|
58
58
|
const { getAllByTestId } = (0, _react1.render)(/*#__PURE__*/ _react.createElement(_RatingEditor.RatingEditor, {
|
|
59
59
|
field: field,
|
|
60
60
|
isInitiallyDisabled: false
|
|
61
61
|
}));
|
|
62
|
-
expect(getAllByTestId('rating-editor-star')).toHaveLength(5);
|
|
62
|
+
(0, _vitest.expect)(getAllByTestId('rating-editor-star')).toHaveLength(5);
|
|
63
63
|
});
|
|
64
|
-
it('renders custom number of stars', ()=>{
|
|
64
|
+
(0, _vitest.it)('renders custom number of stars', ()=>{
|
|
65
65
|
const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)();
|
|
66
66
|
const { getAllByTestId } = (0, _react1.render)(/*#__PURE__*/ _react.createElement(_RatingEditor.RatingEditor, {
|
|
67
67
|
field: field,
|
|
@@ -74,12 +74,12 @@ describe('RatingEditor', ()=>{
|
|
|
74
74
|
invocation: {}
|
|
75
75
|
}
|
|
76
76
|
}));
|
|
77
|
-
expect(getAllByTestId('rating-editor-star')).toHaveLength(20);
|
|
77
|
+
(0, _vitest.expect)(getAllByTestId('rating-editor-star')).toHaveLength(20);
|
|
78
78
|
});
|
|
79
|
-
it('should setValue by clicking on a item and removeValue by clicking on clear', ()=>{
|
|
79
|
+
(0, _vitest.it)('should setValue by clicking on a item and removeValue by clicking on clear', ()=>{
|
|
80
80
|
const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((field)=>{
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
_vitest.vi.spyOn(field, 'setValue');
|
|
82
|
+
_vitest.vi.spyOn(field, 'removeValue');
|
|
83
83
|
return {
|
|
84
84
|
...field
|
|
85
85
|
};
|
|
@@ -89,24 +89,24 @@ describe('RatingEditor', ()=>{
|
|
|
89
89
|
isInitiallyDisabled: false
|
|
90
90
|
}));
|
|
91
91
|
const $stars = getAllByTestId('rating-editor-star');
|
|
92
|
-
expect(queryByTestId('rating-editor-clean')).not.toBeInTheDocument();
|
|
93
|
-
expect(container.querySelectorAll('[data-selected="true"]')).toHaveLength(0);
|
|
94
|
-
expect(container.querySelectorAll('[data-selected="false"]')).toHaveLength(5);
|
|
92
|
+
(0, _vitest.expect)(queryByTestId('rating-editor-clean')).not.toBeInTheDocument();
|
|
93
|
+
(0, _vitest.expect)(container.querySelectorAll('[data-selected="true"]')).toHaveLength(0);
|
|
94
|
+
(0, _vitest.expect)(container.querySelectorAll('[data-selected="false"]')).toHaveLength(5);
|
|
95
95
|
_react1.fireEvent.mouseDown($stars[4]);
|
|
96
|
-
expect(field.setValue).toHaveBeenCalledWith(5);
|
|
97
|
-
expect(container.querySelectorAll('[data-selected="true"]')).toHaveLength(5);
|
|
98
|
-
expect(container.querySelectorAll('[data-selected="false"]')).toHaveLength(0);
|
|
96
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenCalledWith(5);
|
|
97
|
+
(0, _vitest.expect)(container.querySelectorAll('[data-selected="true"]')).toHaveLength(5);
|
|
98
|
+
(0, _vitest.expect)(container.querySelectorAll('[data-selected="false"]')).toHaveLength(0);
|
|
99
99
|
_react1.fireEvent.mouseDown($stars[0]);
|
|
100
|
-
expect(field.setValue).toHaveBeenCalledWith(1);
|
|
101
|
-
expect(container.querySelectorAll('[data-selected="true"]')).toHaveLength(1);
|
|
102
|
-
expect(container.querySelectorAll('[data-selected="false"]')).toHaveLength(4);
|
|
100
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenCalledWith(1);
|
|
101
|
+
(0, _vitest.expect)(container.querySelectorAll('[data-selected="true"]')).toHaveLength(1);
|
|
102
|
+
(0, _vitest.expect)(container.querySelectorAll('[data-selected="false"]')).toHaveLength(4);
|
|
103
103
|
_react1.fireEvent.click(getByTestId('rating-editor-clear'));
|
|
104
|
-
expect(field.removeValue).toHaveBeenCalled();
|
|
104
|
+
(0, _vitest.expect)(field.removeValue).toHaveBeenCalled();
|
|
105
105
|
});
|
|
106
|
-
it('should should setValue by focusing and using Enter', ()=>{
|
|
106
|
+
(0, _vitest.it)('should should setValue by focusing and using Enter', ()=>{
|
|
107
107
|
const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((field)=>{
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
_vitest.vi.spyOn(field, 'setValue');
|
|
109
|
+
_vitest.vi.spyOn(field, 'removeValue');
|
|
110
110
|
return {
|
|
111
111
|
...field
|
|
112
112
|
};
|
|
@@ -116,24 +116,24 @@ describe('RatingEditor', ()=>{
|
|
|
116
116
|
isInitiallyDisabled: false
|
|
117
117
|
}));
|
|
118
118
|
const $stars = getAllByTestId('rating-editor-star');
|
|
119
|
-
expect(queryByTestId('rating-editor-clean')).not.toBeInTheDocument();
|
|
120
|
-
expect(container.querySelectorAll('[data-selected="true"]')).toHaveLength(0);
|
|
121
|
-
expect(container.querySelectorAll('[data-selected="false"]')).toHaveLength(5);
|
|
119
|
+
(0, _vitest.expect)(queryByTestId('rating-editor-clean')).not.toBeInTheDocument();
|
|
120
|
+
(0, _vitest.expect)(container.querySelectorAll('[data-selected="true"]')).toHaveLength(0);
|
|
121
|
+
(0, _vitest.expect)(container.querySelectorAll('[data-selected="false"]')).toHaveLength(5);
|
|
122
122
|
_react1.fireEvent.focus($stars[2]);
|
|
123
|
-
expect(container.querySelectorAll('[data-selected="true"]')).toHaveLength(3);
|
|
124
|
-
expect(container.querySelectorAll('[data-selected="false"]')).toHaveLength(2);
|
|
123
|
+
(0, _vitest.expect)(container.querySelectorAll('[data-selected="true"]')).toHaveLength(3);
|
|
124
|
+
(0, _vitest.expect)(container.querySelectorAll('[data-selected="false"]')).toHaveLength(2);
|
|
125
125
|
_react1.fireEvent.keyDown($stars[2], {
|
|
126
126
|
keyCode: 13
|
|
127
127
|
});
|
|
128
|
-
expect(field.setValue).toHaveBeenCalledTimes(1);
|
|
129
|
-
expect(field.setValue).toHaveBeenCalledWith(3);
|
|
128
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenCalledTimes(1);
|
|
129
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenCalledWith(3);
|
|
130
130
|
_react1.fireEvent.focus($stars[4]);
|
|
131
|
-
expect(container.querySelectorAll('[data-selected="true"]')).toHaveLength(5);
|
|
132
|
-
expect(container.querySelectorAll('[data-selected="false"]')).toHaveLength(0);
|
|
131
|
+
(0, _vitest.expect)(container.querySelectorAll('[data-selected="true"]')).toHaveLength(5);
|
|
132
|
+
(0, _vitest.expect)(container.querySelectorAll('[data-selected="false"]')).toHaveLength(0);
|
|
133
133
|
_react1.fireEvent.keyDown($stars[4], {
|
|
134
134
|
keyCode: 13
|
|
135
135
|
});
|
|
136
|
-
expect(field.setValue).toHaveBeenCalledTimes(2);
|
|
137
|
-
expect(field.setValue).toHaveBeenCalledWith(5);
|
|
136
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenCalledTimes(2);
|
|
137
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenCalledWith(5);
|
|
138
138
|
});
|
|
139
139
|
});
|
|
@@ -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 { RatingEditor } from './RatingEditor';
|
|
6
6
|
configure({
|
|
7
7
|
testIdAttribute: 'data-test-id'
|
|
@@ -33,8 +33,8 @@ describe('RatingEditor', ()=>{
|
|
|
33
33
|
});
|
|
34
34
|
it('should setValue by clicking on a item and removeValue by clicking on clear', ()=>{
|
|
35
35
|
const [field] = createFakeFieldAPI((field)=>{
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
vi.spyOn(field, 'setValue');
|
|
37
|
+
vi.spyOn(field, 'removeValue');
|
|
38
38
|
return {
|
|
39
39
|
...field
|
|
40
40
|
};
|
|
@@ -60,8 +60,8 @@ describe('RatingEditor', ()=>{
|
|
|
60
60
|
});
|
|
61
61
|
it('should should setValue by focusing and using Enter', ()=>{
|
|
62
62
|
const [field] = createFakeFieldAPI((field)=>{
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
vi.spyOn(field, 'setValue');
|
|
64
|
+
vi.spyOn(field, 'removeValue');
|
|
65
65
|
return {
|
|
66
66
|
...field
|
|
67
67
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-rating",
|
|
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,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-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-canary.5+3e29f973",
|
|
43
43
|
"@emotion/css": "^11.13.5",
|
|
44
44
|
"lodash": "^4.17.15"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@contentful/field-editor-test-utils": "^3.1.
|
|
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
|
}
|