@dhis2-ui/calendar 10.12.0 → 10.12.2

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.
@@ -2,7 +2,6 @@
2
2
 
3
3
  var _button = require("@dhis2-ui/button");
4
4
  var _react = require("@testing-library/react");
5
- var _userEvent = require("@testing-library/user-event");
6
5
  var _react2 = _interopRequireWildcard(require("react"));
7
6
  var _reactFinalForm = require("react-final-form");
8
7
  var _calendarInput = require("../calendar-input.js");
@@ -10,12 +9,9 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
10
9
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
11
10
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
12
11
  describe('Calendar Input', () => {
13
- beforeEach(() => {
12
+ it('allow selection of a date through the calendar widget', async () => {
14
13
  jest.useFakeTimers();
15
14
  jest.setSystemTime(new Date('2024-10-22T09:05:00.000Z'));
16
- });
17
- afterEach(jest.useRealTimers);
18
- it('allow selection of a date through the calendar widget', async () => {
19
15
  const onDateSelectMock = jest.fn();
20
16
  const screen = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_calendarInput.CalendarInput, {
21
17
  calendar: "gregory",
@@ -34,6 +30,7 @@ describe('Calendar Input', () => {
34
30
  expect(onDateSelectMock).toHaveBeenCalledWith(expect.objectContaining({
35
31
  calendarDateString: todayString
36
32
  }));
33
+ jest.useRealTimers();
37
34
  });
38
35
  it('allow selection of a date through the input', async () => {
39
36
  const onDateSelectMock = jest.fn();
@@ -54,8 +51,7 @@ describe('Calendar Input', () => {
54
51
  }));
55
52
  });
56
53
  describe('validation', () => {
57
- beforeEach(jest.useRealTimers);
58
- it('should validate minimum date', async () => {
54
+ it('should validate minimum date', () => {
59
55
  const onDateSelectMock = jest.fn();
60
56
  const screen = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(CalendarWithValidation, {
61
57
  calendar: "gregory",
@@ -64,33 +60,38 @@ describe('Calendar Input', () => {
64
60
  }));
65
61
  const dateInputString = '2023-10-12';
66
62
  const dateInput = (0, _react.within)(screen.getByTestId('dhis2-uicore-input')).getByRole('textbox');
67
- await _userEvent.userEvent.clear(dateInput);
68
- await _userEvent.userEvent.type(dateInput, dateInputString);
69
- await _userEvent.userEvent.tab();
70
- expect(await screen.findByText('Date 2023-10-12 is less than the minimum allowed date 2024-01-01.'));
63
+ _react.fireEvent.change(dateInput, {
64
+ target: {
65
+ value: dateInputString
66
+ }
67
+ });
68
+ _react.fireEvent.blur(dateInput);
69
+ expect(screen.getByText('Date 2023-10-12 is less than the minimum allowed date 2024-01-01.')).toBeInTheDocument();
71
70
  expect(onDateSelectMock).toHaveBeenCalledTimes(1);
72
71
  });
73
- // skipping since test times out - reference issue: https://dhis2.atlassian.net/browse/LIBS-763
74
- it.skip('should validate maximum date', async () => {
72
+ it('should validate maximum date', () => {
75
73
  const {
76
74
  getByTestId,
77
- findByText
75
+ getByText
78
76
  } = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(CalendarWithValidation, {
79
77
  calendar: "gregory",
80
78
  maxDate: "2024-01-01"
81
79
  }));
82
80
  const dateInputString = '2024-10-12';
83
81
  const dateInput = (0, _react.within)(getByTestId('dhis2-uicore-input')).getByRole('textbox');
84
- await _userEvent.userEvent.clear(dateInput);
85
- await _userEvent.userEvent.type(dateInput, dateInputString);
86
- await _userEvent.userEvent.tab();
87
- expect(await findByText('Date 2024-10-12 is greater than the maximum allowed date 2024-01-01.'));
82
+ _react.fireEvent.change(dateInput, {
83
+ target: {
84
+ value: dateInputString
85
+ }
86
+ });
87
+ _react.fireEvent.blur(dateInput);
88
+ expect(getByText('Date 2024-10-12 is greater than the maximum allowed date 2024-01-01.')).toBeInTheDocument();
88
89
  });
89
- it('should validate date in ethiopic calendar', async () => {
90
+ it('should validate date in ethiopic calendar', () => {
90
91
  const onDateSelectMock = jest.fn();
91
92
  const {
92
93
  getByTestId,
93
- findByText,
94
+ getByText,
94
95
  queryByText
95
96
  } = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(CalendarWithValidation, {
96
97
  calendar: "ethiopian",
@@ -99,28 +100,37 @@ describe('Calendar Input', () => {
99
100
  }));
100
101
  let dateInputString = '2018-13-02';
101
102
  const dateInput = (0, _react.within)(getByTestId('dhis2-uicore-input')).getByRole('textbox');
102
- await _userEvent.userEvent.clear(dateInput);
103
- await _userEvent.userEvent.type(dateInput, dateInputString);
104
- await _userEvent.userEvent.tab();
105
- await findByText('Date 2018-13-02 is less than the minimum allowed date 2018-13-04.');
103
+ _react.fireEvent.change(dateInput, {
104
+ target: {
105
+ value: dateInputString
106
+ }
107
+ });
108
+ _react.fireEvent.blur(dateInput);
109
+ expect(getByTestId('dhis2-uiwidgets-calendar-inputfield-validation')).toBeInTheDocument();
110
+ expect(getByText('Date 2018-13-02 is less than the minimum allowed date 2018-13-04.')).toBeInTheDocument();
106
111
  dateInputString = '2018-13-05';
107
- await _userEvent.userEvent.clear(dateInput);
108
- await _userEvent.userEvent.click(dateInput);
109
- await _userEvent.userEvent.type(dateInput, dateInputString);
110
- await _userEvent.userEvent.tab();
112
+ _react.fireEvent.change(dateInput, {
113
+ target: {
114
+ value: dateInputString
115
+ }
116
+ });
117
+ _react.fireEvent.blur(dateInput);
111
118
  expect(queryByText('Date 2018-13-04 is less than the minimum allowed date 2018-13-05.')).not.toBeInTheDocument();
112
119
  dateInputString = '2018-13-07';
113
- await _userEvent.userEvent.clear(dateInput);
114
- await _userEvent.userEvent.type(dateInput, dateInputString);
115
- await _userEvent.userEvent.tab();
116
- expect(await findByText('Invalid date in specified calendar')).toBeInTheDocument();
117
- }, 20 * 1000);
120
+ _react.fireEvent.change(dateInput, {
121
+ target: {
122
+ value: dateInputString
123
+ }
124
+ });
125
+ _react.fireEvent.blur(dateInput);
126
+ expect(getByText('Invalid date in specified calendar')).toBeInTheDocument();
127
+ });
118
128
  // ToDo: these scenarios seem to work but they timeout on CI sporadically - ticket: https://dhis2.atlassian.net/browse/LIBS-763
119
- it.skip('should validate date in nepali calendar', async () => {
129
+ it('should validate date in nepali calendar', () => {
120
130
  const onDateSelectMock = jest.fn();
121
131
  const {
122
132
  getByTestId,
123
- findByText,
133
+ getByText,
124
134
  queryByText
125
135
  } = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(CalendarWithValidation, {
126
136
  calendar: "nepali",
@@ -129,23 +139,32 @@ describe('Calendar Input', () => {
129
139
  }));
130
140
  let dateInputString = '2080-06-01';
131
141
  const dateInput = (0, _react.within)(getByTestId('dhis2-uicore-input')).getByRole('textbox');
132
- await _userEvent.userEvent.clear(dateInput);
133
- await _userEvent.userEvent.type(dateInput, dateInputString);
134
- await _userEvent.userEvent.tab();
135
- expect(await findByText('Date 2080-06-01 is greater than the maximum allowed date 2080-05-30.'));
142
+ _react.fireEvent.change(dateInput, {
143
+ target: {
144
+ value: dateInputString
145
+ }
146
+ });
147
+ _react.fireEvent.blur(dateInput);
148
+ expect(getByText('Date 2080-06-01 is greater than the maximum allowed date 2080-05-30.')).toBeInTheDocument();
136
149
  dateInputString = '2080-04-32';
137
- await _userEvent.userEvent.clear(dateInput);
138
- await _userEvent.userEvent.type(dateInput, dateInputString);
139
- await _userEvent.userEvent.tab();
150
+ _react.fireEvent.change(dateInput, {
151
+ target: {
152
+ value: dateInputString
153
+ }
154
+ });
155
+ _react.fireEvent.blur(dateInput);
140
156
  expect(queryByText(/greater than the maximum allowed date/)).not.toBeInTheDocument();
141
157
  dateInputString = '2080-01-32';
142
- await _userEvent.userEvent.clear(dateInput);
143
- await _userEvent.userEvent.type(dateInput, dateInputString);
144
- await _userEvent.userEvent.tab();
145
- expect(await findByText('Invalid date in specified calendar')).toBeInTheDocument();
146
- }, 20 * 1000);
147
- it.skip('should validate from date picker', async () => {
148
- jest.useFakeTimers('modern');
158
+ _react.fireEvent.change(dateInput, {
159
+ target: {
160
+ value: dateInputString
161
+ }
162
+ });
163
+ _react.fireEvent.blur(dateInput);
164
+ expect(getByText('Invalid date in specified calendar')).toBeInTheDocument();
165
+ });
166
+ it('should validate from date picker', () => {
167
+ jest.useFakeTimers();
149
168
  jest.setSystemTime(new Date('2024-10-22T09:05:00.000Z'));
150
169
  const onDateSelectMock = jest.fn();
151
170
  const {
@@ -158,8 +177,8 @@ describe('Calendar Input', () => {
158
177
  onDateSelect: onDateSelectMock
159
178
  }));
160
179
  const dateInput = (0, _react.within)(getByTestId('dhis2-uicore-input')).getByRole('textbox');
161
- await _react.fireEvent.focusIn(dateInput);
162
- await _react.fireEvent.click(getByText('17'));
180
+ _react.fireEvent.focusIn(dateInput);
181
+ _react.fireEvent.click(getByText('17'));
163
182
  expect(queryByText('17')).not.toBeInTheDocument();
164
183
 
165
184
  // Checking fix for Bug where callback used to be called twice - first with undefined
@@ -172,8 +191,9 @@ describe('Calendar Input', () => {
172
191
  warning: false
173
192
  }
174
193
  });
194
+ jest.useRealTimers();
175
195
  });
176
- it('should validate with Clear', async () => {
196
+ it('should validate with Clear', () => {
177
197
  const onDateSelectMock = jest.fn();
178
198
  const {
179
199
  queryByText,
@@ -187,11 +207,14 @@ describe('Calendar Input', () => {
187
207
  }));
188
208
  const dateInputString = '2023-10-12';
189
209
  const dateInput = (0, _react.within)(getByTestId('dhis2-uicore-input')).getByRole('textbox');
190
- await _userEvent.userEvent.clear(dateInput);
191
- await _userEvent.userEvent.type(dateInput, dateInputString);
192
- await _userEvent.userEvent.tab();
210
+ _react.fireEvent.change(dateInput, {
211
+ target: {
212
+ value: dateInputString
213
+ }
214
+ });
215
+ _react.fireEvent.blur(dateInput);
193
216
  expect(getByTestId('dhis2-uiwidgets-calendar-inputfield-validation')).toBeInTheDocument();
194
- await _userEvent.userEvent.click(getByText('Clear'));
217
+ _react.fireEvent.click(getByText('Clear'));
195
218
  expect(queryByText('17')).not.toBeInTheDocument();
196
219
  expect(onDateSelectMock).toHaveBeenLastCalledWith({
197
220
  calendarDateString: null,
@@ -200,7 +223,7 @@ describe('Calendar Input', () => {
200
223
  }
201
224
  });
202
225
  });
203
- it('should validate when Clearing manually (i.e. deleting text not using clear button)', async () => {
226
+ it('should validate when Clearing manually (i.e. deleting text not using clear button)', () => {
204
227
  const onDateSelectMock = jest.fn();
205
228
  const {
206
229
  getByTestId
@@ -212,12 +235,19 @@ describe('Calendar Input', () => {
212
235
  }));
213
236
  const dateInputString = '2023-10-12';
214
237
  const dateInput = (0, _react.within)(getByTestId('dhis2-uicore-input')).getByRole('textbox');
215
- await _userEvent.userEvent.clear(dateInput);
216
- await _userEvent.userEvent.type(dateInput, dateInputString);
217
- await _userEvent.userEvent.tab();
238
+ _react.fireEvent.change(dateInput, {
239
+ target: {
240
+ value: dateInputString
241
+ }
242
+ });
243
+ _react.fireEvent.blur(dateInput);
218
244
  expect(getByTestId('dhis2-uiwidgets-calendar-inputfield-validation')).toBeInTheDocument();
219
- await _userEvent.userEvent.clear(dateInput);
220
- await _userEvent.userEvent.tab();
245
+ _react.fireEvent.change(dateInput, {
246
+ target: {
247
+ value: ''
248
+ }
249
+ });
250
+ _react.fireEvent.blur(dateInput);
221
251
  expect(onDateSelectMock).toHaveBeenCalledWith({
222
252
  calendarDateString: null,
223
253
  validation: {
@@ -1,17 +1,13 @@
1
1
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
2
  import { Button } from '@dhis2-ui/button';
3
3
  import { fireEvent, render, waitFor, within } from '@testing-library/react';
4
- import { userEvent } from '@testing-library/user-event';
5
4
  import React, { useState } from 'react';
6
5
  import { Field, Form } from 'react-final-form';
7
6
  import { CalendarInput } from '../calendar-input.js';
8
7
  describe('Calendar Input', () => {
9
- beforeEach(() => {
8
+ it('allow selection of a date through the calendar widget', async () => {
10
9
  jest.useFakeTimers();
11
10
  jest.setSystemTime(new Date('2024-10-22T09:05:00.000Z'));
12
- });
13
- afterEach(jest.useRealTimers);
14
- it('allow selection of a date through the calendar widget', async () => {
15
11
  const onDateSelectMock = jest.fn();
16
12
  const screen = render(/*#__PURE__*/React.createElement(CalendarInput, {
17
13
  calendar: "gregory",
@@ -30,6 +26,7 @@ describe('Calendar Input', () => {
30
26
  expect(onDateSelectMock).toHaveBeenCalledWith(expect.objectContaining({
31
27
  calendarDateString: todayString
32
28
  }));
29
+ jest.useRealTimers();
33
30
  });
34
31
  it('allow selection of a date through the input', async () => {
35
32
  const onDateSelectMock = jest.fn();
@@ -50,8 +47,7 @@ describe('Calendar Input', () => {
50
47
  }));
51
48
  });
52
49
  describe('validation', () => {
53
- beforeEach(jest.useRealTimers);
54
- it('should validate minimum date', async () => {
50
+ it('should validate minimum date', () => {
55
51
  const onDateSelectMock = jest.fn();
56
52
  const screen = render(/*#__PURE__*/React.createElement(CalendarWithValidation, {
57
53
  calendar: "gregory",
@@ -60,33 +56,38 @@ describe('Calendar Input', () => {
60
56
  }));
61
57
  const dateInputString = '2023-10-12';
62
58
  const dateInput = within(screen.getByTestId('dhis2-uicore-input')).getByRole('textbox');
63
- await userEvent.clear(dateInput);
64
- await userEvent.type(dateInput, dateInputString);
65
- await userEvent.tab();
66
- expect(await screen.findByText('Date 2023-10-12 is less than the minimum allowed date 2024-01-01.'));
59
+ fireEvent.change(dateInput, {
60
+ target: {
61
+ value: dateInputString
62
+ }
63
+ });
64
+ fireEvent.blur(dateInput);
65
+ expect(screen.getByText('Date 2023-10-12 is less than the minimum allowed date 2024-01-01.')).toBeInTheDocument();
67
66
  expect(onDateSelectMock).toHaveBeenCalledTimes(1);
68
67
  });
69
- // skipping since test times out - reference issue: https://dhis2.atlassian.net/browse/LIBS-763
70
- it.skip('should validate maximum date', async () => {
68
+ it('should validate maximum date', () => {
71
69
  const {
72
70
  getByTestId,
73
- findByText
71
+ getByText
74
72
  } = render(/*#__PURE__*/React.createElement(CalendarWithValidation, {
75
73
  calendar: "gregory",
76
74
  maxDate: "2024-01-01"
77
75
  }));
78
76
  const dateInputString = '2024-10-12';
79
77
  const dateInput = within(getByTestId('dhis2-uicore-input')).getByRole('textbox');
80
- await userEvent.clear(dateInput);
81
- await userEvent.type(dateInput, dateInputString);
82
- await userEvent.tab();
83
- expect(await findByText('Date 2024-10-12 is greater than the maximum allowed date 2024-01-01.'));
78
+ fireEvent.change(dateInput, {
79
+ target: {
80
+ value: dateInputString
81
+ }
82
+ });
83
+ fireEvent.blur(dateInput);
84
+ expect(getByText('Date 2024-10-12 is greater than the maximum allowed date 2024-01-01.')).toBeInTheDocument();
84
85
  });
85
- it('should validate date in ethiopic calendar', async () => {
86
+ it('should validate date in ethiopic calendar', () => {
86
87
  const onDateSelectMock = jest.fn();
87
88
  const {
88
89
  getByTestId,
89
- findByText,
90
+ getByText,
90
91
  queryByText
91
92
  } = render(/*#__PURE__*/React.createElement(CalendarWithValidation, {
92
93
  calendar: "ethiopian",
@@ -95,28 +96,37 @@ describe('Calendar Input', () => {
95
96
  }));
96
97
  let dateInputString = '2018-13-02';
97
98
  const dateInput = within(getByTestId('dhis2-uicore-input')).getByRole('textbox');
98
- await userEvent.clear(dateInput);
99
- await userEvent.type(dateInput, dateInputString);
100
- await userEvent.tab();
101
- await findByText('Date 2018-13-02 is less than the minimum allowed date 2018-13-04.');
99
+ fireEvent.change(dateInput, {
100
+ target: {
101
+ value: dateInputString
102
+ }
103
+ });
104
+ fireEvent.blur(dateInput);
105
+ expect(getByTestId('dhis2-uiwidgets-calendar-inputfield-validation')).toBeInTheDocument();
106
+ expect(getByText('Date 2018-13-02 is less than the minimum allowed date 2018-13-04.')).toBeInTheDocument();
102
107
  dateInputString = '2018-13-05';
103
- await userEvent.clear(dateInput);
104
- await userEvent.click(dateInput);
105
- await userEvent.type(dateInput, dateInputString);
106
- await userEvent.tab();
108
+ fireEvent.change(dateInput, {
109
+ target: {
110
+ value: dateInputString
111
+ }
112
+ });
113
+ fireEvent.blur(dateInput);
107
114
  expect(queryByText('Date 2018-13-04 is less than the minimum allowed date 2018-13-05.')).not.toBeInTheDocument();
108
115
  dateInputString = '2018-13-07';
109
- await userEvent.clear(dateInput);
110
- await userEvent.type(dateInput, dateInputString);
111
- await userEvent.tab();
112
- expect(await findByText('Invalid date in specified calendar')).toBeInTheDocument();
113
- }, 20 * 1000);
116
+ fireEvent.change(dateInput, {
117
+ target: {
118
+ value: dateInputString
119
+ }
120
+ });
121
+ fireEvent.blur(dateInput);
122
+ expect(getByText('Invalid date in specified calendar')).toBeInTheDocument();
123
+ });
114
124
  // ToDo: these scenarios seem to work but they timeout on CI sporadically - ticket: https://dhis2.atlassian.net/browse/LIBS-763
115
- it.skip('should validate date in nepali calendar', async () => {
125
+ it('should validate date in nepali calendar', () => {
116
126
  const onDateSelectMock = jest.fn();
117
127
  const {
118
128
  getByTestId,
119
- findByText,
129
+ getByText,
120
130
  queryByText
121
131
  } = render(/*#__PURE__*/React.createElement(CalendarWithValidation, {
122
132
  calendar: "nepali",
@@ -125,23 +135,32 @@ describe('Calendar Input', () => {
125
135
  }));
126
136
  let dateInputString = '2080-06-01';
127
137
  const dateInput = within(getByTestId('dhis2-uicore-input')).getByRole('textbox');
128
- await userEvent.clear(dateInput);
129
- await userEvent.type(dateInput, dateInputString);
130
- await userEvent.tab();
131
- expect(await findByText('Date 2080-06-01 is greater than the maximum allowed date 2080-05-30.'));
138
+ fireEvent.change(dateInput, {
139
+ target: {
140
+ value: dateInputString
141
+ }
142
+ });
143
+ fireEvent.blur(dateInput);
144
+ expect(getByText('Date 2080-06-01 is greater than the maximum allowed date 2080-05-30.')).toBeInTheDocument();
132
145
  dateInputString = '2080-04-32';
133
- await userEvent.clear(dateInput);
134
- await userEvent.type(dateInput, dateInputString);
135
- await userEvent.tab();
146
+ fireEvent.change(dateInput, {
147
+ target: {
148
+ value: dateInputString
149
+ }
150
+ });
151
+ fireEvent.blur(dateInput);
136
152
  expect(queryByText(/greater than the maximum allowed date/)).not.toBeInTheDocument();
137
153
  dateInputString = '2080-01-32';
138
- await userEvent.clear(dateInput);
139
- await userEvent.type(dateInput, dateInputString);
140
- await userEvent.tab();
141
- expect(await findByText('Invalid date in specified calendar')).toBeInTheDocument();
142
- }, 20 * 1000);
143
- it.skip('should validate from date picker', async () => {
144
- jest.useFakeTimers('modern');
154
+ fireEvent.change(dateInput, {
155
+ target: {
156
+ value: dateInputString
157
+ }
158
+ });
159
+ fireEvent.blur(dateInput);
160
+ expect(getByText('Invalid date in specified calendar')).toBeInTheDocument();
161
+ });
162
+ it('should validate from date picker', () => {
163
+ jest.useFakeTimers();
145
164
  jest.setSystemTime(new Date('2024-10-22T09:05:00.000Z'));
146
165
  const onDateSelectMock = jest.fn();
147
166
  const {
@@ -154,8 +173,8 @@ describe('Calendar Input', () => {
154
173
  onDateSelect: onDateSelectMock
155
174
  }));
156
175
  const dateInput = within(getByTestId('dhis2-uicore-input')).getByRole('textbox');
157
- await fireEvent.focusIn(dateInput);
158
- await fireEvent.click(getByText('17'));
176
+ fireEvent.focusIn(dateInput);
177
+ fireEvent.click(getByText('17'));
159
178
  expect(queryByText('17')).not.toBeInTheDocument();
160
179
 
161
180
  // Checking fix for Bug where callback used to be called twice - first with undefined
@@ -168,8 +187,9 @@ describe('Calendar Input', () => {
168
187
  warning: false
169
188
  }
170
189
  });
190
+ jest.useRealTimers();
171
191
  });
172
- it('should validate with Clear', async () => {
192
+ it('should validate with Clear', () => {
173
193
  const onDateSelectMock = jest.fn();
174
194
  const {
175
195
  queryByText,
@@ -183,11 +203,14 @@ describe('Calendar Input', () => {
183
203
  }));
184
204
  const dateInputString = '2023-10-12';
185
205
  const dateInput = within(getByTestId('dhis2-uicore-input')).getByRole('textbox');
186
- await userEvent.clear(dateInput);
187
- await userEvent.type(dateInput, dateInputString);
188
- await userEvent.tab();
206
+ fireEvent.change(dateInput, {
207
+ target: {
208
+ value: dateInputString
209
+ }
210
+ });
211
+ fireEvent.blur(dateInput);
189
212
  expect(getByTestId('dhis2-uiwidgets-calendar-inputfield-validation')).toBeInTheDocument();
190
- await userEvent.click(getByText('Clear'));
213
+ fireEvent.click(getByText('Clear'));
191
214
  expect(queryByText('17')).not.toBeInTheDocument();
192
215
  expect(onDateSelectMock).toHaveBeenLastCalledWith({
193
216
  calendarDateString: null,
@@ -196,7 +219,7 @@ describe('Calendar Input', () => {
196
219
  }
197
220
  });
198
221
  });
199
- it('should validate when Clearing manually (i.e. deleting text not using clear button)', async () => {
222
+ it('should validate when Clearing manually (i.e. deleting text not using clear button)', () => {
200
223
  const onDateSelectMock = jest.fn();
201
224
  const {
202
225
  getByTestId
@@ -208,12 +231,19 @@ describe('Calendar Input', () => {
208
231
  }));
209
232
  const dateInputString = '2023-10-12';
210
233
  const dateInput = within(getByTestId('dhis2-uicore-input')).getByRole('textbox');
211
- await userEvent.clear(dateInput);
212
- await userEvent.type(dateInput, dateInputString);
213
- await userEvent.tab();
234
+ fireEvent.change(dateInput, {
235
+ target: {
236
+ value: dateInputString
237
+ }
238
+ });
239
+ fireEvent.blur(dateInput);
214
240
  expect(getByTestId('dhis2-uiwidgets-calendar-inputfield-validation')).toBeInTheDocument();
215
- await userEvent.clear(dateInput);
216
- await userEvent.tab();
241
+ fireEvent.change(dateInput, {
242
+ target: {
243
+ value: ''
244
+ }
245
+ });
246
+ fireEvent.blur(dateInput);
217
247
  expect(onDateSelectMock).toHaveBeenCalledWith({
218
248
  calendarDateString: null,
219
249
  validation: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhis2-ui/calendar",
3
- "version": "10.12.0",
3
+ "version": "10.12.2",
4
4
  "description": "UI Calendar",
5
5
  "repository": {
6
6
  "type": "git",
@@ -33,15 +33,15 @@
33
33
  "styled-jsx": "^4"
34
34
  },
35
35
  "dependencies": {
36
- "@dhis2-ui/button": "10.12.0",
37
- "@dhis2-ui/card": "10.12.0",
38
- "@dhis2-ui/input": "10.12.0",
39
- "@dhis2-ui/layer": "10.12.0",
40
- "@dhis2-ui/popper": "10.12.0",
36
+ "@dhis2-ui/button": "10.12.2",
37
+ "@dhis2-ui/card": "10.12.2",
38
+ "@dhis2-ui/input": "10.12.2",
39
+ "@dhis2-ui/layer": "10.12.2",
40
+ "@dhis2-ui/popper": "10.12.2",
41
41
  "@dhis2/multi-calendar-dates": "2.1.2",
42
42
  "@dhis2/prop-types": "^3.1.2",
43
- "@dhis2/ui-constants": "10.12.0",
44
- "@dhis2/ui-icons": "10.12.0",
43
+ "@dhis2/ui-constants": "10.12.2",
44
+ "@dhis2/ui-icons": "10.12.2",
45
45
  "classnames": "^2.3.1",
46
46
  "prop-types": "^15.7.2"
47
47
  },