@ionic/core 7.5.6-dev.11700168085.18cb70d3 → 7.5.6-dev.11700492285.1581ed02

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.
Files changed (80) hide show
  1. package/components/ion-datetime.js +2 -2
  2. package/dist/cjs/ion-datetime_3.cjs.entry.js +2 -2
  3. package/dist/collection/collection-manifest.json +4 -4
  4. package/dist/collection/components/accordion/test/accordion.spec.js +195 -0
  5. package/dist/collection/components/action-sheet/test/action-sheet-id.spec.js +32 -0
  6. package/dist/collection/components/action-sheet/test/basic/action-sheet.spec.js +18 -0
  7. package/dist/collection/components/alert/test/alert-id.spec.js +32 -0
  8. package/dist/collection/components/alert/test/alert.spec.js +37 -0
  9. package/dist/collection/components/back-button/test/back-button.spec.js +86 -0
  10. package/dist/collection/components/breadcrumb/test/aria.spec.js +22 -0
  11. package/dist/collection/components/breadcrumbs/test/breadcrumbs.spec.js +58 -0
  12. package/dist/collection/components/button/test/form-reference/button.spec.js +26 -0
  13. package/dist/collection/components/card/test/aria.spec.js +16 -0
  14. package/dist/collection/components/checkbox/test/checkbox.spec.js +20 -0
  15. package/dist/collection/components/datetime/datetime.js +2 -2
  16. package/dist/collection/components/datetime/test/a11y/datetime.spec.js +43 -0
  17. package/dist/collection/components/datetime/test/comparison.spec.js +43 -0
  18. package/dist/collection/components/datetime/test/data.spec.js +456 -0
  19. package/dist/collection/components/datetime/test/format.spec.js +124 -0
  20. package/dist/collection/components/datetime/test/helpers.spec.js +72 -0
  21. package/dist/collection/components/datetime/test/manipulation.spec.js +433 -0
  22. package/dist/collection/components/datetime/test/parse.spec.js +222 -0
  23. package/dist/collection/components/datetime/test/state.spec.js +114 -0
  24. package/dist/collection/components/infinite-scroll-content/test/infinite-scroll-content.spec.js +37 -0
  25. package/dist/collection/components/input/test/input.spec.js +85 -0
  26. package/dist/collection/components/input/test/item/input.spec.js +24 -0
  27. package/dist/collection/components/item/test/a11y/item.spec.js +48 -0
  28. package/dist/collection/components/loading/test/basic/loading.spec.js +16 -0
  29. package/dist/collection/components/loading/test/loading-id.spec.js +32 -0
  30. package/dist/collection/components/loading/test/loading.spec.js +37 -0
  31. package/dist/collection/components/modal/test/a11y/modal.spec.js +22 -0
  32. package/dist/collection/components/modal/test/basic/modal.spec.js +16 -0
  33. package/dist/collection/components/modal/test/can-dismiss/modal.spec.js +191 -0
  34. package/dist/collection/components/modal/test/modal-id.spec.js +32 -0
  35. package/dist/collection/components/nav/test/nav-controller.spec.js +749 -0
  36. package/dist/collection/components/picker/test/picker-id.spec.js +32 -0
  37. package/dist/collection/components/picker-column/test/picker-column-aria.spec.js +35 -0
  38. package/dist/collection/components/picker-column/test/picker-column-dynamic.spec.js +29 -0
  39. package/dist/collection/components/picker-column/test/picker-column.spec.js +17 -0
  40. package/dist/collection/components/popover/test/basic/popover.spec.js +16 -0
  41. package/dist/collection/components/popover/test/popover-id.spec.js +32 -0
  42. package/dist/collection/components/popover/test/util.spec.js +53 -0
  43. package/dist/collection/components/radio/test/radio.spec.js +46 -0
  44. package/dist/collection/components/range/test/label/range.spec.js +23 -0
  45. package/dist/collection/components/range/test/range.spec.js +205 -0
  46. package/dist/collection/components/refresher-content/test/refresher-content.spec.js +46 -0
  47. package/dist/collection/components/router/test/matching.spec.js +250 -0
  48. package/dist/collection/components/router/test/parser.spec.js +133 -0
  49. package/dist/collection/components/router/test/path.spec.js +218 -0
  50. package/dist/collection/components/router/test/router.spec.js +55 -0
  51. package/dist/collection/components/searchbar/test/searchbar.spec.js +15 -0
  52. package/dist/collection/components/segment/test/segment.spec.js +37 -0
  53. package/dist/collection/components/select/test/select.spec.js +59 -0
  54. package/dist/collection/components/textarea/test/textarea.spec.js +59 -0
  55. package/dist/collection/components/toast/test/toast-id.spec.js +32 -0
  56. package/dist/collection/components/toast/test/toast.spec.js +120 -0
  57. package/dist/collection/components/toggle/test/toggle.spec.js +55 -0
  58. package/dist/collection/global/test/config-controller.spec.js +77 -0
  59. package/dist/collection/utils/animation/test/animation.spec.js +431 -0
  60. package/dist/collection/utils/keyboard/test/keyboard-controller.spec.js +21 -0
  61. package/dist/collection/utils/keyboard/test/keyboard.spec.js +214 -0
  62. package/dist/collection/utils/sanitization/test/sanitization.spec.js +43 -0
  63. package/dist/collection/utils/test/aria.spec.js +79 -0
  64. package/dist/collection/utils/test/attributes.spec.js +53 -0
  65. package/dist/collection/utils/test/hardware-back-button.spec.js +53 -0
  66. package/dist/collection/utils/test/overlays/overlays.spec.js +102 -0
  67. package/dist/collection/utils/test/platform.spec.js +132 -0
  68. package/dist/collection/utils/test/ready.spec.js +39 -0
  69. package/dist/collection/utils/test/theme.spec.js +56 -0
  70. package/dist/docs.json +21 -21
  71. package/dist/esm/ion-datetime_3.entry.js +2 -2
  72. package/dist/esm-es5/ion-datetime_3.entry.js +1 -1
  73. package/dist/ionic/ionic.esm.js +1 -1
  74. package/dist/ionic/p-40903d34.system.js +1 -1
  75. package/dist/ionic/p-ad61e508.entry.js +4 -0
  76. package/dist/ionic/p-d91e93ac.system.entry.js +4 -0
  77. package/hydrate/index.js +2 -2
  78. package/package.json +2 -1
  79. package/dist/ionic/p-b76c6241.system.entry.js +0 -4
  80. package/dist/ionic/p-b781d6b2.entry.js +0 -4
