@mui/x-date-pickers 6.3.0 → 6.4.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.
Files changed (205) hide show
  1. package/AdapterDateFns/AdapterDateFns.d.ts +3 -7
  2. package/AdapterDateFns/AdapterDateFns.js +2 -8
  3. package/AdapterDateFnsJalali/AdapterDateFnsJalali.d.ts +3 -7
  4. package/AdapterDateFnsJalali/AdapterDateFnsJalali.js +2 -8
  5. package/AdapterDayjs/AdapterDayjs.d.ts +3 -9
  6. package/AdapterDayjs/AdapterDayjs.js +2 -3
  7. package/AdapterLuxon/AdapterLuxon.d.ts +3 -8
  8. package/AdapterLuxon/AdapterLuxon.js +6 -5
  9. package/AdapterMoment/AdapterMoment.d.ts +3 -9
  10. package/AdapterMoment/AdapterMoment.js +2 -2
  11. package/AdapterMomentHijri/AdapterMomentHijri.d.ts +5 -14
  12. package/AdapterMomentHijri/AdapterMomentHijri.js +4 -10
  13. package/AdapterMomentJalaali/AdapterMomentJalaali.d.ts +6 -16
  14. package/AdapterMomentJalaali/AdapterMomentJalaali.js +15 -12
  15. package/CHANGELOG.md +105 -2
  16. package/DateCalendar/DateCalendar.js +2 -2
  17. package/DateCalendar/DayCalendar.js +11 -10
  18. package/DateCalendar/PickersCalendarHeader.js +2 -2
  19. package/DateCalendar/useCalendarState.d.ts +1 -1
  20. package/DateField/DateField.js +4 -0
  21. package/DatePicker/shared.d.ts +1 -1
  22. package/DateTimeField/DateTimeField.js +4 -0
  23. package/DateTimeField/DateTimeField.types.d.ts +2 -10
  24. package/DateTimePicker/shared.d.ts +5 -12
  25. package/DesktopTimePicker/DesktopTimePicker.js +4 -2
  26. package/LocalizationProvider/LocalizationProvider.d.ts +10 -8
  27. package/LocalizationProvider/LocalizationProvider.js +3 -3
  28. package/MonthCalendar/MonthCalendar.js +2 -2
  29. package/TimeClock/TimeClock.types.d.ts +2 -1
  30. package/TimeField/TimeField.js +4 -0
  31. package/index.js +1 -1
  32. package/internals/hooks/useField/useField.utils.d.ts +13 -13
  33. package/internals/hooks/useField/useField.utils.js +5 -4
  34. package/internals/hooks/useField/useFieldState.js +2 -2
  35. package/internals/hooks/usePicker/usePickerViews.d.ts +2 -2
  36. package/internals/hooks/useUtils.d.ts +1 -1
  37. package/internals/index.d.ts +1 -1
  38. package/internals/models/props/clock.d.ts +1 -1
  39. package/internals/models/validation.d.ts +13 -0
  40. package/internals/utils/date-utils.d.ts +6 -4
  41. package/internals/utils/date-utils.js +16 -0
  42. package/internals/utils/time-utils.d.ts +4 -4
  43. package/internals/utils/validation/extractValidationProps.d.ts +1 -1
  44. package/internals/utils/validation/extractValidationProps.js +1 -1
  45. package/legacy/AdapterDateFns/AdapterDateFns.js +2 -8
  46. package/legacy/AdapterDateFnsJalali/AdapterDateFnsJalali.js +2 -8
  47. package/legacy/AdapterDayjs/AdapterDayjs.js +2 -3
  48. package/legacy/AdapterLuxon/AdapterLuxon.js +6 -5
  49. package/legacy/AdapterMoment/AdapterMoment.js +2 -2
  50. package/legacy/AdapterMomentHijri/AdapterMomentHijri.js +4 -10
  51. package/legacy/AdapterMomentJalaali/AdapterMomentJalaali.js +15 -12
  52. package/legacy/DateCalendar/DateCalendar.js +2 -2
  53. package/legacy/DateCalendar/DayCalendar.js +11 -10
  54. package/legacy/DateCalendar/PickersCalendarHeader.js +2 -2
  55. package/legacy/DateField/DateField.js +4 -0
  56. package/legacy/DateTimeField/DateTimeField.js +4 -0
  57. package/legacy/DesktopTimePicker/DesktopTimePicker.js +4 -2
  58. package/legacy/LocalizationProvider/LocalizationProvider.js +3 -3
  59. package/legacy/MonthCalendar/MonthCalendar.js +2 -2
  60. package/legacy/TimeField/TimeField.js +4 -0
  61. package/legacy/index.js +1 -1
  62. package/legacy/internals/hooks/useField/useField.utils.js +7 -6
  63. package/legacy/internals/hooks/useField/useFieldState.js +2 -2
  64. package/legacy/internals/utils/date-utils.js +16 -0
  65. package/legacy/internals/utils/validation/extractValidationProps.js +1 -1
  66. package/legacy/locales/csCZ.js +3 -3
  67. package/legacy/locales/index.js +1 -0
  68. package/legacy/locales/skSK.js +93 -0
  69. package/legacy/locales/ukUA.js +3 -1
  70. package/legacy/tests/describeGregorianAdapter/describeGregorianAdapter.js +2 -7
  71. package/legacy/tests/describeGregorianAdapter/describeGregorianAdapter.utils.js +2 -0
  72. package/legacy/tests/describeGregorianAdapter/index.js +2 -1
  73. package/legacy/tests/describeGregorianAdapter/testCalculations.js +272 -200
  74. package/legacy/tests/describeGregorianAdapter/testLocalization.js +34 -0
  75. package/legacy/tests/describeHijriAdapter/describeHijriAdapter.js +1 -3
  76. package/legacy/tests/describeHijriAdapter/testCalculations.js +101 -28
  77. package/legacy/tests/describeHijriAdapter/testLocalization.js +8 -0
  78. package/legacy/tests/describeJalaliAdapter/describeJalaliAdapter.js +2 -6
  79. package/legacy/tests/describeJalaliAdapter/testCalculations.js +157 -24
  80. package/legacy/tests/describeJalaliAdapter/testLocalization.js +8 -0
  81. package/legacy/tests/describeValidation/testTextFieldValidation.js +26 -0
  82. package/locales/beBY.d.ts +3 -3
  83. package/locales/caES.d.ts +3 -3
  84. package/locales/csCZ.d.ts +3 -3
  85. package/locales/csCZ.js +3 -3
  86. package/locales/daDK.d.ts +3 -3
  87. package/locales/deDE.d.ts +3 -3
  88. package/locales/enUS.d.ts +3 -3
  89. package/locales/esES.d.ts +3 -3
  90. package/locales/faIR.d.ts +3 -3
  91. package/locales/fiFI.d.ts +3 -3
  92. package/locales/frFR.d.ts +3 -3
  93. package/locales/heIL.d.ts +3 -3
  94. package/locales/huHU.d.ts +3 -3
  95. package/locales/index.d.ts +1 -0
  96. package/locales/index.js +1 -0
  97. package/locales/isIS.d.ts +3 -3
  98. package/locales/itIT.d.ts +3 -3
  99. package/locales/jaJP.d.ts +3 -3
  100. package/locales/koKR.d.ts +3 -3
  101. package/locales/kzKZ.d.ts +3 -3
  102. package/locales/nbNO.d.ts +3 -3
  103. package/locales/nlNL.d.ts +3 -3
  104. package/locales/plPL.d.ts +3 -3
  105. package/locales/ptBR.d.ts +3 -3
  106. package/locales/ruRU.d.ts +3 -3
  107. package/locales/skSK.d.ts +53 -0
  108. package/locales/skSK.js +61 -0
  109. package/locales/svSE.d.ts +3 -3
  110. package/locales/trTR.d.ts +3 -3
  111. package/locales/ukUA.d.ts +3 -3
  112. package/locales/ukUA.js +1 -1
  113. package/locales/urPK.d.ts +3 -3
  114. package/locales/utils/getPickersLocalization.d.ts +3 -3
  115. package/locales/zhCN.d.ts +3 -3
  116. package/models/adapters.d.ts +43 -35
  117. package/modern/AdapterDateFns/AdapterDateFns.js +2 -8
  118. package/modern/AdapterDateFnsJalali/AdapterDateFnsJalali.js +2 -8
  119. package/modern/AdapterDayjs/AdapterDayjs.js +2 -2
  120. package/modern/AdapterLuxon/AdapterLuxon.js +6 -5
  121. package/modern/AdapterMoment/AdapterMoment.js +2 -2
  122. package/modern/AdapterMomentHijri/AdapterMomentHijri.js +4 -10
  123. package/modern/AdapterMomentJalaali/AdapterMomentJalaali.js +15 -12
  124. package/modern/DateCalendar/DateCalendar.js +2 -2
  125. package/modern/DateCalendar/DayCalendar.js +11 -10
  126. package/modern/DateCalendar/PickersCalendarHeader.js +2 -2
  127. package/modern/DateField/DateField.js +4 -0
  128. package/modern/DateTimeField/DateTimeField.js +4 -0
  129. package/modern/DesktopTimePicker/DesktopTimePicker.js +3 -1
  130. package/modern/LocalizationProvider/LocalizationProvider.js +3 -3
  131. package/modern/MonthCalendar/MonthCalendar.js +2 -2
  132. package/modern/TimeField/TimeField.js +4 -0
  133. package/modern/index.js +1 -1
  134. package/modern/internals/hooks/useField/useField.utils.js +5 -4
  135. package/modern/internals/hooks/useField/useFieldState.js +2 -2
  136. package/modern/internals/utils/date-utils.js +16 -0
  137. package/modern/internals/utils/validation/extractValidationProps.js +1 -1
  138. package/modern/locales/csCZ.js +3 -3
  139. package/modern/locales/index.js +1 -0
  140. package/modern/locales/skSK.js +58 -0
  141. package/modern/locales/ukUA.js +1 -1
  142. package/modern/tests/describeGregorianAdapter/describeGregorianAdapter.js +2 -7
  143. package/modern/tests/describeGregorianAdapter/describeGregorianAdapter.utils.js +2 -0
  144. package/modern/tests/describeGregorianAdapter/index.js +2 -1
  145. package/modern/tests/describeGregorianAdapter/testCalculations.js +272 -198
  146. package/modern/tests/describeGregorianAdapter/testLocalization.js +34 -0
  147. package/modern/tests/describeHijriAdapter/describeHijriAdapter.js +1 -3
  148. package/modern/tests/describeHijriAdapter/testCalculations.js +101 -28
  149. package/modern/tests/describeHijriAdapter/testLocalization.js +8 -0
  150. package/modern/tests/describeJalaliAdapter/describeJalaliAdapter.js +2 -6
  151. package/modern/tests/describeJalaliAdapter/testCalculations.js +157 -24
  152. package/modern/tests/describeJalaliAdapter/testLocalization.js +8 -0
  153. package/modern/tests/describeValidation/testTextFieldValidation.js +27 -0
  154. package/node/AdapterDateFns/AdapterDateFns.js +2 -8
  155. package/node/AdapterDateFnsJalali/AdapterDateFnsJalali.js +2 -8
  156. package/node/AdapterDayjs/AdapterDayjs.js +2 -2
  157. package/node/AdapterLuxon/AdapterLuxon.js +6 -5
  158. package/node/AdapterMoment/AdapterMoment.js +2 -2
  159. package/node/AdapterMomentHijri/AdapterMomentHijri.js +4 -10
  160. package/node/AdapterMomentJalaali/AdapterMomentJalaali.js +15 -12
  161. package/node/DateCalendar/DateCalendar.js +1 -1
  162. package/node/DateCalendar/DayCalendar.js +11 -10
  163. package/node/DateCalendar/PickersCalendarHeader.js +2 -2
  164. package/node/DateField/DateField.js +4 -0
  165. package/node/DateTimeField/DateTimeField.js +4 -0
  166. package/node/DesktopTimePicker/DesktopTimePicker.js +3 -1
  167. package/node/LocalizationProvider/LocalizationProvider.js +5 -5
  168. package/node/MonthCalendar/MonthCalendar.js +1 -1
  169. package/node/TimeField/TimeField.js +4 -0
  170. package/node/index.js +1 -1
  171. package/node/internals/hooks/useField/useField.utils.js +5 -4
  172. package/node/internals/hooks/useField/useFieldState.js +2 -2
  173. package/node/internals/utils/date-utils.js +20 -2
  174. package/node/internals/utils/validation/extractValidationProps.js +1 -1
  175. package/node/locales/csCZ.js +3 -3
  176. package/node/locales/index.js +11 -0
  177. package/node/locales/skSK.js +65 -0
  178. package/node/locales/ukUA.js +1 -1
  179. package/node/tests/describeGregorianAdapter/describeGregorianAdapter.js +3 -9
  180. package/node/tests/describeGregorianAdapter/describeGregorianAdapter.utils.js +10 -0
  181. package/node/tests/describeGregorianAdapter/index.js +4 -3
  182. package/node/tests/describeGregorianAdapter/testCalculations.js +272 -198
  183. package/node/tests/describeGregorianAdapter/testLocalization.js +35 -0
  184. package/node/tests/describeHijriAdapter/describeHijriAdapter.js +1 -3
  185. package/node/tests/describeHijriAdapter/testCalculations.js +100 -27
  186. package/node/tests/describeHijriAdapter/testLocalization.js +8 -0
  187. package/node/tests/describeJalaliAdapter/describeJalaliAdapter.js +2 -6
  188. package/node/tests/describeJalaliAdapter/testCalculations.js +156 -23
  189. package/node/tests/describeJalaliAdapter/testLocalization.js +8 -0
  190. package/node/tests/describeValidation/testTextFieldValidation.js +27 -0
  191. package/package.json +2 -2
  192. package/tests/describeGregorianAdapter/describeGregorianAdapter.js +2 -7
  193. package/tests/describeGregorianAdapter/describeGregorianAdapter.utils.js +2 -0
  194. package/tests/describeGregorianAdapter/index.js +2 -1
  195. package/tests/describeGregorianAdapter/testCalculations.js +272 -198
  196. package/tests/describeGregorianAdapter/testLocalization.js +34 -0
  197. package/tests/describeHijriAdapter/describeHijriAdapter.js +1 -3
  198. package/tests/describeHijriAdapter/testCalculations.js +101 -28
  199. package/tests/describeHijriAdapter/testLocalization.js +8 -0
  200. package/tests/describeJalaliAdapter/describeJalaliAdapter.js +2 -6
  201. package/tests/describeJalaliAdapter/testCalculations.js +157 -24
  202. package/tests/describeJalaliAdapter/testLocalization.js +8 -0
  203. package/tests/describeValidation/testTextFieldValidation.js +27 -0
  204. package/themeAugmentation/props.d.ts +1 -1
  205. package/timeViewRenderers/timeViewRenderers.d.ts +2 -2
