@contentful/field-editor-date 2.0.12-canary.3 → 2.0.13-canary.0
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.
|
@@ -5,7 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
6
6
|
require("@testing-library/jest-dom/extend-expect");
|
|
7
7
|
const _react1 = require("@testing-library/react");
|
|
8
|
+
const _userevent = /*#__PURE__*/ _interop_require_default(require("@testing-library/user-event"));
|
|
8
9
|
const _TimepickerInput = require("./TimepickerInput");
|
|
10
|
+
function _interop_require_default(obj) {
|
|
11
|
+
return obj && obj.__esModule ? obj : {
|
|
12
|
+
default: obj
|
|
13
|
+
};
|
|
14
|
+
}
|
|
9
15
|
function _getRequireWildcardCache(nodeInterop) {
|
|
10
16
|
if (typeof WeakMap !== "function") return null;
|
|
11
17
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -82,14 +88,9 @@ describe('TimepickerInput', ()=>{
|
|
|
82
88
|
ampm: "PM",
|
|
83
89
|
onChange: onChange
|
|
84
90
|
}));
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
target: {
|
|
89
|
-
value: '19:00'
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
_react1.fireEvent.blur(input);
|
|
91
|
+
_userevent.default.clear(getByTestId('time-input'));
|
|
92
|
+
_userevent.default.type(getByTestId('time-input'), '19:00');
|
|
93
|
+
_userevent.default.tab();
|
|
93
94
|
expect(onChange).toHaveBeenCalledWith({
|
|
94
95
|
time: '19:00',
|
|
95
96
|
ampm: 'PM'
|
|
@@ -104,14 +105,9 @@ describe('TimepickerInput', ()=>{
|
|
|
104
105
|
ampm: "PM",
|
|
105
106
|
onChange: onChange
|
|
106
107
|
}));
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
target: {
|
|
111
|
-
value: '23:59'
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
_react1.fireEvent.blur(input);
|
|
108
|
+
_userevent.default.clear(getByTestId('time-input'));
|
|
109
|
+
_userevent.default.type(getByTestId('time-input'), '23:59');
|
|
110
|
+
_userevent.default.tab();
|
|
115
111
|
expect(onChange).toHaveBeenCalledWith({
|
|
116
112
|
time: '23:59',
|
|
117
113
|
ampm: 'PM'
|
|
@@ -126,14 +122,9 @@ describe('TimepickerInput', ()=>{
|
|
|
126
122
|
ampm: "AM",
|
|
127
123
|
onChange: onChange
|
|
128
124
|
}));
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
target: {
|
|
133
|
-
value: '00:00'
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
_react1.fireEvent.blur(input);
|
|
125
|
+
_userevent.default.clear(getByTestId('time-input'));
|
|
126
|
+
_userevent.default.type(getByTestId('time-input'), '00:00');
|
|
127
|
+
_userevent.default.tab();
|
|
137
128
|
expect(onChange).toHaveBeenCalledWith({
|
|
138
129
|
time: '00:00',
|
|
139
130
|
ampm: 'AM'
|
|
@@ -148,14 +139,9 @@ describe('TimepickerInput', ()=>{
|
|
|
148
139
|
ampm: "PM",
|
|
149
140
|
onChange: onChange
|
|
150
141
|
}));
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
target: {
|
|
155
|
-
value: '12:00'
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
_react1.fireEvent.blur(input);
|
|
142
|
+
_userevent.default.clear(getByTestId('time-input'));
|
|
143
|
+
_userevent.default.type(getByTestId('time-input'), '12:00');
|
|
144
|
+
_userevent.default.tab();
|
|
159
145
|
expect(onChange).toHaveBeenCalledWith({
|
|
160
146
|
time: '12:00',
|
|
161
147
|
ampm: 'PM'
|
|
@@ -170,20 +156,68 @@ describe('TimepickerInput', ()=>{
|
|
|
170
156
|
ampm: "PM",
|
|
171
157
|
onChange: onChange
|
|
172
158
|
}));
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
target: {
|
|
177
|
-
value: '13:00'
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
_react1.fireEvent.blur(input);
|
|
159
|
+
_userevent.default.clear(getByTestId('time-input'));
|
|
160
|
+
_userevent.default.type(getByTestId('time-input'), '13:00');
|
|
161
|
+
_userevent.default.tab();
|
|
181
162
|
expect(onChange).toHaveBeenCalledWith({
|
|
182
163
|
time: '13:00',
|
|
183
164
|
ampm: 'PM'
|
|
184
165
|
});
|
|
185
166
|
});
|
|
186
167
|
});
|
|
168
|
+
describe('shorthand input without colon', ()=>{
|
|
169
|
+
it('parses 1005 as 10:05 in 24h mode', ()=>{
|
|
170
|
+
const onChange = jest.fn();
|
|
171
|
+
const { getByTestId } = (0, _react1.render)(/*#__PURE__*/ _react.createElement(_TimepickerInput.TimepickerInput, {
|
|
172
|
+
disabled: false,
|
|
173
|
+
uses12hClock: false,
|
|
174
|
+
time: "00:00",
|
|
175
|
+
ampm: "AM",
|
|
176
|
+
onChange: onChange
|
|
177
|
+
}));
|
|
178
|
+
_userevent.default.clear(getByTestId('time-input'));
|
|
179
|
+
_userevent.default.type(getByTestId('time-input'), '1005');
|
|
180
|
+
_userevent.default.tab();
|
|
181
|
+
expect(onChange).toHaveBeenCalledWith({
|
|
182
|
+
time: '10:05',
|
|
183
|
+
ampm: 'AM'
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
it('parses 1900 as 19:00 in 24h mode', ()=>{
|
|
187
|
+
const onChange = jest.fn();
|
|
188
|
+
const { getByTestId } = (0, _react1.render)(/*#__PURE__*/ _react.createElement(_TimepickerInput.TimepickerInput, {
|
|
189
|
+
disabled: false,
|
|
190
|
+
uses12hClock: false,
|
|
191
|
+
time: "00:00",
|
|
192
|
+
ampm: "AM",
|
|
193
|
+
onChange: onChange
|
|
194
|
+
}));
|
|
195
|
+
_userevent.default.clear(getByTestId('time-input'));
|
|
196
|
+
_userevent.default.type(getByTestId('time-input'), '1900');
|
|
197
|
+
_userevent.default.tab();
|
|
198
|
+
expect(onChange).toHaveBeenCalledWith({
|
|
199
|
+
time: '19:00',
|
|
200
|
+
ampm: 'PM'
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
it('parses 0700 as 07:00 AM in 12h mode', ()=>{
|
|
204
|
+
const onChange = jest.fn();
|
|
205
|
+
const { getByTestId } = (0, _react1.render)(/*#__PURE__*/ _react.createElement(_TimepickerInput.TimepickerInput, {
|
|
206
|
+
disabled: false,
|
|
207
|
+
uses12hClock: true,
|
|
208
|
+
time: "12:00",
|
|
209
|
+
ampm: "AM",
|
|
210
|
+
onChange: onChange
|
|
211
|
+
}));
|
|
212
|
+
_userevent.default.clear(getByTestId('time-input'));
|
|
213
|
+
_userevent.default.type(getByTestId('time-input'), '0700');
|
|
214
|
+
_userevent.default.tab();
|
|
215
|
+
expect(onChange).toHaveBeenCalledWith({
|
|
216
|
+
time: '07:00',
|
|
217
|
+
ampm: 'AM'
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
});
|
|
187
221
|
describe('onChange on blur — 12h mode', ()=>{
|
|
188
222
|
it('emits 07:00 AM correctly in 12h mode', ()=>{
|
|
189
223
|
const onChange = jest.fn();
|
|
@@ -194,14 +228,9 @@ describe('TimepickerInput', ()=>{
|
|
|
194
228
|
ampm: "AM",
|
|
195
229
|
onChange: onChange
|
|
196
230
|
}));
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
target: {
|
|
201
|
-
value: '07:00 AM'
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
_react1.fireEvent.blur(input);
|
|
231
|
+
_userevent.default.clear(getByTestId('time-input'));
|
|
232
|
+
_userevent.default.type(getByTestId('time-input'), '07:00 AM');
|
|
233
|
+
_userevent.default.tab();
|
|
205
234
|
expect(onChange).toHaveBeenCalledWith({
|
|
206
235
|
time: '07:00',
|
|
207
236
|
ampm: 'AM'
|
|
@@ -216,14 +245,9 @@ describe('TimepickerInput', ()=>{
|
|
|
216
245
|
ampm: "PM",
|
|
217
246
|
onChange: onChange
|
|
218
247
|
}));
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
target: {
|
|
223
|
-
value: '07:00 PM'
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
_react1.fireEvent.blur(input);
|
|
248
|
+
_userevent.default.clear(getByTestId('time-input'));
|
|
249
|
+
_userevent.default.type(getByTestId('time-input'), '07:00 PM');
|
|
250
|
+
_userevent.default.tab();
|
|
227
251
|
expect(onChange).toHaveBeenCalledWith({
|
|
228
252
|
time: '07:00',
|
|
229
253
|
ampm: 'PM'
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import '@testing-library/jest-dom/extend-expect';
|
|
3
|
-
import { cleanup, configure,
|
|
3
|
+
import { cleanup, configure, render } from '@testing-library/react';
|
|
4
|
+
import userEvent from '@testing-library/user-event';
|
|
4
5
|
import { TimepickerInput } from './TimepickerInput';
|
|
5
6
|
configure({
|
|
6
7
|
testIdAttribute: 'data-test-id'
|
|
@@ -37,14 +38,9 @@ describe('TimepickerInput', ()=>{
|
|
|
37
38
|
ampm: "PM",
|
|
38
39
|
onChange: onChange
|
|
39
40
|
}));
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
target: {
|
|
44
|
-
value: '19:00'
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
fireEvent.blur(input);
|
|
41
|
+
userEvent.clear(getByTestId('time-input'));
|
|
42
|
+
userEvent.type(getByTestId('time-input'), '19:00');
|
|
43
|
+
userEvent.tab();
|
|
48
44
|
expect(onChange).toHaveBeenCalledWith({
|
|
49
45
|
time: '19:00',
|
|
50
46
|
ampm: 'PM'
|
|
@@ -59,14 +55,9 @@ describe('TimepickerInput', ()=>{
|
|
|
59
55
|
ampm: "PM",
|
|
60
56
|
onChange: onChange
|
|
61
57
|
}));
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
target: {
|
|
66
|
-
value: '23:59'
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
fireEvent.blur(input);
|
|
58
|
+
userEvent.clear(getByTestId('time-input'));
|
|
59
|
+
userEvent.type(getByTestId('time-input'), '23:59');
|
|
60
|
+
userEvent.tab();
|
|
70
61
|
expect(onChange).toHaveBeenCalledWith({
|
|
71
62
|
time: '23:59',
|
|
72
63
|
ampm: 'PM'
|
|
@@ -81,14 +72,9 @@ describe('TimepickerInput', ()=>{
|
|
|
81
72
|
ampm: "AM",
|
|
82
73
|
onChange: onChange
|
|
83
74
|
}));
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
target: {
|
|
88
|
-
value: '00:00'
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
fireEvent.blur(input);
|
|
75
|
+
userEvent.clear(getByTestId('time-input'));
|
|
76
|
+
userEvent.type(getByTestId('time-input'), '00:00');
|
|
77
|
+
userEvent.tab();
|
|
92
78
|
expect(onChange).toHaveBeenCalledWith({
|
|
93
79
|
time: '00:00',
|
|
94
80
|
ampm: 'AM'
|
|
@@ -103,14 +89,9 @@ describe('TimepickerInput', ()=>{
|
|
|
103
89
|
ampm: "PM",
|
|
104
90
|
onChange: onChange
|
|
105
91
|
}));
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
target: {
|
|
110
|
-
value: '12:00'
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
fireEvent.blur(input);
|
|
92
|
+
userEvent.clear(getByTestId('time-input'));
|
|
93
|
+
userEvent.type(getByTestId('time-input'), '12:00');
|
|
94
|
+
userEvent.tab();
|
|
114
95
|
expect(onChange).toHaveBeenCalledWith({
|
|
115
96
|
time: '12:00',
|
|
116
97
|
ampm: 'PM'
|
|
@@ -125,20 +106,68 @@ describe('TimepickerInput', ()=>{
|
|
|
125
106
|
ampm: "PM",
|
|
126
107
|
onChange: onChange
|
|
127
108
|
}));
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
target: {
|
|
132
|
-
value: '13:00'
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
fireEvent.blur(input);
|
|
109
|
+
userEvent.clear(getByTestId('time-input'));
|
|
110
|
+
userEvent.type(getByTestId('time-input'), '13:00');
|
|
111
|
+
userEvent.tab();
|
|
136
112
|
expect(onChange).toHaveBeenCalledWith({
|
|
137
113
|
time: '13:00',
|
|
138
114
|
ampm: 'PM'
|
|
139
115
|
});
|
|
140
116
|
});
|
|
141
117
|
});
|
|
118
|
+
describe('shorthand input without colon', ()=>{
|
|
119
|
+
it('parses 1005 as 10:05 in 24h mode', ()=>{
|
|
120
|
+
const onChange = jest.fn();
|
|
121
|
+
const { getByTestId } = render(/*#__PURE__*/ React.createElement(TimepickerInput, {
|
|
122
|
+
disabled: false,
|
|
123
|
+
uses12hClock: false,
|
|
124
|
+
time: "00:00",
|
|
125
|
+
ampm: "AM",
|
|
126
|
+
onChange: onChange
|
|
127
|
+
}));
|
|
128
|
+
userEvent.clear(getByTestId('time-input'));
|
|
129
|
+
userEvent.type(getByTestId('time-input'), '1005');
|
|
130
|
+
userEvent.tab();
|
|
131
|
+
expect(onChange).toHaveBeenCalledWith({
|
|
132
|
+
time: '10:05',
|
|
133
|
+
ampm: 'AM'
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
it('parses 1900 as 19:00 in 24h mode', ()=>{
|
|
137
|
+
const onChange = jest.fn();
|
|
138
|
+
const { getByTestId } = render(/*#__PURE__*/ React.createElement(TimepickerInput, {
|
|
139
|
+
disabled: false,
|
|
140
|
+
uses12hClock: false,
|
|
141
|
+
time: "00:00",
|
|
142
|
+
ampm: "AM",
|
|
143
|
+
onChange: onChange
|
|
144
|
+
}));
|
|
145
|
+
userEvent.clear(getByTestId('time-input'));
|
|
146
|
+
userEvent.type(getByTestId('time-input'), '1900');
|
|
147
|
+
userEvent.tab();
|
|
148
|
+
expect(onChange).toHaveBeenCalledWith({
|
|
149
|
+
time: '19:00',
|
|
150
|
+
ampm: 'PM'
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
it('parses 0700 as 07:00 AM in 12h mode', ()=>{
|
|
154
|
+
const onChange = jest.fn();
|
|
155
|
+
const { getByTestId } = render(/*#__PURE__*/ React.createElement(TimepickerInput, {
|
|
156
|
+
disabled: false,
|
|
157
|
+
uses12hClock: true,
|
|
158
|
+
time: "12:00",
|
|
159
|
+
ampm: "AM",
|
|
160
|
+
onChange: onChange
|
|
161
|
+
}));
|
|
162
|
+
userEvent.clear(getByTestId('time-input'));
|
|
163
|
+
userEvent.type(getByTestId('time-input'), '0700');
|
|
164
|
+
userEvent.tab();
|
|
165
|
+
expect(onChange).toHaveBeenCalledWith({
|
|
166
|
+
time: '07:00',
|
|
167
|
+
ampm: 'AM'
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
});
|
|
142
171
|
describe('onChange on blur — 12h mode', ()=>{
|
|
143
172
|
it('emits 07:00 AM correctly in 12h mode', ()=>{
|
|
144
173
|
const onChange = jest.fn();
|
|
@@ -149,14 +178,9 @@ describe('TimepickerInput', ()=>{
|
|
|
149
178
|
ampm: "AM",
|
|
150
179
|
onChange: onChange
|
|
151
180
|
}));
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
target: {
|
|
156
|
-
value: '07:00 AM'
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
fireEvent.blur(input);
|
|
181
|
+
userEvent.clear(getByTestId('time-input'));
|
|
182
|
+
userEvent.type(getByTestId('time-input'), '07:00 AM');
|
|
183
|
+
userEvent.tab();
|
|
160
184
|
expect(onChange).toHaveBeenCalledWith({
|
|
161
185
|
time: '07:00',
|
|
162
186
|
ampm: 'AM'
|
|
@@ -171,14 +195,9 @@ describe('TimepickerInput', ()=>{
|
|
|
171
195
|
ampm: "PM",
|
|
172
196
|
onChange: onChange
|
|
173
197
|
}));
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
target: {
|
|
178
|
-
value: '07:00 PM'
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
fireEvent.blur(input);
|
|
198
|
+
userEvent.clear(getByTestId('time-input'));
|
|
199
|
+
userEvent.type(getByTestId('time-input'), '07:00 PM');
|
|
200
|
+
userEvent.tab();
|
|
182
201
|
expect(onChange).toHaveBeenCalledWith({
|
|
183
202
|
time: '07:00',
|
|
184
203
|
ampm: 'PM'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-date",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.13-canary.0+176e857e",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"publishConfig": {
|
|
58
58
|
"registry": "https://npm.pkg.github.com/"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "176e857ee4418a9298214f8696b1c6adbebda0bb"
|
|
61
61
|
}
|