@@ -0,0 +1,72 @@
1
+ /*!
2
+ * (C) Ionic http://ionicframework.com - MIT License
3
+ */
4
+ import { isLeapYear, getNumDaysInMonth, is24Hour, isMonthFirstLocale, getHourCycle } from "../utils/helpers";
5
+ describe('daysInMonth()', () => {
6
+ it('should return correct days in month for month and year', () => {
7
+ expect(getNumDaysInMonth(1, 2019)).toBe(31);
8
+ expect(getNumDaysInMonth(2, 2019)).toBe(28);
9
+ expect(getNumDaysInMonth(3, 2019)).toBe(31);
10
+ expect(getNumDaysInMonth(4, 2019)).toBe(30);
11
+ expect(getNumDaysInMonth(5, 2019)).toBe(31);
12
+ expect(getNumDaysInMonth(6, 2019)).toBe(30);
13
+ expect(getNumDaysInMonth(7, 2019)).toBe(31);
14
+ expect(getNumDaysInMonth(8, 2019)).toBe(31);
15
+ expect(getNumDaysInMonth(9, 2019)).toBe(30);
16
+ expect(getNumDaysInMonth(10, 2019)).toBe(31);
17
+ expect(getNumDaysInMonth(11, 2019)).toBe(30);
18
+ expect(getNumDaysInMonth(12, 2019)).toBe(31);
19
+ expect(getNumDaysInMonth(2, 2020)).toBe(29);
20
+ expect(getNumDaysInMonth(2, 2021)).toBe(28);
21
+ expect(getNumDaysInMonth(2, 1900)).toBe(28);
22
+ expect(getNumDaysInMonth(2, 1800)).toBe(28);
23
+ expect(getNumDaysInMonth(2, 2400)).toBe(29);
24
+ });
25
+ });
26
+ describe('isLeapYear()', () => {
27
+ it('should return true if year is leapyear', () => {
28
+ expect(isLeapYear(2096)).toBe(true);
29
+ expect(isLeapYear(2021)).toBe(false);
30
+ expect(isLeapYear(2012)).toBe(true);
31
+ expect(isLeapYear(2000)).toBe(true);
32
+ expect(isLeapYear(1900)).toBe(false);
33
+ expect(isLeapYear(1800)).toBe(false);
34
+ });
35
+ });
36
+ describe('is24Hour()', () => {
37
+ it('should return true if the locale uses 24 hour time', () => {
38
+ expect(is24Hour('h11')).toBe(false);
39
+ expect(is24Hour('h12')).toBe(false);
40
+ expect(is24Hour('h23')).toBe(true);
41
+ expect(is24Hour('h24')).toBe(true);
42
+ });
43
+ });
44
+ describe('getHourCycle()', () => {
45
+ it('should return the correct hour cycle', () => {
46
+ expect(getHourCycle('en-US')).toBe('h12');
47
+ expect(getHourCycle('en-US', 'h23')).toBe('h23');
48
+ expect(getHourCycle('en-US', 'h12')).toBe('h12');
49
+ expect(getHourCycle('en-US-u-hc-h23')).toBe('h23');
50
+ expect(getHourCycle('en-GB')).toBe('h23');
51
+ expect(getHourCycle('en-GB', 'h23')).toBe('h23');
52
+ expect(getHourCycle('en-GB', 'h12')).toBe('h12');
53
+ expect(getHourCycle('en-GB-u-hc-h12')).toBe('h12');
54
+ expect(getHourCycle('en-GB', 'h11')).toBe('h11');
55
+ expect(getHourCycle('en-GB-u-hc-h11')).toBe('h11');
56
+ expect(getHourCycle('en-GB', 'h24')).toBe('h24');
57
+ expect(getHourCycle('en-GB-u-hc-h24')).toBe('h24');
58
+ });
59
+ });
60
+ describe('isMonthFirstLocale()', () => {
61
+ it('should return true if the locale shows months first', () => {
62
+ expect(isMonthFirstLocale('en-US')).toBe(true);
63
+ expect(isMonthFirstLocale('en-GB')).toBe(true);
64
+ expect(isMonthFirstLocale('es-ES')).toBe(true);
65
+ expect(isMonthFirstLocale('ro-RO')).toBe(true);
66
+ });
67
+ it('should return false if the locale shows years first', () => {
68
+ expect(isMonthFirstLocale('zh-CN')).toBe(false);
69
+ expect(isMonthFirstLocale('ja-JP')).toBe(false);
70
+ expect(isMonthFirstLocale('ko-KR')).toBe(false);
71
+ });
72
+ });
@@ -0,0 +1,433 @@
1
+ /*!
2
+ * (C) Ionic http://ionicframework.com - MIT License
3
+ */
4
+ import { getPreviousYear, getNextYear, getPreviousMonth, getNextMonth, getPreviousDay, getNextDay, getPreviousWeek, getNextWeek, getEndOfWeek, getStartOfWeek, convert12HourTo24Hour, getInternalHourValue, calculateHourFromAMPM, subtractDays, addDays, validateParts, } from "../utils/manipulation";
5
+ describe('addDays()', () => {
6
+ it('should correctly add days', () => {
7
+ expect(addDays({
8
+ day: 1,
9
+ month: 1,
10
+ year: 2021,
11
+ }, 31)).toEqual({
12
+ day: 1,
13
+ month: 2,
14
+ year: 2021,
15
+ });
16
+ expect(addDays({
17
+ day: 31,
18
+ month: 12,
19
+ year: 2021,
20
+ }, 1)).toEqual({
21
+ day: 1,
22
+ month: 1,
23
+ year: 2022,
24
+ });
25
+ });
26
+ });
27
+ describe('subtractDays()', () => {
28
+ it('should correctly subtract days', () => {
29
+ expect(subtractDays({
30
+ day: 1,
31
+ month: 1,
32
+ year: 2021,
33
+ }, 1)).toEqual({
34
+ day: 31,
35
+ month: 12,
36
+ year: 2020,
37
+ });
38
+ expect(subtractDays({
39
+ day: 1,
40
+ month: 2,
41
+ year: 2021,
42
+ }, 31)).toEqual({
43
+ day: 1,
44
+ month: 1,
45
+ year: 2021,
46
+ });
47
+ });
48
+ });
49
+ describe('getInternalHourValue()', () => {
50
+ it('should correctly get the internal hour value', () => {
51
+ expect(getInternalHourValue(12, true)).toEqual(12);
52
+ expect(getInternalHourValue(12, true)).toEqual(12);
53
+ expect(getInternalHourValue(12, false, 'am')).toEqual(0);
54
+ expect(getInternalHourValue(12, false, 'pm')).toEqual(12);
55
+ expect(getInternalHourValue(1, true)).toEqual(1);
56
+ expect(getInternalHourValue(1, true)).toEqual(1);
57
+ expect(getInternalHourValue(1, false, 'am')).toEqual(1);
58
+ expect(getInternalHourValue(1, false, 'pm')).toEqual(13);
59
+ });
60
+ });
61
+ describe('calculateHourFromAMPM()', () => {
62
+ it('should correctly convert from AM to PM', () => {
63
+ expect(calculateHourFromAMPM({ hour: 12, ampm: 'am' }, 'pm')).toEqual(12);
64
+ expect(calculateHourFromAMPM({ hour: 1, ampm: 'am' }, 'pm')).toEqual(13);
65
+ expect(calculateHourFromAMPM({ hour: 2, ampm: 'am' }, 'pm')).toEqual(14);
66
+ expect(calculateHourFromAMPM({ hour: 3, ampm: 'am' }, 'pm')).toEqual(15);
67
+ expect(calculateHourFromAMPM({ hour: 4, ampm: 'am' }, 'pm')).toEqual(16);
68
+ expect(calculateHourFromAMPM({ hour: 5, ampm: 'am' }, 'pm')).toEqual(17);
69
+ expect(calculateHourFromAMPM({ hour: 6, ampm: 'am' }, 'pm')).toEqual(18);
70
+ expect(calculateHourFromAMPM({ hour: 7, ampm: 'am' }, 'pm')).toEqual(19);
71
+ expect(calculateHourFromAMPM({ hour: 8, ampm: 'am' }, 'pm')).toEqual(20);
72
+ expect(calculateHourFromAMPM({ hour: 9, ampm: 'am' }, 'pm')).toEqual(21);
73
+ expect(calculateHourFromAMPM({ hour: 10, ampm: 'am' }, 'pm')).toEqual(22);
74
+ expect(calculateHourFromAMPM({ hour: 11, ampm: 'am' }, 'pm')).toEqual(23);
75
+ expect(calculateHourFromAMPM({ hour: 13, ampm: 'pm' }, 'am')).toEqual(1);
76
+ expect(calculateHourFromAMPM({ hour: 14, ampm: 'pm' }, 'am')).toEqual(2);
77
+ expect(calculateHourFromAMPM({ hour: 15, ampm: 'pm' }, 'am')).toEqual(3);
78
+ expect(calculateHourFromAMPM({ hour: 16, ampm: 'pm' }, 'am')).toEqual(4);
79
+ expect(calculateHourFromAMPM({ hour: 17, ampm: 'pm' }, 'am')).toEqual(5);
80
+ expect(calculateHourFromAMPM({ hour: 18, ampm: 'pm' }, 'am')).toEqual(6);
81
+ expect(calculateHourFromAMPM({ hour: 19, ampm: 'pm' }, 'am')).toEqual(7);
82
+ expect(calculateHourFromAMPM({ hour: 20, ampm: 'pm' }, 'am')).toEqual(8);
83
+ expect(calculateHourFromAMPM({ hour: 21, ampm: 'pm' }, 'am')).toEqual(9);
84
+ expect(calculateHourFromAMPM({ hour: 22, ampm: 'pm' }, 'am')).toEqual(10);
85
+ expect(calculateHourFromAMPM({ hour: 23, ampm: 'pm' }, 'am')).toEqual(11);
86
+ expect(calculateHourFromAMPM({ hour: 0, ampm: 'pm' }, 'am')).toEqual(12);
87
+ });
88
+ });
89
+ describe('convert12HourTo24Hour()', () => {
90
+ it('should correctly convert 12 hour to 24 hour', () => {
91
+ expect(convert12HourTo24Hour(12, 'am')).toEqual(0);
92
+ expect(convert12HourTo24Hour(1, 'am')).toEqual(1);
93
+ expect(convert12HourTo24Hour(2, 'am')).toEqual(2);
94
+ expect(convert12HourTo24Hour(3, 'am')).toEqual(3);
95
+ expect(convert12HourTo24Hour(4, 'am')).toEqual(4);
96
+ expect(convert12HourTo24Hour(5, 'am')).toEqual(5);
97
+ expect(convert12HourTo24Hour(6, 'am')).toEqual(6);
98
+ expect(convert12HourTo24Hour(7, 'am')).toEqual(7);
99
+ expect(convert12HourTo24Hour(8, 'am')).toEqual(8);
100
+ expect(convert12HourTo24Hour(9, 'am')).toEqual(9);
101
+ expect(convert12HourTo24Hour(10, 'am')).toEqual(10);
102
+ expect(convert12HourTo24Hour(11, 'am')).toEqual(11);
103
+ expect(convert12HourTo24Hour(12, 'pm')).toEqual(12);
104
+ expect(convert12HourTo24Hour(1, 'pm')).toEqual(13);
105
+ expect(convert12HourTo24Hour(2, 'pm')).toEqual(14);
106
+ expect(convert12HourTo24Hour(3, 'pm')).toEqual(15);
107
+ expect(convert12HourTo24Hour(4, 'pm')).toEqual(16);
108
+ expect(convert12HourTo24Hour(5, 'pm')).toEqual(17);
109
+ expect(convert12HourTo24Hour(6, 'pm')).toEqual(18);
110
+ expect(convert12HourTo24Hour(7, 'pm')).toEqual(19);
111
+ expect(convert12HourTo24Hour(8, 'pm')).toEqual(20);
112
+ expect(convert12HourTo24Hour(9, 'pm')).toEqual(21);
113
+ expect(convert12HourTo24Hour(10, 'pm')).toEqual(22);
114
+ expect(convert12HourTo24Hour(11, 'pm')).toEqual(23);
115
+ });
116
+ });
117
+ describe('getStartOfWeek()', () => {
118
+ it('should correctly return the start of the week', () => {
119
+ expect(getStartOfWeek({
120
+ month: 5,
121
+ day: 17,
122
+ year: 2021,
123
+ dayOfWeek: 1,
124
+ })).toEqual({
125
+ month: 5,
126
+ day: 16,
127
+ year: 2021,
128
+ });
129
+ expect(getStartOfWeek({
130
+ month: 5,
131
+ day: 1,
132
+ year: 2021,
133
+ dayOfWeek: 6,
134
+ })).toEqual({
135
+ month: 4,
136
+ day: 25,
137
+ year: 2021,
138
+ });
139
+ expect(getStartOfWeek({
140
+ month: 1,
141
+ day: 2,
142
+ year: 2021,
143
+ dayOfWeek: 6,
144
+ })).toEqual({
145
+ month: 12,
146
+ day: 27,
147
+ year: 2020,
148
+ });
149
+ });
150
+ });
151
+ describe('getEndOfWeek()', () => {
152
+ it('should correctly return the end of the week', () => {
153
+ expect(getEndOfWeek({
154
+ month: 5,
155
+ day: 17,
156
+ year: 2021,
157
+ dayOfWeek: 1,
158
+ })).toEqual({
159
+ month: 5,
160
+ day: 22,
161
+ year: 2021,
162
+ });
163
+ expect(getEndOfWeek({
164
+ month: 5,
165
+ day: 31,
166
+ year: 2021,
167
+ dayOfWeek: 1,
168
+ })).toEqual({
169
+ month: 6,
170
+ day: 5,
171
+ year: 2021,
172
+ });
173
+ expect(getEndOfWeek({
174
+ month: 12,
175
+ day: 29,
176
+ year: 2021,
177
+ dayOfWeek: 3,
178
+ })).toEqual({
179
+ month: 1,
180
+ day: 1,
181
+ year: 2022,
182
+ });
183
+ });
184
+ });
185
+ describe('getNextWeek()', () => {
186
+ it('should correctly return the next week', () => {
187
+ expect(getNextWeek({
188
+ month: 5,
189
+ day: 17,
190
+ year: 2021,
191
+ })).toEqual({
192
+ month: 5,
193
+ day: 24,
194
+ year: 2021,
195
+ });
196
+ expect(getNextWeek({
197
+ month: 5,
198
+ day: 31,
199
+ year: 2021,
200
+ })).toEqual({
201
+ month: 6,
202
+ day: 7,
203
+ year: 2021,
204
+ });
205
+ expect(getNextWeek({
206
+ month: 12,
207
+ day: 29,
208
+ year: 2021,
209
+ })).toEqual({
210
+ month: 1,
211
+ day: 5,
212
+ year: 2022,
213
+ });
214
+ });
215
+ });
216
+ describe('getPreviousWeek()', () => {
217
+ it('should correctly return the previous week', () => {
218
+ expect(getPreviousWeek({
219
+ month: 5,
220
+ day: 17,
221
+ year: 2021,
222
+ })).toEqual({
223
+ month: 5,
224
+ day: 10,
225
+ year: 2021,
226
+ });
227
+ expect(getPreviousWeek({
228
+ month: 5,
229
+ day: 1,
230
+ year: 2021,
231
+ })).toEqual({
232
+ month: 4,
233
+ day: 24,
234
+ year: 2021,
235
+ });
236
+ expect(getPreviousWeek({
237
+ month: 1,
238
+ day: 4,
239
+ year: 2021,
240
+ })).toEqual({
241
+ month: 12,
242
+ day: 28,
243
+ year: 2020,
244
+ });
245
+ });
246
+ });
247
+ describe('getNextDay()', () => {
248
+ it('should correctly return the next day', () => {
249
+ expect(getNextDay({
250
+ month: 5,
251
+ day: 17,
252
+ year: 2021,
253
+ })).toEqual({
254
+ month: 5,
255
+ day: 18,
256
+ year: 2021,
257
+ });
258
+ expect(getNextDay({
259
+ month: 5,
260
+ day: 31,
261
+ year: 2021,
262
+ })).toEqual({
263
+ month: 6,
264
+ day: 1,
265
+ year: 2021,
266
+ });
267
+ expect(getNextDay({
268
+ month: 12,
269
+ day: 31,
270
+ year: 2021,
271
+ })).toEqual({
272
+ month: 1,
273
+ day: 1,
274
+ year: 2022,
275
+ });
276
+ });
277
+ });
278
+ describe('getPreviousDay()', () => {
279
+ it('should correctly return the previous day', () => {
280
+ expect(getPreviousDay({
281
+ month: 5,
282
+ day: 17,
283
+ year: 2021,
284
+ })).toEqual({
285
+ month: 5,
286
+ day: 16,
287
+ year: 2021,
288
+ });
289
+ expect(getPreviousDay({
290
+ month: 5,
291
+ day: 1,
292
+ year: 2021,
293
+ })).toEqual({
294
+ month: 4,
295
+ day: 30,
296
+ year: 2021,
297
+ });
298
+ expect(getPreviousDay({
299
+ month: 1,
300
+ day: 1,
301
+ year: 2021,
302
+ })).toEqual({
303
+ month: 12,
304
+ day: 31,
305
+ year: 2020,
306
+ });
307
+ });
308
+ });
309
+ describe('getNextMonth()', () => {
310
+ it('should return correct next month', () => {
311
+ expect(getNextMonth({ month: 5, year: 2021, day: 1 })).toEqual({
312
+ month: 6,
313
+ year: 2021,
314
+ day: 1,
315
+ });
316
+ expect(getNextMonth({ month: 12, year: 2021, day: 30 })).toEqual({
317
+ month: 1,
318
+ year: 2022,
319
+ day: 30,
320
+ });
321
+ expect(getNextMonth({ month: 12, year: 1999, day: 30 })).toEqual({
322
+ month: 1,
323
+ year: 2000,
324
+ day: 30,
325
+ });
326
+ });
327
+ });
328
+ describe('getPreviousMonth()', () => {
329
+ it('should return correct previous month', () => {
330
+ expect(getPreviousMonth({ month: 5, year: 2021, day: 1 })).toEqual({
331
+ month: 4,
332
+ year: 2021,
333
+ day: 1,
334
+ });
335
+ expect(getPreviousMonth({ month: 1, year: 2021, day: 30 })).toEqual({
336
+ month: 12,
337
+ year: 2020,
338
+ day: 30,
339
+ });
340
+ expect(getPreviousMonth({ month: 1, year: 2000, day: 30 })).toEqual({
341
+ month: 12,
342
+ year: 1999,
343
+ day: 30,
344
+ });
345
+ });
346
+ });
347
+ describe('getNextYear()', () => {
348
+ it('should return correct next year', () => {
349
+ expect(getNextYear({ month: 5, year: 2021, day: 1 })).toEqual({
350
+ month: 5,
351
+ year: 2022,
352
+ day: 1,
353
+ });
354
+ expect(getNextYear({ month: 12, year: 1999, day: 30 })).toEqual({
355
+ month: 12,
356
+ year: 2000,
357
+ day: 30,
358
+ });
359
+ // Leap year
360
+ expect(getNextYear({ month: 2, year: 2024, day: 29 })).toEqual({
361
+ month: 2,
362
+ year: 2025,
363
+ day: 28,
364
+ });
365
+ });
366
+ });
367
+ describe('getPreviousYear()', () => {
368
+ it('should return correct next year', () => {
369
+ expect(getPreviousYear({ month: 5, year: 2021, day: 1 })).toEqual({
370
+ month: 5,
371
+ year: 2020,
372
+ day: 1,
373
+ });
374
+ expect(getPreviousYear({ month: 12, year: 1999, day: 30 })).toEqual({
375
+ month: 12,
376
+ year: 1998,
377
+ day: 30,
378
+ });
379
+ // Leap year
380
+ expect(getPreviousYear({ month: 2, year: 2024, day: 29 })).toEqual({
381
+ month: 2,
382
+ year: 2023,
383
+ day: 28,
384
+ });
385
+ });
386
+ });
387
+ describe('validateParts()', () => {
388
+ it('should move day in bounds', () => {
389
+ expect(validateParts({ month: 2, day: 31, year: 2022, hour: 8, minute: 0 })).toEqual({
390
+ month: 2,
391
+ day: 28,
392
+ year: 2022,
393
+ hour: 8,
394
+ minute: 0,
395
+ });
396
+ });
397
+ it('should move the hour back in bounds according to the min', () => {
398
+ expect(validateParts({ month: 1, day: 1, year: 2022, hour: 8, minute: 0 }, { month: 1, day: 1, year: 2022, hour: 9, minute: 0 })).toEqual({ month: 1, day: 1, year: 2022, hour: 9, minute: 0 });
399
+ });
400
+ it('should move the minute back in bounds according to the min', () => {
401
+ expect(validateParts({ month: 1, day: 1, year: 2022, hour: 9, minute: 20 }, { month: 1, day: 1, year: 2022, hour: 9, minute: 30 })).toEqual({ month: 1, day: 1, year: 2022, hour: 9, minute: 30 });
402
+ });
403
+ it('should move the hour and minute back in bounds according to the min', () => {
404
+ expect(validateParts({ month: 1, day: 1, year: 2022, hour: 8, minute: 30 }, { month: 1, day: 1, year: 2022, hour: 9, minute: 0 })).toEqual({ month: 1, day: 1, year: 2022, hour: 9, minute: 0 });
405
+ });
406
+ it('should move the hour back in bounds according to the max', () => {
407
+ expect(validateParts({ month: 1, day: 1, year: 2022, hour: 10, minute: 0 }, undefined, {
408
+ month: 1,
409
+ day: 1,
410
+ year: 2022,
411
+ hour: 9,
412
+ minute: 0,
413
+ })).toEqual({ month: 1, day: 1, year: 2022, hour: 9, minute: 0 });
414
+ });
415
+ it('should move the minute back in bounds according to the max', () => {
416
+ expect(validateParts({ month: 1, day: 1, year: 2022, hour: 9, minute: 40 }, undefined, {
417
+ month: 1,
418
+ day: 1,
419
+ year: 2022,
420
+ hour: 9,
421
+ minute: 30,
422
+ })).toEqual({ month: 1, day: 1, year: 2022, hour: 9, minute: 30 });
423
+ });
424
+ it('should move the hour and minute back in bounds according to the max', () => {
425
+ expect(validateParts({ month: 1, day: 1, year: 2022, hour: 10, minute: 20 }, undefined, {
426
+ month: 1,
427
+ day: 1,
428
+ year: 2022,
429
+ hour: 9,
430
+ minute: 30,
431
+ })).toEqual({ month: 1, day: 1, year: 2022, hour: 9, minute: 30 });
432
+ });
433
+ });