@instructure/ui-date-time-input 9.2.1-snapshot-1 → 9.2.1-snapshot-3
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.
- package/CHANGELOG.md +1 -1
- package/es/DateTimeInput/__new-tests__/DateTimeInput.test.js +16 -12
- package/lib/DateTimeInput/__new-tests__/DateTimeInput.test.js +16 -12
- package/package.json +19 -18
- package/src/DateTimeInput/__new-tests__/DateTimeInput.test.tsx +21 -13
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/DateTimeInput/__new-tests__/DateTimeInput.test.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [9.2.1-snapshot-
|
|
6
|
+
## [9.2.1-snapshot-3](https://github.com/instructure/instructure-ui/compare/v9.2.0...v9.2.1-snapshot-3) (2024-07-12)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @instructure/ui-date-time-input
|
|
9
9
|
|
|
@@ -25,17 +25,21 @@ var _DateTimeInput, _DateTimeInput2, _DateTimeInput3;
|
|
|
25
25
|
|
|
26
26
|
import React from 'react';
|
|
27
27
|
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
|
28
|
+
import { vi } from 'vitest';
|
|
28
29
|
import userEvent from '@testing-library/user-event';
|
|
29
30
|
import '@testing-library/jest-dom';
|
|
30
31
|
import { DateTimeInput } from '../index';
|
|
31
32
|
import { ApplyLocale, DateTime } from '@instructure/ui-i18n';
|
|
32
33
|
describe('<DateTimeInput />', () => {
|
|
34
|
+
let consoleWarningMock;
|
|
33
35
|
let consoleErrorMock;
|
|
34
36
|
beforeEach(() => {
|
|
35
37
|
// Mocking console to prevent test output pollution and expect for messages
|
|
36
|
-
|
|
38
|
+
consoleWarningMock = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
39
|
+
consoleErrorMock = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
37
40
|
});
|
|
38
41
|
afterEach(() => {
|
|
42
|
+
consoleWarningMock.mockRestore();
|
|
39
43
|
consoleErrorMock.mockRestore();
|
|
40
44
|
});
|
|
41
45
|
it('should use the default value', () => {
|
|
@@ -59,7 +63,7 @@ describe('<DateTimeInput />', () => {
|
|
|
59
63
|
expect(timeInput).toHaveValue(dateTime.format('LT'));
|
|
60
64
|
});
|
|
61
65
|
it('should use the value', () => {
|
|
62
|
-
const onChange =
|
|
66
|
+
const onChange = vi.fn();
|
|
63
67
|
const locale = 'en-US';
|
|
64
68
|
const timezone = 'US/Eastern';
|
|
65
69
|
const dateTime = DateTime.parse('2017-05-01T23:30Z', locale, timezone);
|
|
@@ -85,7 +89,7 @@ describe('<DateTimeInput />', () => {
|
|
|
85
89
|
const timezone = 'US/Eastern';
|
|
86
90
|
const value = DateTime.parse('2017-05-01T17:30Z', locale, timezone);
|
|
87
91
|
const defaultValue = DateTime.parse('2016-04-01T17:00Z', locale, timezone);
|
|
88
|
-
const onChange =
|
|
92
|
+
const onChange = vi.fn();
|
|
89
93
|
render( /*#__PURE__*/React.createElement(DateTimeInput, {
|
|
90
94
|
description: "date_time",
|
|
91
95
|
prevMonthLabel: "Previous month",
|
|
@@ -126,7 +130,7 @@ describe('<DateTimeInput />', () => {
|
|
|
126
130
|
expect(timeInput).toHaveValue('12:00 AM');
|
|
127
131
|
});
|
|
128
132
|
it('should call invalidDateTimeMessage if time is set w/o a date and is required', async () => {
|
|
129
|
-
const invalidDateTimeMessage =
|
|
133
|
+
const invalidDateTimeMessage = vi.fn(_rawd => 'whoops');
|
|
130
134
|
const _render = render( /*#__PURE__*/React.createElement(DateTimeInput, {
|
|
131
135
|
description: "date_time",
|
|
132
136
|
dateRenderLabel: "date-input",
|
|
@@ -148,7 +152,7 @@ describe('<DateTimeInput />', () => {
|
|
|
148
152
|
});
|
|
149
153
|
});
|
|
150
154
|
it('should not call invalidDateTimeMessage if time is set w/o a date', async () => {
|
|
151
|
-
const invalidDateTimeMessage =
|
|
155
|
+
const invalidDateTimeMessage = vi.fn(_rawd => 'whoops');
|
|
152
156
|
render( /*#__PURE__*/React.createElement(DateTimeInput, {
|
|
153
157
|
description: "date_time",
|
|
154
158
|
dateRenderLabel: "date-input",
|
|
@@ -168,7 +172,7 @@ describe('<DateTimeInput />', () => {
|
|
|
168
172
|
});
|
|
169
173
|
});
|
|
170
174
|
it('should fire the onChange event when TimeInput value changes', async () => {
|
|
171
|
-
const onChange =
|
|
175
|
+
const onChange = vi.fn();
|
|
172
176
|
const locale = 'en-US';
|
|
173
177
|
const timezone = 'US/Eastern';
|
|
174
178
|
const defaultValue = DateTime.parse('2017-05-01T17:00', locale, timezone);
|
|
@@ -287,7 +291,7 @@ describe('<DateTimeInput />', () => {
|
|
|
287
291
|
expect(timeInput).toEqual(tref);
|
|
288
292
|
});
|
|
289
293
|
it('should update message when value prop changes', () => {
|
|
290
|
-
const onChange =
|
|
294
|
+
const onChange = vi.fn();
|
|
291
295
|
const locale = 'en-US';
|
|
292
296
|
const timezone = 'US/Eastern';
|
|
293
297
|
const dateTime = DateTime.parse('2017-05-01T17:30Z', locale, timezone);
|
|
@@ -313,7 +317,7 @@ describe('<DateTimeInput />', () => {
|
|
|
313
317
|
expect(container).toHaveTextContent('March 29, 2018 12:30 PM');
|
|
314
318
|
});
|
|
315
319
|
it('should update message when locale changed', () => {
|
|
316
|
-
const onChange =
|
|
320
|
+
const onChange = vi.fn();
|
|
317
321
|
const locale = 'en-US';
|
|
318
322
|
const timezone = 'US/Eastern';
|
|
319
323
|
const dateTime = DateTime.parse('2017-05-01T17:30Z', locale, timezone);
|
|
@@ -339,7 +343,7 @@ describe('<DateTimeInput />', () => {
|
|
|
339
343
|
expect(container).toHaveTextContent('1 mai 2017 13:30');
|
|
340
344
|
});
|
|
341
345
|
it('should update message when timezone changed', () => {
|
|
342
|
-
const onChange =
|
|
346
|
+
const onChange = vi.fn();
|
|
343
347
|
const locale = 'en-US';
|
|
344
348
|
const timezone = 'US/Eastern';
|
|
345
349
|
const dateTime = DateTime.parse('2017-05-01T17:30Z', locale, timezone);
|
|
@@ -506,7 +510,7 @@ describe('<DateTimeInput />', () => {
|
|
|
506
510
|
});
|
|
507
511
|
});
|
|
508
512
|
it('should read locale and timezone from context', () => {
|
|
509
|
-
const onChange =
|
|
513
|
+
const onChange = vi.fn();
|
|
510
514
|
const dateTime = DateTime.parse('2017-05-01T17:30Z', 'en-US', 'GMT');
|
|
511
515
|
const _render13 = render(
|
|
512
516
|
/*#__PURE__*/
|
|
@@ -528,7 +532,7 @@ describe('<DateTimeInput />', () => {
|
|
|
528
532
|
expect(container).toHaveTextContent('lundi 1 mai 2017 20:30');
|
|
529
533
|
});
|
|
530
534
|
it('should format date according to dateFormat', async () => {
|
|
531
|
-
const onChange =
|
|
535
|
+
const onChange = vi.fn();
|
|
532
536
|
const dateTime = DateTime.parse('2017-05-01T17:30Z', 'en-US', 'GMT');
|
|
533
537
|
const props = {
|
|
534
538
|
description: 'date_time',
|
|
@@ -555,7 +559,7 @@ describe('<DateTimeInput />', () => {
|
|
|
555
559
|
});
|
|
556
560
|
});
|
|
557
561
|
it('should format bottom message according to messageFormat', async () => {
|
|
558
|
-
const onChange =
|
|
562
|
+
const onChange = vi.fn();
|
|
559
563
|
const dateTime = DateTime.parse('2017-05-01T17:30Z', 'en-US', 'GMT');
|
|
560
564
|
const props = {
|
|
561
565
|
description: 'date_time',
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
var _react = _interopRequireDefault(require("react"));
|
|
5
5
|
var _react2 = require("@testing-library/react");
|
|
6
|
+
var _vitest = require("vitest");
|
|
6
7
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
7
8
|
require("@testing-library/jest-dom");
|
|
8
9
|
var _index = require("../index");
|
|
@@ -33,12 +34,15 @@ var _DateTimeInput, _DateTimeInput2, _DateTimeInput3;
|
|
|
33
34
|
* SOFTWARE.
|
|
34
35
|
*/
|
|
35
36
|
describe('<DateTimeInput />', () => {
|
|
37
|
+
let consoleWarningMock;
|
|
36
38
|
let consoleErrorMock;
|
|
37
39
|
beforeEach(() => {
|
|
38
40
|
// Mocking console to prevent test output pollution and expect for messages
|
|
39
|
-
|
|
41
|
+
consoleWarningMock = _vitest.vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
42
|
+
consoleErrorMock = _vitest.vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
40
43
|
});
|
|
41
44
|
afterEach(() => {
|
|
45
|
+
consoleWarningMock.mockRestore();
|
|
42
46
|
consoleErrorMock.mockRestore();
|
|
43
47
|
});
|
|
44
48
|
it('should use the default value', () => {
|
|
@@ -62,7 +66,7 @@ describe('<DateTimeInput />', () => {
|
|
|
62
66
|
expect(timeInput).toHaveValue(dateTime.format('LT'));
|
|
63
67
|
});
|
|
64
68
|
it('should use the value', () => {
|
|
65
|
-
const onChange =
|
|
69
|
+
const onChange = _vitest.vi.fn();
|
|
66
70
|
const locale = 'en-US';
|
|
67
71
|
const timezone = 'US/Eastern';
|
|
68
72
|
const dateTime = _DateTime.DateTime.parse('2017-05-01T23:30Z', locale, timezone);
|
|
@@ -88,7 +92,7 @@ describe('<DateTimeInput />', () => {
|
|
|
88
92
|
const timezone = 'US/Eastern';
|
|
89
93
|
const value = _DateTime.DateTime.parse('2017-05-01T17:30Z', locale, timezone);
|
|
90
94
|
const defaultValue = _DateTime.DateTime.parse('2016-04-01T17:00Z', locale, timezone);
|
|
91
|
-
const onChange =
|
|
95
|
+
const onChange = _vitest.vi.fn();
|
|
92
96
|
(0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.DateTimeInput, {
|
|
93
97
|
description: "date_time",
|
|
94
98
|
prevMonthLabel: "Previous month",
|
|
@@ -129,7 +133,7 @@ describe('<DateTimeInput />', () => {
|
|
|
129
133
|
expect(timeInput).toHaveValue('12:00 AM');
|
|
130
134
|
});
|
|
131
135
|
it('should call invalidDateTimeMessage if time is set w/o a date and is required', async () => {
|
|
132
|
-
const invalidDateTimeMessage =
|
|
136
|
+
const invalidDateTimeMessage = _vitest.vi.fn(_rawd => 'whoops');
|
|
133
137
|
const _render = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.DateTimeInput, {
|
|
134
138
|
description: "date_time",
|
|
135
139
|
dateRenderLabel: "date-input",
|
|
@@ -151,7 +155,7 @@ describe('<DateTimeInput />', () => {
|
|
|
151
155
|
});
|
|
152
156
|
});
|
|
153
157
|
it('should not call invalidDateTimeMessage if time is set w/o a date', async () => {
|
|
154
|
-
const invalidDateTimeMessage =
|
|
158
|
+
const invalidDateTimeMessage = _vitest.vi.fn(_rawd => 'whoops');
|
|
155
159
|
(0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.DateTimeInput, {
|
|
156
160
|
description: "date_time",
|
|
157
161
|
dateRenderLabel: "date-input",
|
|
@@ -171,7 +175,7 @@ describe('<DateTimeInput />', () => {
|
|
|
171
175
|
});
|
|
172
176
|
});
|
|
173
177
|
it('should fire the onChange event when TimeInput value changes', async () => {
|
|
174
|
-
const onChange =
|
|
178
|
+
const onChange = _vitest.vi.fn();
|
|
175
179
|
const locale = 'en-US';
|
|
176
180
|
const timezone = 'US/Eastern';
|
|
177
181
|
const defaultValue = _DateTime.DateTime.parse('2017-05-01T17:00', locale, timezone);
|
|
@@ -290,7 +294,7 @@ describe('<DateTimeInput />', () => {
|
|
|
290
294
|
expect(timeInput).toEqual(tref);
|
|
291
295
|
});
|
|
292
296
|
it('should update message when value prop changes', () => {
|
|
293
|
-
const onChange =
|
|
297
|
+
const onChange = _vitest.vi.fn();
|
|
294
298
|
const locale = 'en-US';
|
|
295
299
|
const timezone = 'US/Eastern';
|
|
296
300
|
const dateTime = _DateTime.DateTime.parse('2017-05-01T17:30Z', locale, timezone);
|
|
@@ -316,7 +320,7 @@ describe('<DateTimeInput />', () => {
|
|
|
316
320
|
expect(container).toHaveTextContent('March 29, 2018 12:30 PM');
|
|
317
321
|
});
|
|
318
322
|
it('should update message when locale changed', () => {
|
|
319
|
-
const onChange =
|
|
323
|
+
const onChange = _vitest.vi.fn();
|
|
320
324
|
const locale = 'en-US';
|
|
321
325
|
const timezone = 'US/Eastern';
|
|
322
326
|
const dateTime = _DateTime.DateTime.parse('2017-05-01T17:30Z', locale, timezone);
|
|
@@ -342,7 +346,7 @@ describe('<DateTimeInput />', () => {
|
|
|
342
346
|
expect(container).toHaveTextContent('1 mai 2017 13:30');
|
|
343
347
|
});
|
|
344
348
|
it('should update message when timezone changed', () => {
|
|
345
|
-
const onChange =
|
|
349
|
+
const onChange = _vitest.vi.fn();
|
|
346
350
|
const locale = 'en-US';
|
|
347
351
|
const timezone = 'US/Eastern';
|
|
348
352
|
const dateTime = _DateTime.DateTime.parse('2017-05-01T17:30Z', locale, timezone);
|
|
@@ -509,7 +513,7 @@ describe('<DateTimeInput />', () => {
|
|
|
509
513
|
});
|
|
510
514
|
});
|
|
511
515
|
it('should read locale and timezone from context', () => {
|
|
512
|
-
const onChange =
|
|
516
|
+
const onChange = _vitest.vi.fn();
|
|
513
517
|
const dateTime = _DateTime.DateTime.parse('2017-05-01T17:30Z', 'en-US', 'GMT');
|
|
514
518
|
const _render13 = (0, _react2.render)(
|
|
515
519
|
/*#__PURE__*/
|
|
@@ -531,7 +535,7 @@ describe('<DateTimeInput />', () => {
|
|
|
531
535
|
expect(container).toHaveTextContent('lundi 1 mai 2017 20:30');
|
|
532
536
|
});
|
|
533
537
|
it('should format date according to dateFormat', async () => {
|
|
534
|
-
const onChange =
|
|
538
|
+
const onChange = _vitest.vi.fn();
|
|
535
539
|
const dateTime = _DateTime.DateTime.parse('2017-05-01T17:30Z', 'en-US', 'GMT');
|
|
536
540
|
const props = {
|
|
537
541
|
description: 'date_time',
|
|
@@ -558,7 +562,7 @@ describe('<DateTimeInput />', () => {
|
|
|
558
562
|
});
|
|
559
563
|
});
|
|
560
564
|
it('should format bottom message according to messageFormat', async () => {
|
|
561
|
-
const onChange =
|
|
565
|
+
const onChange = _vitest.vi.fn();
|
|
562
566
|
const dateTime = _DateTime.DateTime.parse('2017-05-01T17:30Z', 'en-US', 'GMT');
|
|
563
567
|
const props = {
|
|
564
568
|
description: 'date_time',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-date-time-input",
|
|
3
|
-
"version": "9.2.1-snapshot-
|
|
3
|
+
"version": "9.2.1-snapshot-3",
|
|
4
4
|
"description": "A UI component that allows to select date and time.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -23,28 +23,29 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@instructure/ui-babel-preset": "9.2.1-snapshot-
|
|
27
|
-
"@instructure/ui-test-utils": "9.2.1-snapshot-
|
|
26
|
+
"@instructure/ui-babel-preset": "9.2.1-snapshot-3",
|
|
27
|
+
"@instructure/ui-test-utils": "9.2.1-snapshot-3",
|
|
28
28
|
"@testing-library/jest-dom": "^6.4.5",
|
|
29
29
|
"@testing-library/react": "^15.0.7",
|
|
30
|
-
"@testing-library/user-event": "^14.5.2"
|
|
30
|
+
"@testing-library/user-event": "^14.5.2",
|
|
31
|
+
"vitest": "^1.6.0"
|
|
31
32
|
},
|
|
32
33
|
"dependencies": {
|
|
33
34
|
"@babel/runtime": "^7.24.5",
|
|
34
|
-
"@instructure/console": "9.2.1-snapshot-
|
|
35
|
-
"@instructure/shared-types": "9.2.1-snapshot-
|
|
36
|
-
"@instructure/ui-a11y-content": "9.2.1-snapshot-
|
|
37
|
-
"@instructure/ui-buttons": "9.2.1-snapshot-
|
|
38
|
-
"@instructure/ui-calendar": "9.2.1-snapshot-
|
|
39
|
-
"@instructure/ui-date-input": "9.2.1-snapshot-
|
|
40
|
-
"@instructure/ui-form-field": "9.2.1-snapshot-
|
|
41
|
-
"@instructure/ui-i18n": "9.2.1-snapshot-
|
|
42
|
-
"@instructure/ui-icons": "9.2.1-snapshot-
|
|
43
|
-
"@instructure/ui-prop-types": "9.2.1-snapshot-
|
|
44
|
-
"@instructure/ui-react-utils": "9.2.1-snapshot-
|
|
45
|
-
"@instructure/ui-testable": "9.2.1-snapshot-
|
|
46
|
-
"@instructure/ui-time-select": "9.2.1-snapshot-
|
|
47
|
-
"@instructure/ui-utils": "9.2.1-snapshot-
|
|
35
|
+
"@instructure/console": "9.2.1-snapshot-3",
|
|
36
|
+
"@instructure/shared-types": "9.2.1-snapshot-3",
|
|
37
|
+
"@instructure/ui-a11y-content": "9.2.1-snapshot-3",
|
|
38
|
+
"@instructure/ui-buttons": "9.2.1-snapshot-3",
|
|
39
|
+
"@instructure/ui-calendar": "9.2.1-snapshot-3",
|
|
40
|
+
"@instructure/ui-date-input": "9.2.1-snapshot-3",
|
|
41
|
+
"@instructure/ui-form-field": "9.2.1-snapshot-3",
|
|
42
|
+
"@instructure/ui-i18n": "9.2.1-snapshot-3",
|
|
43
|
+
"@instructure/ui-icons": "9.2.1-snapshot-3",
|
|
44
|
+
"@instructure/ui-prop-types": "9.2.1-snapshot-3",
|
|
45
|
+
"@instructure/ui-react-utils": "9.2.1-snapshot-3",
|
|
46
|
+
"@instructure/ui-testable": "9.2.1-snapshot-3",
|
|
47
|
+
"@instructure/ui-time-select": "9.2.1-snapshot-3",
|
|
48
|
+
"@instructure/ui-utils": "9.2.1-snapshot-3",
|
|
48
49
|
"prop-types": "^15.8.1"
|
|
49
50
|
},
|
|
50
51
|
"peerDependencies": {
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
import React from 'react'
|
|
26
26
|
import { fireEvent, render, screen, waitFor } from '@testing-library/react'
|
|
27
|
+
import { vi } from 'vitest'
|
|
27
28
|
import userEvent from '@testing-library/user-event'
|
|
28
29
|
import '@testing-library/jest-dom'
|
|
29
30
|
|
|
@@ -31,14 +32,21 @@ import { DateTimeInput } from '../index'
|
|
|
31
32
|
import { ApplyLocale, DateTime } from '@instructure/ui-i18n'
|
|
32
33
|
|
|
33
34
|
describe('<DateTimeInput />', () => {
|
|
34
|
-
let
|
|
35
|
+
let consoleWarningMock: ReturnType<typeof vi.spyOn>
|
|
36
|
+
let consoleErrorMock: ReturnType<typeof vi.spyOn>
|
|
35
37
|
|
|
36
38
|
beforeEach(() => {
|
|
37
39
|
// Mocking console to prevent test output pollution and expect for messages
|
|
38
|
-
|
|
40
|
+
consoleWarningMock = vi
|
|
41
|
+
.spyOn(console, 'warn')
|
|
42
|
+
.mockImplementation(() => {}) as any
|
|
43
|
+
consoleErrorMock = vi
|
|
44
|
+
.spyOn(console, 'error')
|
|
45
|
+
.mockImplementation(() => {}) as any
|
|
39
46
|
})
|
|
40
47
|
|
|
41
48
|
afterEach(() => {
|
|
49
|
+
consoleWarningMock.mockRestore()
|
|
42
50
|
consoleErrorMock.mockRestore()
|
|
43
51
|
})
|
|
44
52
|
|
|
@@ -68,7 +76,7 @@ describe('<DateTimeInput />', () => {
|
|
|
68
76
|
})
|
|
69
77
|
|
|
70
78
|
it('should use the value', () => {
|
|
71
|
-
const onChange =
|
|
79
|
+
const onChange = vi.fn()
|
|
72
80
|
const locale = 'en-US'
|
|
73
81
|
const timezone = 'US/Eastern'
|
|
74
82
|
const dateTime = DateTime.parse('2017-05-01T23:30Z', locale, timezone)
|
|
@@ -99,7 +107,7 @@ describe('<DateTimeInput />', () => {
|
|
|
99
107
|
const timezone = 'US/Eastern'
|
|
100
108
|
const value = DateTime.parse('2017-05-01T17:30Z', locale, timezone)
|
|
101
109
|
const defaultValue = DateTime.parse('2016-04-01T17:00Z', locale, timezone)
|
|
102
|
-
const onChange =
|
|
110
|
+
const onChange = vi.fn()
|
|
103
111
|
|
|
104
112
|
render(
|
|
105
113
|
<DateTimeInput
|
|
@@ -150,7 +158,7 @@ describe('<DateTimeInput />', () => {
|
|
|
150
158
|
})
|
|
151
159
|
|
|
152
160
|
it('should call invalidDateTimeMessage if time is set w/o a date and is required', async () => {
|
|
153
|
-
const invalidDateTimeMessage =
|
|
161
|
+
const invalidDateTimeMessage = vi.fn((_rawd) => 'whoops')
|
|
154
162
|
|
|
155
163
|
const { container } = render(
|
|
156
164
|
<DateTimeInput
|
|
@@ -177,7 +185,7 @@ describe('<DateTimeInput />', () => {
|
|
|
177
185
|
})
|
|
178
186
|
|
|
179
187
|
it('should not call invalidDateTimeMessage if time is set w/o a date', async () => {
|
|
180
|
-
const invalidDateTimeMessage =
|
|
188
|
+
const invalidDateTimeMessage = vi.fn((_rawd) => 'whoops')
|
|
181
189
|
|
|
182
190
|
render(
|
|
183
191
|
<DateTimeInput
|
|
@@ -204,7 +212,7 @@ describe('<DateTimeInput />', () => {
|
|
|
204
212
|
})
|
|
205
213
|
|
|
206
214
|
it('should fire the onChange event when TimeInput value changes', async () => {
|
|
207
|
-
const onChange =
|
|
215
|
+
const onChange = vi.fn()
|
|
208
216
|
|
|
209
217
|
const locale = 'en-US'
|
|
210
218
|
const timezone = 'US/Eastern'
|
|
@@ -332,7 +340,7 @@ describe('<DateTimeInput />', () => {
|
|
|
332
340
|
})
|
|
333
341
|
|
|
334
342
|
it('should update message when value prop changes', () => {
|
|
335
|
-
const onChange =
|
|
343
|
+
const onChange = vi.fn()
|
|
336
344
|
const locale = 'en-US'
|
|
337
345
|
const timezone = 'US/Eastern'
|
|
338
346
|
const dateTime = DateTime.parse('2017-05-01T17:30Z', locale, timezone)
|
|
@@ -358,7 +366,7 @@ describe('<DateTimeInput />', () => {
|
|
|
358
366
|
})
|
|
359
367
|
|
|
360
368
|
it('should update message when locale changed', () => {
|
|
361
|
-
const onChange =
|
|
369
|
+
const onChange = vi.fn()
|
|
362
370
|
const locale = 'en-US'
|
|
363
371
|
const timezone = 'US/Eastern'
|
|
364
372
|
const dateTime = DateTime.parse('2017-05-01T17:30Z', locale, timezone)
|
|
@@ -384,7 +392,7 @@ describe('<DateTimeInput />', () => {
|
|
|
384
392
|
})
|
|
385
393
|
|
|
386
394
|
it('should update message when timezone changed', () => {
|
|
387
|
-
const onChange =
|
|
395
|
+
const onChange = vi.fn()
|
|
388
396
|
const locale = 'en-US'
|
|
389
397
|
const timezone = 'US/Eastern'
|
|
390
398
|
const dateTime = DateTime.parse('2017-05-01T17:30Z', locale, timezone)
|
|
@@ -561,7 +569,7 @@ describe('<DateTimeInput />', () => {
|
|
|
561
569
|
})
|
|
562
570
|
|
|
563
571
|
it('should read locale and timezone from context', () => {
|
|
564
|
-
const onChange =
|
|
572
|
+
const onChange = vi.fn()
|
|
565
573
|
const dateTime = DateTime.parse('2017-05-01T17:30Z', 'en-US', 'GMT')
|
|
566
574
|
const { container } = render(
|
|
567
575
|
// Africa/Nairobi is GMT +3
|
|
@@ -583,7 +591,7 @@ describe('<DateTimeInput />', () => {
|
|
|
583
591
|
})
|
|
584
592
|
|
|
585
593
|
it('should format date according to dateFormat', async () => {
|
|
586
|
-
const onChange =
|
|
594
|
+
const onChange = vi.fn()
|
|
587
595
|
const dateTime = DateTime.parse('2017-05-01T17:30Z', 'en-US', 'GMT')
|
|
588
596
|
const props = {
|
|
589
597
|
description: 'date_time',
|
|
@@ -616,7 +624,7 @@ describe('<DateTimeInput />', () => {
|
|
|
616
624
|
})
|
|
617
625
|
|
|
618
626
|
it('should format bottom message according to messageFormat', async () => {
|
|
619
|
-
const onChange =
|
|
627
|
+
const onChange = vi.fn()
|
|
620
628
|
const dateTime = DateTime.parse('2017-05-01T17:30Z', 'en-US', 'GMT')
|
|
621
629
|
const props = {
|
|
622
630
|
description: 'date_time',
|