@@ -9,13 +9,11 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
9
9
  var _createDescribe = _interopRequireDefault(require("@mui/monorepo/test/utils/createDescribe"));
10
10
  var _testCalculations = require("./testCalculations");
11
11
  var _testLocalization = require("./testLocalization");
12
- var _describeGregorianAdapter = require("../describeGregorianAdapter");
13
12
  function innerJalaliDescribeAdapter(Adapter, params) {
14
13
  const adapter = new Adapter();
15
14
  describe(adapter.lib, () => {
16
15
  const testSuitParams = (0, _extends2.default)({}, params, {
17
- adapter,
18
- testDate: adapter.date(_describeGregorianAdapter.TEST_DATE_ISO)
16
+ adapter
19
17
  });
20
18
  if (params.before) {
21
19
  before(params.before);
@@ -7,9 +7,9 @@ exports.testCalculations = void 0;
7
7
  var _chai = require("chai");
8
8
  var _describeGregorianAdapter = require("../describeGregorianAdapter");
9
9
  const testCalculations = ({
10
- adapter,
11
- testDate
10
+ adapter
12
11
  }) => {
12
+ const testDateIso = adapter.date(_describeGregorianAdapter.TEST_DATE_ISO_STRING);
13
13
  it('Method: date', () => {
14
14
  (0, _chai.expect)(adapter.date(null)).to.equal(null);
15
15
  });
@@ -18,56 +18,129 @@ const testCalculations = ({
18
18
  (0, _chai.expect)(adapter.parse('01/01/1395', 'iYYYY/iM/iD')).not.to.equal(null);
19
19
  });
20
20
  it('Method: isEqual', () => {
21
- const anotherDate = adapter.date(_describeGregorianAdapter.TEST_DATE_ISO);
22
- (0, _chai.expect)(adapter.isEqual(testDate, anotherDate)).to.equal(true);
21
+ const anotherDate = adapter.date(_describeGregorianAdapter.TEST_DATE_ISO_STRING);
22
+ (0, _chai.expect)(adapter.isEqual(testDateIso, anotherDate)).to.equal(true);
23
23
  (0, _chai.expect)(adapter.isEqual(null, null)).to.equal(true);
24
24
  });
25
+ it('Method: isAfter', () => {
26
+ (0, _chai.expect)(adapter.isAfter(adapter.date(), testDateIso)).to.equal(true);
27
+ (0, _chai.expect)(adapter.isAfter(testDateIso, adapter.date())).to.equal(false);
28
+ });
25
29
  it('Method: isAfterYear', () => {
26
- const afterYear = adapter.addYears(testDate, 2);
27
- (0, _chai.expect)(adapter.isAfterYear(afterYear, testDate)).to.equal(true);
30
+ const afterYear = adapter.addYears(testDateIso, 2);
31
+ (0, _chai.expect)(adapter.isAfterYear(afterYear, testDateIso)).to.equal(true);
32
+ });
33
+ it('Method: isAfterDay', () => {
34
+ const nextDayIso = adapter.addDays(testDateIso, 1);
35
+ (0, _chai.expect)(adapter.isAfterDay(nextDayIso, testDateIso)).to.equal(true);
36
+ (0, _chai.expect)(adapter.isAfterDay(testDateIso, nextDayIso)).to.equal(false);
37
+ });
38
+ it('Method: isBefore', () => {
39
+ (0, _chai.expect)(adapter.isBefore(testDateIso, adapter.date())).to.equal(true);
40
+ (0, _chai.expect)(adapter.isBefore(adapter.date(), testDateIso)).to.equal(false);
28
41
  });
29
42
  it('Method: isBeforeYear', () => {
30
- const afterYear = adapter.addYears(testDate, 2);
31
- (0, _chai.expect)(adapter.isBeforeYear(testDate, afterYear)).to.equal(true);
43
+ const afterYear = adapter.addYears(testDateIso, 2);
44
+ (0, _chai.expect)(adapter.isBeforeYear(testDateIso, afterYear)).to.equal(true);
45
+ });
46
+ it('Method: isBeforeDay', () => {
47
+ const nextDayIso = adapter.addDays(testDateIso, -1);
48
+ (0, _chai.expect)(adapter.isBeforeDay(nextDayIso, testDateIso)).to.equal(true);
49
+ (0, _chai.expect)(adapter.isBeforeDay(testDateIso, nextDayIso)).to.equal(false);
32
50
  });
33
51
  it('Method: startOfYear', () => {
34
- (0, _chai.expect)(adapter.startOfYear(testDate)).toEqualDateTime(new Date('2018-09-11T00:00:00.000Z'));
52
+ (0, _chai.expect)(adapter.startOfYear(testDateIso)).toEqualDateTime('2018-09-11T00:00:00.000Z');
53
+ });
54
+ it('Method: startOfWeek', () => {
55
+ (0, _chai.expect)(adapter.startOfWeek(testDateIso)).toEqualDateTime('2018-10-28T00:00:00.000Z');
56
+ });
57
+ it('Method: startOfDay', () => {
58
+ (0, _chai.expect)(adapter.startOfDay(testDateIso)).toEqualDateTime('2018-10-30T00:00:00.000Z');
35
59
  });
36
60
  it('Method: startOfMonth', () => {
37
- (0, _chai.expect)(adapter.startOfMonth(testDate)).toEqualDateTime(new Date('2018-10-10T00:00:00.000Z'));
61
+ (0, _chai.expect)(adapter.startOfMonth(testDateIso)).toEqualDateTime('2018-10-10T00:00:00.000Z');
38
62
  });
39
63
  it('Method: endOfYear', () => {
40
- (0, _chai.expect)(adapter.endOfYear(testDate)).toEqualDateTime(new Date('2019-08-30T23:59:59.999Z'));
64
+ (0, _chai.expect)(adapter.endOfYear(testDateIso)).toEqualDateTime('2019-08-30T23:59:59.999Z');
41
65
  });
42
66
  it('Method: endOfMonth', () => {
43
- (0, _chai.expect)(adapter.endOfMonth(testDate)).toEqualDateTime(new Date('2018-11-08T23:59:59.999Z'));
67
+ (0, _chai.expect)(adapter.endOfMonth(testDateIso)).toEqualDateTime('2018-11-08T23:59:59.999Z');
68
+ });
69
+ it('Method: endOfWeek', () => {
70
+ (0, _chai.expect)(adapter.endOfWeek(testDateIso)).toEqualDateTime('2018-11-03T23:59:59.999Z');
71
+ });
72
+ it('Method: endOfDay', () => {
73
+ (0, _chai.expect)(adapter.endOfDay(testDateIso)).toEqualDateTime('2018-10-30T23:59:59.999Z');
74
+ });
75
+ it('Method: addYears', () => {
76
+ (0, _chai.expect)(adapter.addYears(testDateIso, 2)).toEqualDateTime('2020-10-08T11:44:00.000Z');
77
+ (0, _chai.expect)(adapter.addYears(testDateIso, -2)).toEqualDateTime('2016-11-21T11:44:00.000Z');
78
+ });
79
+ it('Method: addMonths', () => {
80
+ (0, _chai.expect)(adapter.addMonths(testDateIso, 2)).toEqualDateTime('2018-12-28T11:44:00.000Z');
81
+ (0, _chai.expect)(adapter.addMonths(testDateIso, -2)).toEqualDateTime('2018-09-01T11:44:00.000Z');
82
+ (0, _chai.expect)(adapter.addMonths(testDateIso, 3)).toEqualDateTime('2019-01-27T11:44:00.000Z');
83
+ });
84
+ it('Method: addWeeks', () => {
85
+ (0, _chai.expect)(adapter.addWeeks(testDateIso, 2)).toEqualDateTime('2018-11-13T11:44:00.000Z');
86
+ (0, _chai.expect)(adapter.addWeeks(testDateIso, -2)).toEqualDateTime('2018-10-16T11:44:00.000Z');
87
+ });
88
+ it('Method: addDays', () => {
89
+ (0, _chai.expect)(adapter.addDays(testDateIso, 2)).toEqualDateTime('2018-11-01T11:44:00.000Z');
90
+ (0, _chai.expect)(adapter.addDays(testDateIso, -2)).toEqualDateTime('2018-10-28T11:44:00.000Z');
91
+ });
92
+ it('Method: addHours', () => {
93
+ (0, _chai.expect)(adapter.addHours(testDateIso, 2)).toEqualDateTime('2018-10-30T13:44:00.000Z');
94
+ (0, _chai.expect)(adapter.addHours(testDateIso, -2)).toEqualDateTime('2018-10-30T09:44:00.000Z');
95
+ (0, _chai.expect)(adapter.addHours(testDateIso, 15)).toEqualDateTime('2018-10-31T02:44:00.000Z');
96
+ });
97
+ it('Method: addMinutes', () => {
98
+ (0, _chai.expect)(adapter.addMinutes(testDateIso, 2)).toEqualDateTime('2018-10-30T11:46:00.000Z');
99
+ (0, _chai.expect)(adapter.addMinutes(testDateIso, -2)).toEqualDateTime('2018-10-30T11:42:00.000Z');
100
+ (0, _chai.expect)(adapter.addMinutes(testDateIso, 20)).toEqualDateTime('2018-10-30T12:04:00.000Z');
101
+ });
102
+ it('Method: addSeconds', () => {
103
+ (0, _chai.expect)(adapter.addSeconds(testDateIso, 2)).toEqualDateTime('2018-10-30T11:44:02.000Z');
104
+ (0, _chai.expect)(adapter.addSeconds(testDateIso, -2)).toEqualDateTime('2018-10-30T11:43:58.000Z');
105
+ (0, _chai.expect)(adapter.addSeconds(testDateIso, 70)).toEqualDateTime('2018-10-30T11:45:10.000Z');
44
106
  });
45
107
  it('Method: getYear', () => {
46
- (0, _chai.expect)(adapter.getYear(testDate)).to.equal(1440);
108
+ (0, _chai.expect)(adapter.getYear(testDateIso)).to.equal(1440);
47
109
  });
48
110
  it('Method: getMonth', () => {
49
- (0, _chai.expect)(adapter.getMonth(testDate)).to.equal(1);
111
+ (0, _chai.expect)(adapter.getMonth(testDateIso)).to.equal(1);
50
112
  });
51
113
  it('Method: getDate', () => {
52
- (0, _chai.expect)(adapter.getDate(testDate)).to.equal(21);
114
+ (0, _chai.expect)(adapter.getDate(testDateIso)).to.equal(21);
53
115
  });
54
116
  it('Method: setYear', () => {
55
- (0, _chai.expect)(adapter.setYear(testDate, 1441)).toEqualDateTime(new Date('2019-10-20T11:44:00.000Z'));
117
+ (0, _chai.expect)(adapter.setYear(testDateIso, 1441)).toEqualDateTime('2019-10-20T11:44:00.000Z');
118
+ });
119
+ it('Method: setMonth', () => {
120
+ (0, _chai.expect)(adapter.setMonth(testDateIso, 4)).toEqualDateTime('2019-01-27T11:44:00.000Z');
56
121
  });
57
122
  it('Method: setDate', () => {
58
- (0, _chai.expect)(adapter.setDate(testDate, 22)).toEqualDateTime(new Date('2018-10-31T11:44:00.000Z'));
123
+ (0, _chai.expect)(adapter.setDate(testDateIso, 22)).toEqualDateTime('2018-10-31T11:44:00.000Z');
59
124
  });
60
125
  it('Method: getNextMonth', () => {
61
- (0, _chai.expect)(adapter.getNextMonth(testDate)).toEqualDateTime(new Date('2018-11-29T11:44:00.000Z'));
126
+ (0, _chai.expect)(adapter.getNextMonth(testDateIso)).toEqualDateTime('2018-11-29T11:44:00.000Z');
62
127
  });
63
128
  it('Method: getPreviousMonth', () => {
64
- (0, _chai.expect)(adapter.getPreviousMonth(testDate)).toEqualDateTime(new Date('2018-10-01T11:44:00.000Z'));
129
+ (0, _chai.expect)(adapter.getPreviousMonth(testDateIso)).toEqualDateTime(new Date('2018-10-01T11:44:00.000Z'));
130
+ });
131
+ it('Method: getMonthArray', () => {
132
+ const monthArray = adapter.getMonthArray(testDateIso);
133
+ let expectedDate = adapter.date('2018-09-11T00:00:00.000Z');
134
+ monthArray.forEach(month => {
135
+ (0, _chai.expect)(month).toEqualDateTime(expectedDate);
136
+ expectedDate = adapter.addMonths(expectedDate, 1);
137
+ });
65
138
  });
66
139
  it('Method: getWeekdays', () => {
67
140
  (0, _chai.expect)(adapter.getWeekdays()).to.deep.equal(['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س']);
68
141
  });
69
142
  it('Method: getWeekArray', () => {
70
- const weekArray = adapter.getWeekArray(testDate);
143
+ const weekArray = adapter.getWeekArray(testDateIso);
71
144
  const expectedDate = new Date('2018-10-07T00:00:00.000Z');
72
145
  weekArray.forEach(week => {
73
146
  week.forEach(day => {
@@ -77,21 +150,21 @@ const testCalculations = ({
77
150
  });
78
151
  });
79
152
  it('Method: getWeekNumber', () => {
80
- (0, _chai.expect)(adapter.getWeekNumber(testDate)).to.equal(8);
153
+ (0, _chai.expect)(adapter.getWeekNumber(testDateIso)).to.equal(8);
81
154
  });
82
155
  describe('Method: getYearRange', () => {
83
156
  it('Minimum limit', () => {
84
- const anotherYear = adapter.setYear(testDate, 1355);
85
- (0, _chai.expect)(() => adapter.getYearRange(anotherYear, testDate)).to.throw('min date must be on or after 1356-01-01 H (1937-03-14)');
157
+ const anotherYear = adapter.setYear(testDateIso, 1355);
158
+ (0, _chai.expect)(() => adapter.getYearRange(anotherYear, testDateIso)).to.throw('min date must be on or after 1356-01-01 H (1937-03-14)');
86
159
  });
87
160
  it('Maximum limit', () => {
88
- const anotherYear = adapter.setYear(testDate, 1500);
89
- (0, _chai.expect)(() => adapter.getYearRange(testDate, anotherYear)).to.throw('max date must be on or before 1499-12-29 H (2076-11-26)');
161
+ const anotherYear = adapter.setYear(testDateIso, 1500);
162
+ (0, _chai.expect)(() => adapter.getYearRange(testDateIso, anotherYear)).to.throw('max date must be on or before 1499-12-29 H (2076-11-26)');
90
163
  });
91
164
  });
92
165
  it('Method: getYearRange', () => {
93
- const anotherDate = adapter.setYear(testDate, 1445);
94
- const yearRange = adapter.getYearRange(testDate, anotherDate);
166
+ const anotherDate = adapter.setYear(testDateIso, 1445);
167
+ const yearRange = adapter.getYearRange(testDateIso, anotherDate);
95
168
  (0, _chai.expect)(yearRange).to.have.length(6);
96
169
  });
97
170
  };
@@ -16,5 +16,13 @@ const testLocalization = ({
16
16
  (0, _chai.expect)(adapter.getMeridiemText('am')).to.equal('ص');
17
17
  (0, _chai.expect)(adapter.getMeridiemText('pm')).to.equal('م');
18
18
  });
19
+ it('Method: getFormatHelperText', () => {
20
+ (0, _chai.expect)(adapter.getFormatHelperText(adapter.formats.keyboardDate)).to.equal('yyyy/mm/dd');
21
+ (0, _chai.expect)(adapter.getFormatHelperText(adapter.formats.keyboardDateTime12h)).to.equal('yyyy/mm/dd hh:mm (a|p)m');
22
+ });
23
+ it('Method: getCurrentLocaleCode', () => {
24
+ // Returns the default locale
25
+ (0, _chai.expect)(adapter.getCurrentLocaleCode()).to.match(/ar/);
26
+ });
19
27
  };
20
28
  exports.testLocalization = testLocalization;
@@ -9,15 +9,11 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
9
9
  var _createDescribe = _interopRequireDefault(require("@mui/monorepo/test/utils/createDescribe"));
10
10
  var _testCalculations = require("./testCalculations");
11
11
  var _testLocalization = require("./testLocalization");
12
- var _describeGregorianAdapter = require("../describeGregorianAdapter");
13
12
  function innerJalaliDescribeAdapter(Adapter, params) {
14
- const adapter = new Adapter({
15
- locale: params.locale
16
- });
13
+ const adapter = new Adapter();
17
14
  describe(adapter.lib, () => {
18
15
  const testSuitParams = (0, _extends2.default)({}, params, {
19
- adapter,
20
- testDate: adapter.date(_describeGregorianAdapter.TEST_DATE_ISO)
16
+ adapter
21
17
  });
22
18
  if (params.before) {
23
19
  before(params.before);
@@ -7,9 +7,9 @@ exports.testCalculations = void 0;
7
7
  var _chai = require("chai");
8
8
  var _describeGregorianAdapter = require("../describeGregorianAdapter");
9
9
  const testCalculations = ({
10
- adapter,
11
- testDate
10
+ adapter
12
11
  }) => {
12
+ const testDateIso = adapter.date(_describeGregorianAdapter.TEST_DATE_ISO_STRING);
13
13
  it('Method: date', () => {
14
14
  (0, _chai.expect)(adapter.date(null)).to.equal(null);
15
15
  });
@@ -17,51 +17,184 @@ const testCalculations = ({
17
17
  (0, _chai.expect)(adapter.parse('', adapter.formats.keyboardDate)).to.equal(null);
18
18
  (0, _chai.expect)(adapter.parse('01/01/1395', adapter.formats.keyboardDate)).not.to.equal(null);
19
19
  });
20
+ it('Method: parseISO', () => {
21
+ (0, _chai.expect)(adapter.parseISO(_describeGregorianAdapter.TEST_DATE_ISO_STRING)).toEqualDateTime(testDateIso);
22
+ });
23
+ it('Method: toISO', () => {
24
+ const outputtedISO = adapter.toISO(testDateIso);
25
+ if (adapter.lib === 'date-fns-jalali') {
26
+ // date-fns never suppress useless milliseconds in the end
27
+ (0, _chai.expect)(outputtedISO).to.equal(_describeGregorianAdapter.TEST_DATE_ISO_STRING.replace('.000Z', 'Z'));
28
+ } else {
29
+ (0, _chai.expect)(outputtedISO).to.equal(_describeGregorianAdapter.TEST_DATE_ISO_STRING);
30
+ }
31
+ });
32
+ it('Method: isNull', () => {
33
+ (0, _chai.expect)(adapter.isNull(null)).to.equal(true);
34
+ (0, _chai.expect)(adapter.isNull(testDateIso)).to.equal(false);
35
+ });
36
+ describe('Method: getDiff', () => {
37
+ it('should compute the millisecond diff when there is no unit', () => {
38
+ (0, _chai.expect)(adapter.getDiff(testDateIso, adapter.date('2018-10-29T11:44:00.000Z'))).to.equal(86400000);
39
+ (0, _chai.expect)(adapter.getDiff(testDateIso, adapter.date('2018-10-31T11:44:00.000Z'))).to.equal(-86400000);
40
+ (0, _chai.expect)(adapter.getDiff(testDateIso, adapter.date('2018-10-31T11:44:00.000Z'))).to.equal(-86400000);
41
+ });
42
+ it('should compute the diff in the provided unit (ISO)', () => {
43
+ (0, _chai.expect)(adapter.getDiff(testDateIso, adapter.date('2017-09-29T11:44:00.000Z'), 'years')).to.equal(1);
44
+ (0, _chai.expect)(adapter.getDiff(testDateIso, adapter.date('2018-08-29T11:44:00.000Z'), 'months')).to.equal(2);
45
+ (0, _chai.expect)(adapter.getDiff(testDateIso, adapter.date('2018-05-29T11:44:00.000Z'), 'quarters')).to.equal(1);
46
+ (0, _chai.expect)(adapter.getDiff(testDateIso, adapter.date('2018-09-29T11:44:00.000Z'), 'days')).to.equal(31);
47
+ (0, _chai.expect)(adapter.getDiff(testDateIso, adapter.date('2018-09-29T11:44:00.000Z'), 'weeks')).to.equal(4);
48
+ (0, _chai.expect)(adapter.getDiff(testDateIso, adapter.date('2018-09-29T11:44:00.000Z'), 'hours')).to.equal(744);
49
+ (0, _chai.expect)(adapter.getDiff(testDateIso, adapter.date('2018-09-29T11:44:00.000Z'), 'minutes')).to.equal(44640);
50
+ (0, _chai.expect)(adapter.getDiff(testDateIso, adapter.date('2018-10-30T10:44:00.000Z'), 'seconds')).to.equal(3600);
51
+ (0, _chai.expect)(adapter.getDiff(testDateIso, adapter.date('2018-10-30T10:44:00.000Z'), 'milliseconds')).to.equal(3600000);
52
+ });
53
+ });
20
54
  it('Method: isEqual', () => {
21
- const anotherDate = adapter.date(_describeGregorianAdapter.TEST_DATE_ISO);
22
- (0, _chai.expect)(adapter.isEqual(testDate, anotherDate)).to.equal(true);
55
+ const anotherDate = adapter.date(_describeGregorianAdapter.TEST_DATE_ISO_STRING);
56
+ (0, _chai.expect)(adapter.isEqual(testDateIso, anotherDate)).to.equal(true);
23
57
  (0, _chai.expect)(adapter.isEqual(null, null)).to.equal(true);
24
58
  });
59
+ it('Method: isSameYear', () => {
60
+ (0, _chai.expect)(adapter.isSameYear(testDateIso, adapter.date('2018-10-01T00:00:00.000Z'))).to.equal(true);
61
+ (0, _chai.expect)(adapter.isSameYear(testDateIso, adapter.date('2019-10-01T00:00:00.000Z'))).to.equal(false);
62
+ });
63
+ it('Method: isSameMonth', () => {
64
+ (0, _chai.expect)(adapter.isSameMonth(testDateIso, adapter.date('2018-11-04T00:00:00.000Z'))).to.equal(true);
65
+ (0, _chai.expect)(adapter.isSameMonth(testDateIso, adapter.date('2019-10-01T00:00:00.000Z'))).to.equal(false);
66
+ });
67
+ it('Method: isSameDay', () => {
68
+ (0, _chai.expect)(adapter.isSameDay(testDateIso, adapter.date('2018-10-30T00:00:00.000Z'))).to.equal(true);
69
+ (0, _chai.expect)(adapter.isSameDay(testDateIso, adapter.date('2019-10-30T00:00:00.000Z'))).to.equal(false);
70
+ });
71
+ it('Method: isSameHour', () => {
72
+ (0, _chai.expect)(adapter.isSameHour(testDateIso, adapter.date('2018-10-30T11:00:00.000Z'))).to.equal(true);
73
+ (0, _chai.expect)(adapter.isSameHour(testDateIso, adapter.date('2018-10-30T12:00:00.000Z'))).to.equal(false);
74
+ });
75
+ it('Method: isAfter', () => {
76
+ (0, _chai.expect)(adapter.isAfter(adapter.date(), testDateIso)).to.equal(true);
77
+ (0, _chai.expect)(adapter.isAfter(testDateIso, adapter.date())).to.equal(false);
78
+ });
25
79
  it('Method: isAfterYear', () => {
26
- const afterYear = adapter.addYears(testDate, 2);
27
- (0, _chai.expect)(adapter.isAfterYear(afterYear, testDate)).to.equal(true);
80
+ const afterYear = adapter.addYears(testDateIso, 2);
81
+ (0, _chai.expect)(adapter.isAfterYear(afterYear, testDateIso)).to.equal(true);
82
+ });
83
+ it('Method: isAfterDay', () => {
84
+ const nextDayIso = adapter.addDays(testDateIso, 1);
85
+ (0, _chai.expect)(adapter.isAfterDay(nextDayIso, testDateIso)).to.equal(true);
86
+ (0, _chai.expect)(adapter.isAfterDay(testDateIso, nextDayIso)).to.equal(false);
87
+ });
88
+ it('Method: isBefore', () => {
89
+ (0, _chai.expect)(adapter.isBefore(testDateIso, adapter.date())).to.equal(true);
90
+ (0, _chai.expect)(adapter.isBefore(adapter.date(), testDateIso)).to.equal(false);
28
91
  });
29
92
  it('Method: isBeforeYear', () => {
30
- const afterYear = adapter.addYears(testDate, 2);
31
- (0, _chai.expect)(adapter.isBeforeYear(testDate, afterYear)).to.equal(true);
93
+ const afterYear = adapter.addYears(testDateIso, 2);
94
+ (0, _chai.expect)(adapter.isBeforeYear(testDateIso, afterYear)).to.equal(true);
95
+ });
96
+ it('Method: isBeforeDay', () => {
97
+ const nextDayIso = adapter.addDays(testDateIso, -1);
98
+ (0, _chai.expect)(adapter.isBeforeDay(nextDayIso, testDateIso)).to.equal(true);
99
+ (0, _chai.expect)(adapter.isBeforeDay(testDateIso, nextDayIso)).to.equal(false);
100
+ });
101
+ it('Method: isWithinRange', () => {
102
+ (0, _chai.expect)(adapter.isWithinRange(adapter.date('2019-10-01T00:00:00.000Z'), [adapter.date('2019-09-01T00:00:00.000Z'), adapter.date('2019-11-01T00:00:00.000Z')])).to.equal(true);
103
+ (0, _chai.expect)(adapter.isWithinRange(adapter.date('2019-12-01T00:00:00.000Z'), [adapter.date('2019-09-01T00:00:00.000Z'), adapter.date('2019-11-01T00:00:00.000Z')])).to.equal(false);
104
+ (0, _chai.expect)(adapter.isWithinRange(adapter.date('2019-10-01'), [adapter.date('2019-09-01'), adapter.date('2019-11-01')])).to.equal(true);
105
+ (0, _chai.expect)(adapter.isWithinRange(adapter.date('2019-12-01'), [adapter.date('2019-09-01'), adapter.date('2019-11-01')])).to.equal(false);
32
106
  });
33
107
  it('Method: startOfYear', () => {
34
- (0, _chai.expect)(adapter.startOfYear(testDate)).toEqualDateTime(new Date('2018-03-21T00:00:00.000Z'));
108
+ (0, _chai.expect)(adapter.startOfYear(testDateIso)).toEqualDateTime('2018-03-21T00:00:00.000Z');
35
109
  });
36
110
  it('Method: startOfMonth', () => {
37
- (0, _chai.expect)(adapter.startOfMonth(testDate)).toEqualDateTime(new Date('2018-10-23T00:00:00.000Z'));
111
+ (0, _chai.expect)(adapter.startOfMonth(testDateIso)).toEqualDateTime('2018-10-23T00:00:00.000Z');
112
+ });
113
+ it('Method: startOfWeek', () => {
114
+ (0, _chai.expect)(adapter.startOfWeek(testDateIso)).toEqualDateTime('2018-10-27T00:00:00.000Z');
115
+ });
116
+ it('Method: startOfDay', () => {
117
+ (0, _chai.expect)(adapter.startOfDay(testDateIso)).toEqualDateTime('2018-10-30T00:00:00.000Z');
38
118
  });
39
119
  it('Method: endOfYear', () => {
40
- (0, _chai.expect)(adapter.endOfYear(testDate)).toEqualDateTime(new Date('2019-03-20T23:59:59.999Z'));
120
+ (0, _chai.expect)(adapter.endOfYear(testDateIso)).toEqualDateTime('2019-03-20T23:59:59.999Z');
41
121
  });
42
122
  it('Method: endOfMonth', () => {
43
- (0, _chai.expect)(adapter.endOfMonth(testDate)).toEqualDateTime(new Date('2018-11-21T23:59:59.999Z'));
123
+ (0, _chai.expect)(adapter.endOfMonth(testDateIso)).toEqualDateTime('2018-11-21T23:59:59.999Z');
124
+ });
125
+ it('Method: endOfWeek', () => {
126
+ (0, _chai.expect)(adapter.endOfWeek(testDateIso)).toEqualDateTime('2018-11-02T23:59:59.999Z');
127
+ });
128
+ it('Method: endOfDay', () => {
129
+ (0, _chai.expect)(adapter.endOfDay(testDateIso)).toEqualDateTime('2018-10-30T23:59:59.999Z');
130
+ });
131
+ it('Method: addYears', () => {
132
+ (0, _chai.expect)(adapter.addYears(testDateIso, 2)).toEqualDateTime('2020-10-29T11:44:00.000Z');
133
+ (0, _chai.expect)(adapter.addYears(testDateIso, -2)).toEqualDateTime('2016-10-29T11:44:00.000Z');
134
+ });
135
+ it('Method: addMonths', () => {
136
+ (0, _chai.expect)(adapter.addMonths(testDateIso, 2)).toEqualDateTime('2018-12-29T11:44:00.000Z');
137
+ (0, _chai.expect)(adapter.addMonths(testDateIso, -2)).toEqualDateTime('2018-08-30T11:44:00.000Z');
138
+ (0, _chai.expect)(adapter.addMonths(testDateIso, 3)).toEqualDateTime('2019-01-28T11:44:00.000Z');
139
+ });
140
+ it('Method: addWeeks', () => {
141
+ (0, _chai.expect)(adapter.addWeeks(testDateIso, 2)).toEqualDateTime('2018-11-13T11:44:00.000Z');
142
+ (0, _chai.expect)(adapter.addWeeks(testDateIso, -2)).toEqualDateTime('2018-10-16T11:44:00.000Z');
143
+ });
144
+ it('Method: addDays', () => {
145
+ (0, _chai.expect)(adapter.addDays(testDateIso, 2)).toEqualDateTime('2018-11-01T11:44:00.000Z');
146
+ (0, _chai.expect)(adapter.addDays(testDateIso, -2)).toEqualDateTime('2018-10-28T11:44:00.000Z');
147
+ });
148
+ it('Method: addHours', () => {
149
+ (0, _chai.expect)(adapter.addHours(testDateIso, 2)).toEqualDateTime('2018-10-30T13:44:00.000Z');
150
+ (0, _chai.expect)(adapter.addHours(testDateIso, -2)).toEqualDateTime('2018-10-30T09:44:00.000Z');
151
+ (0, _chai.expect)(adapter.addHours(testDateIso, 15)).toEqualDateTime('2018-10-31T02:44:00.000Z');
152
+ });
153
+ it('Method: addMinutes', () => {
154
+ (0, _chai.expect)(adapter.addMinutes(testDateIso, 2)).toEqualDateTime('2018-10-30T11:46:00.000Z');
155
+ (0, _chai.expect)(adapter.addMinutes(testDateIso, -2)).toEqualDateTime('2018-10-30T11:42:00.000Z');
156
+ (0, _chai.expect)(adapter.addMinutes(testDateIso, 20)).toEqualDateTime('2018-10-30T12:04:00.000Z');
157
+ });
158
+ it('Method: addSeconds', () => {
159
+ (0, _chai.expect)(adapter.addSeconds(testDateIso, 2)).toEqualDateTime('2018-10-30T11:44:02.000Z');
160
+ (0, _chai.expect)(adapter.addSeconds(testDateIso, -2)).toEqualDateTime('2018-10-30T11:43:58.000Z');
161
+ (0, _chai.expect)(adapter.addSeconds(testDateIso, 70)).toEqualDateTime('2018-10-30T11:45:10.000Z');
44
162
  });
45
163
  it('Method: getYear', () => {
46
- (0, _chai.expect)(adapter.getYear(testDate)).to.equal(1397);
164
+ (0, _chai.expect)(adapter.getYear(testDateIso)).to.equal(1397);
47
165
  });
48
166
  it('Method: getMonth', () => {
49
- (0, _chai.expect)(adapter.getMonth(testDate)).to.equal(7);
167
+ (0, _chai.expect)(adapter.getMonth(testDateIso)).to.equal(7);
50
168
  });
51
169
  it('Method: getDate', () => {
52
- (0, _chai.expect)(adapter.getDate(testDate)).to.equal(8);
170
+ (0, _chai.expect)(adapter.getDate(testDateIso)).to.equal(8);
53
171
  });
54
172
  it('Method: setYear', () => {
55
- (0, _chai.expect)(adapter.setYear(testDate, 1398)).toEqualDateTime(new Date('2019-10-30T11:44:00.000Z'));
173
+ (0, _chai.expect)(adapter.setYear(testDateIso, 1398)).toEqualDateTime('2019-10-30T11:44:00.000Z');
174
+ });
175
+ it('Method: setMonth', () => {
176
+ (0, _chai.expect)(adapter.setMonth(testDateIso, 4)).toEqualDateTime('2018-07-30T11:44:00.000Z');
56
177
  });
57
178
  it('Method: setDate', () => {
58
- (0, _chai.expect)(adapter.setDate(testDate, 9)).toEqualDateTime(new Date('2018-10-31T11:44:00.000Z'));
179
+ (0, _chai.expect)(adapter.setDate(testDateIso, 9)).toEqualDateTime('2018-10-31T11:44:00.000Z');
59
180
  });
60
181
  it('Method: getNextMonth', () => {
61
- (0, _chai.expect)(adapter.getNextMonth(testDate)).toEqualDateTime(new Date('2018-11-29T11:44:00.000Z'));
182
+ (0, _chai.expect)(adapter.getNextMonth(testDateIso)).toEqualDateTime('2018-11-29T11:44:00.000Z');
62
183
  });
63
184
  it('Method: getPreviousMonth', () => {
64
- (0, _chai.expect)(adapter.getPreviousMonth(testDate)).toEqualDateTime(new Date('2018-09-30T11:44:00.000Z'));
185
+ (0, _chai.expect)(adapter.getPreviousMonth(testDateIso)).toEqualDateTime(new Date('2018-09-30T11:44:00.000Z'));
186
+ });
187
+ it('Method: getMonthArray', () => {
188
+ const monthArray = adapter.getMonthArray(testDateIso);
189
+ let expectedDate = adapter.date('2018-03-21T00:00:00.000Z');
190
+ monthArray.forEach(month => {
191
+ (0, _chai.expect)(month).toEqualDateTime(expectedDate);
192
+ expectedDate = adapter.addMonths(expectedDate, 1);
193
+ });
194
+ });
195
+ it('Method: mergeDateAndTime', () => {
196
+ const mergedDate = adapter.mergeDateAndTime(testDateIso, adapter.date('2018-01-01T14:15:16.000Z'));
197
+ (0, _chai.expect)(adapter.toJsDate(mergedDate)).toEqualDateTime('2018-10-30T14:15:16.000Z');
65
198
  });
66
199
  it('Method: getWeekdays', () => {
67
200
  // TODO: AdapterDateFnsJalali `getWeekDays` method seems broken
@@ -69,7 +202,7 @@ const testCalculations = ({
69
202
  (0, _chai.expect)(adapter.getWeekdays()).to.deep.equal(adapter.lib === 'date-fns-jalali' ? ['ش', '1ش', '2ش', '3ش', '4ش', '5ش', 'ج'] : ['ش', 'ی', 'د', 'س', 'چ', 'پ', 'ج']);
70
203
  });
71
204
  it('Method: getWeekArray', () => {
72
- const weekArray = adapter.getWeekArray(testDate);
205
+ const weekArray = adapter.getWeekArray(testDateIso);
73
206
  const expectedDate = new Date('2018-10-20T00:00:00.000Z');
74
207
  weekArray.forEach(week => {
75
208
  week.forEach(day => {
@@ -79,11 +212,11 @@ const testCalculations = ({
79
212
  });
80
213
  });
81
214
  it('Method: getWeekNumber', () => {
82
- (0, _chai.expect)(adapter.getWeekNumber(testDate)).to.equal(33);
215
+ (0, _chai.expect)(adapter.getWeekNumber(testDateIso)).to.equal(33);
83
216
  });
84
217
  it('Method: getYearRange', () => {
85
- const anotherDate = adapter.setYear(testDate, 1400);
86
- const yearRange = adapter.getYearRange(testDate, anotherDate);
218
+ const anotherDate = adapter.setYear(testDateIso, 1400);
219
+ const yearRange = adapter.getYearRange(testDateIso, anotherDate);
87
220
  (0, _chai.expect)(yearRange).to.have.length(4);
88
221
  });
89
222
  };
@@ -16,5 +16,13 @@ const testLocalization = ({
16
16
  (0, _chai.expect)(adapter.getMeridiemText('am')).to.equal('ق.ظ');
17
17
  (0, _chai.expect)(adapter.getMeridiemText('pm')).to.equal('ب.ظ');
18
18
  });
19
+ it('Method: getFormatHelperText', () => {
20
+ (0, _chai.expect)(adapter.getFormatHelperText(adapter.formats.keyboardDate)).to.equal('yyyy/mm/dd');
21
+ (0, _chai.expect)(adapter.getFormatHelperText(adapter.formats.keyboardDateTime12h)).to.equal('yyyy/mm/dd hh:mm (a|p)m');
22
+ });
23
+ it('Method: getCurrentLocaleCode', () => {
24
+ // Returns the default locale
25
+ (0, _chai.expect)(adapter.getCurrentLocaleCode()).to.match(/fa/);
26
+ });
19
27
  };
20
28
  exports.testLocalization = testLocalization;
@@ -448,6 +448,33 @@ const testTextFieldValidation = (ElementToTest, getOptions) => {
448
448
  (0, _chai.expect)(onErrorMock.lastCall.args[0]).to.equal(null);
449
449
  (0, _chai.expect)(_utils.screen.getByRole('textbox')).to.have.attribute('aria-invalid', 'false');
450
450
  });
451
+ it('should apply minutesStep', function test() {
452
+ if (['picker', 'field'].includes(componentFamily) && !withTime) {
453
+ return;
454
+ }
455
+ const onErrorMock = (0, _sinon.spy)();
456
+ const {
457
+ setProps
458
+ } = render( /*#__PURE__*/(0, _jsxRuntime.jsx)(ElementToTest, {
459
+ onError: onErrorMock,
460
+ value: _pickersUtils.adapterToUse.date(new Date(2019, 5, 15, 10, 15)),
461
+ minutesStep: 30
462
+ }));
463
+ if (withTime) {
464
+ (0, _chai.expect)(onErrorMock.callCount).to.equal(1);
465
+ (0, _chai.expect)(onErrorMock.lastCall.args[0]).to.equal('minutesStep');
466
+ (0, _chai.expect)(_utils.screen.getByRole('textbox')).to.have.attribute('aria-invalid', 'true');
467
+ setProps({
468
+ value: _pickersUtils.adapterToUse.date(new Date(2019, 5, 15, 10, 30))
469
+ });
470
+ (0, _chai.expect)(onErrorMock.callCount).to.equal(2);
471
+ (0, _chai.expect)(onErrorMock.lastCall.args[0]).to.equal(null);
472
+ (0, _chai.expect)(_utils.screen.getByRole('textbox')).to.have.attribute('aria-invalid', 'false');
473
+ } else {
474
+ (0, _chai.expect)(onErrorMock.callCount).to.equal(0);
475
+ (0, _chai.expect)(_utils.screen.getByRole('textbox')).to.have.attribute('aria-invalid', 'false');
476
+ }
477
+ });
451
478
  });
452
479
  };
453
480
  exports.testTextFieldValidation = testTextFieldValidation;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-date-pickers",
3
- "version": "6.3.0",
3
+ "version": "6.4.0",
4
4
  "description": "The community edition of the date picker components (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./node/index.js",
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@babel/runtime": "^7.21.0",
37
- "@mui/utils": "^5.12.0",
37
+ "@mui/utils": "^5.12.3",
38
38
  "@types/react-transition-group": "^4.4.5",
39
39
  "clsx": "^1.2.1",
40
40
  "prop-types": "^15.8.1",
@@ -3,16 +3,11 @@ import createDescribe from '@mui/monorepo/test/utils/createDescribe';
3
3
  import { testCalculations } from './testCalculations';
4
4
  import { testLocalization } from './testLocalization';
5
5
  import { testFormat } from './testFormat';
6
- export const TEST_DATE_ISO = '2018-10-30T11:44:00.000Z';
7
6
  function innerGregorianDescribeAdapter(Adapter, params) {
8
- const adapter = new Adapter({
9
- locale: params.locale
10
- });
7
+ const adapter = new Adapter();
11
8
  describe(adapter.lib, () => {
12
9
  const testSuitParams = _extends({}, params, {
13
- adapter,
14
- testDateISO: TEST_DATE_ISO,
15
- testDate: adapter.date(TEST_DATE_ISO)
10
+ adapter
16
11
  });
17
12
  testCalculations(testSuitParams);
18
13
  testLocalization(testSuitParams);
@@ -0,0 +1,2 @@
1
+ export const TEST_DATE_ISO_STRING = '2018-10-30T11:44:00.000Z';
2
+ export const TEST_DATE_LOCALE_STRING = '2018-10-30';
@@ -1 +1,2 @@
1
- export { describeGregorianAdapter, TEST_DATE_ISO } from './describeGregorianAdapter';
1
+ export { describeGregorianAdapter } from './describeGregorianAdapter';
2
+ export { TEST_DATE_ISO_STRING } from './describeGregorianAdapter.utils';