@mui/x-date-pickers 6.3.1 → 6.5.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 (243) 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 +113 -0
  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.types.d.ts +1 -1
  21. package/DateField/index.d.ts +1 -1
  22. package/DateField/useDateField.d.ts +1 -1
  23. package/DateField/useDateField.js +9 -46
  24. package/DatePicker/shared.d.ts +1 -1
  25. package/DateTimeField/DateTimeField.types.d.ts +1 -1
  26. package/DateTimeField/index.d.ts +1 -1
  27. package/DateTimeField/useDateTimeField.d.ts +1 -1
  28. package/DateTimeField/useDateTimeField.js +9 -60
  29. package/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -2
  30. package/DesktopTimePicker/DesktopTimePicker.js +1 -2
  31. package/LocalizationProvider/LocalizationProvider.d.ts +10 -8
  32. package/LocalizationProvider/LocalizationProvider.js +3 -3
  33. package/MobileDateTimePicker/MobileDateTimePicker.js +1 -2
  34. package/MobileTimePicker/MobileTimePicker.js +1 -2
  35. package/MonthCalendar/MonthCalendar.js +2 -2
  36. package/TimeField/index.d.ts +1 -1
  37. package/TimeField/useTimeField.d.ts +1 -1
  38. package/TimeField/useTimeField.js +9 -50
  39. package/index.js +1 -1
  40. package/internals/hooks/useField/useField.js +10 -2
  41. package/internals/hooks/useField/useField.utils.d.ts +13 -13
  42. package/internals/hooks/useField/useField.utils.js +3 -2
  43. package/internals/hooks/useUtils.d.ts +1 -1
  44. package/internals/hooks/useViews.js +2 -0
  45. package/internals/index.d.ts +2 -1
  46. package/internals/index.js +2 -1
  47. package/internals/utils/date-utils.d.ts +6 -4
  48. package/internals/utils/date-utils.js +16 -0
  49. package/internals/utils/fields.d.ts +5 -0
  50. package/internals/utils/fields.js +28 -0
  51. package/internals/utils/time-utils.d.ts +4 -4
  52. package/internals/utils/validation/extractValidationProps.d.ts +5 -1
  53. package/internals/utils/validation/extractValidationProps.js +4 -1
  54. package/legacy/AdapterDateFns/AdapterDateFns.js +2 -8
  55. package/legacy/AdapterDateFnsJalali/AdapterDateFnsJalali.js +2 -8
  56. package/legacy/AdapterDayjs/AdapterDayjs.js +2 -3
  57. package/legacy/AdapterLuxon/AdapterLuxon.js +6 -5
  58. package/legacy/AdapterMoment/AdapterMoment.js +2 -2
  59. package/legacy/AdapterMomentHijri/AdapterMomentHijri.js +4 -10
  60. package/legacy/AdapterMomentJalaali/AdapterMomentJalaali.js +15 -12
  61. package/legacy/DateCalendar/DateCalendar.js +2 -2
  62. package/legacy/DateCalendar/DayCalendar.js +11 -10
  63. package/legacy/DateCalendar/PickersCalendarHeader.js +2 -2
  64. package/legacy/DateField/useDateField.js +8 -44
  65. package/legacy/DateTimeField/useDateTimeField.js +8 -60
  66. package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -2
  67. package/legacy/DesktopTimePicker/DesktopTimePicker.js +1 -2
  68. package/legacy/LocalizationProvider/LocalizationProvider.js +3 -3
  69. package/legacy/MobileDateTimePicker/MobileDateTimePicker.js +1 -2
  70. package/legacy/MobileTimePicker/MobileTimePicker.js +1 -2
  71. package/legacy/MonthCalendar/MonthCalendar.js +2 -2
  72. package/legacy/TimeField/useTimeField.js +8 -48
  73. package/legacy/index.js +1 -1
  74. package/legacy/internals/hooks/useField/useField.js +12 -4
  75. package/legacy/internals/hooks/useField/useField.utils.js +5 -4
  76. package/legacy/internals/hooks/useViews.js +2 -0
  77. package/legacy/internals/index.js +2 -1
  78. package/legacy/internals/utils/date-utils.js +16 -0
  79. package/legacy/internals/utils/fields.js +28 -0
  80. package/legacy/internals/utils/validation/extractValidationProps.js +4 -1
  81. package/legacy/locales/csCZ.js +3 -3
  82. package/legacy/locales/index.js +1 -0
  83. package/legacy/locales/skSK.js +93 -0
  84. package/legacy/locales/ukUA.js +3 -1
  85. package/legacy/tests/describeGregorianAdapter/describeGregorianAdapter.js +2 -7
  86. package/legacy/tests/describeGregorianAdapter/describeGregorianAdapter.utils.js +2 -0
  87. package/legacy/tests/describeGregorianAdapter/index.js +2 -1
  88. package/legacy/tests/describeGregorianAdapter/testCalculations.js +272 -200
  89. package/legacy/tests/describeGregorianAdapter/testLocalization.js +34 -0
  90. package/legacy/tests/describeHijriAdapter/describeHijriAdapter.js +1 -3
  91. package/legacy/tests/describeHijriAdapter/testCalculations.js +101 -28
  92. package/legacy/tests/describeHijriAdapter/testLocalization.js +8 -0
  93. package/legacy/tests/describeJalaliAdapter/describeJalaliAdapter.js +2 -6
  94. package/legacy/tests/describeJalaliAdapter/testCalculations.js +157 -24
  95. package/legacy/tests/describeJalaliAdapter/testLocalization.js +8 -0
  96. package/legacy/tests/describeValue/describeValue.js +30 -3
  97. package/legacy/tests/describeValue/testControlledUnControlled.js +27 -21
  98. package/legacy/tests/describeValue/testPickerActionBar.js +40 -36
  99. package/legacy/tests/describeValue/testPickerOpenCloseLifeCycle.js +92 -71
  100. package/locales/beBY.d.ts +3 -3
  101. package/locales/caES.d.ts +3 -3
  102. package/locales/csCZ.d.ts +3 -3
  103. package/locales/csCZ.js +3 -3
  104. package/locales/daDK.d.ts +3 -3
  105. package/locales/deDE.d.ts +3 -3
  106. package/locales/enUS.d.ts +3 -3
  107. package/locales/esES.d.ts +3 -3
  108. package/locales/faIR.d.ts +3 -3
  109. package/locales/fiFI.d.ts +3 -3
  110. package/locales/frFR.d.ts +3 -3
  111. package/locales/heIL.d.ts +3 -3
  112. package/locales/huHU.d.ts +3 -3
  113. package/locales/index.d.ts +1 -0
  114. package/locales/index.js +1 -0
  115. package/locales/isIS.d.ts +3 -3
  116. package/locales/itIT.d.ts +3 -3
  117. package/locales/jaJP.d.ts +3 -3
  118. package/locales/koKR.d.ts +3 -3
  119. package/locales/kzKZ.d.ts +3 -3
  120. package/locales/nbNO.d.ts +3 -3
  121. package/locales/nlNL.d.ts +3 -3
  122. package/locales/plPL.d.ts +3 -3
  123. package/locales/ptBR.d.ts +3 -3
  124. package/locales/ruRU.d.ts +3 -3
  125. package/locales/skSK.d.ts +53 -0
  126. package/locales/skSK.js +61 -0
  127. package/locales/svSE.d.ts +3 -3
  128. package/locales/trTR.d.ts +3 -3
  129. package/locales/ukUA.d.ts +3 -3
  130. package/locales/ukUA.js +1 -1
  131. package/locales/urPK.d.ts +3 -3
  132. package/locales/utils/getPickersLocalization.d.ts +3 -3
  133. package/locales/zhCN.d.ts +3 -3
  134. package/models/adapters.d.ts +43 -35
  135. package/modern/AdapterDateFns/AdapterDateFns.js +2 -8
  136. package/modern/AdapterDateFnsJalali/AdapterDateFnsJalali.js +2 -8
  137. package/modern/AdapterDayjs/AdapterDayjs.js +2 -2
  138. package/modern/AdapterLuxon/AdapterLuxon.js +6 -5
  139. package/modern/AdapterMoment/AdapterMoment.js +2 -2
  140. package/modern/AdapterMomentHijri/AdapterMomentHijri.js +4 -10
  141. package/modern/AdapterMomentJalaali/AdapterMomentJalaali.js +15 -12
  142. package/modern/DateCalendar/DateCalendar.js +2 -2
  143. package/modern/DateCalendar/DayCalendar.js +11 -10
  144. package/modern/DateCalendar/PickersCalendarHeader.js +2 -2
  145. package/modern/DateField/useDateField.js +9 -46
  146. package/modern/DateTimeField/useDateTimeField.js +9 -60
  147. package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -2
  148. package/modern/DesktopTimePicker/DesktopTimePicker.js +1 -2
  149. package/modern/LocalizationProvider/LocalizationProvider.js +3 -3
  150. package/modern/MobileDateTimePicker/MobileDateTimePicker.js +1 -2
  151. package/modern/MobileTimePicker/MobileTimePicker.js +1 -2
  152. package/modern/MonthCalendar/MonthCalendar.js +2 -2
  153. package/modern/TimeField/useTimeField.js +9 -50
  154. package/modern/index.js +1 -1
  155. package/modern/internals/hooks/useField/useField.js +10 -2
  156. package/modern/internals/hooks/useField/useField.utils.js +3 -2
  157. package/modern/internals/hooks/useViews.js +2 -0
  158. package/modern/internals/index.js +2 -1
  159. package/modern/internals/utils/date-utils.js +16 -0
  160. package/modern/internals/utils/fields.js +28 -0
  161. package/modern/internals/utils/validation/extractValidationProps.js +4 -1
  162. package/modern/locales/csCZ.js +3 -3
  163. package/modern/locales/index.js +1 -0
  164. package/modern/locales/skSK.js +58 -0
  165. package/modern/locales/ukUA.js +1 -1
  166. package/modern/tests/describeGregorianAdapter/describeGregorianAdapter.js +2 -7
  167. package/modern/tests/describeGregorianAdapter/describeGregorianAdapter.utils.js +2 -0
  168. package/modern/tests/describeGregorianAdapter/index.js +2 -1
  169. package/modern/tests/describeGregorianAdapter/testCalculations.js +272 -198
  170. package/modern/tests/describeGregorianAdapter/testLocalization.js +34 -0
  171. package/modern/tests/describeHijriAdapter/describeHijriAdapter.js +1 -3
  172. package/modern/tests/describeHijriAdapter/testCalculations.js +101 -28
  173. package/modern/tests/describeHijriAdapter/testLocalization.js +8 -0
  174. package/modern/tests/describeJalaliAdapter/describeJalaliAdapter.js +2 -6
  175. package/modern/tests/describeJalaliAdapter/testCalculations.js +157 -24
  176. package/modern/tests/describeJalaliAdapter/testLocalization.js +8 -0
  177. package/modern/tests/describeValue/describeValue.js +29 -3
  178. package/modern/tests/describeValue/testControlledUnControlled.js +23 -15
  179. package/modern/tests/describeValue/testPickerActionBar.js +21 -14
  180. package/modern/tests/describeValue/testPickerOpenCloseLifeCycle.js +79 -51
  181. package/node/AdapterDateFns/AdapterDateFns.js +2 -8
  182. package/node/AdapterDateFnsJalali/AdapterDateFnsJalali.js +2 -8
  183. package/node/AdapterDayjs/AdapterDayjs.js +2 -2
  184. package/node/AdapterLuxon/AdapterLuxon.js +6 -5
  185. package/node/AdapterMoment/AdapterMoment.js +2 -2
  186. package/node/AdapterMomentHijri/AdapterMomentHijri.js +4 -10
  187. package/node/AdapterMomentJalaali/AdapterMomentJalaali.js +15 -12
  188. package/node/DateCalendar/DateCalendar.js +1 -1
  189. package/node/DateCalendar/DayCalendar.js +11 -10
  190. package/node/DateCalendar/PickersCalendarHeader.js +2 -2
  191. package/node/DateField/useDateField.js +9 -46
  192. package/node/DateTimeField/useDateTimeField.js +9 -60
  193. package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -2
  194. package/node/DesktopTimePicker/DesktopTimePicker.js +1 -2
  195. package/node/LocalizationProvider/LocalizationProvider.js +5 -5
  196. package/node/MobileDateTimePicker/MobileDateTimePicker.js +1 -2
  197. package/node/MobileTimePicker/MobileTimePicker.js +1 -2
  198. package/node/MonthCalendar/MonthCalendar.js +1 -1
  199. package/node/TimeField/useTimeField.js +9 -50
  200. package/node/index.js +1 -1
  201. package/node/internals/hooks/useField/useField.js +10 -2
  202. package/node/internals/hooks/useField/useField.utils.js +3 -2
  203. package/node/internals/hooks/useViews.js +2 -0
  204. package/node/internals/index.js +13 -0
  205. package/node/internals/utils/date-utils.js +20 -2
  206. package/node/internals/utils/fields.js +36 -0
  207. package/node/internals/utils/validation/extractValidationProps.js +8 -2
  208. package/node/locales/csCZ.js +3 -3
  209. package/node/locales/index.js +11 -0
  210. package/node/locales/skSK.js +65 -0
  211. package/node/locales/ukUA.js +1 -1
  212. package/node/tests/describeGregorianAdapter/describeGregorianAdapter.js +3 -9
  213. package/node/tests/describeGregorianAdapter/describeGregorianAdapter.utils.js +10 -0
  214. package/node/tests/describeGregorianAdapter/index.js +4 -3
  215. package/node/tests/describeGregorianAdapter/testCalculations.js +272 -198
  216. package/node/tests/describeGregorianAdapter/testLocalization.js +35 -0
  217. package/node/tests/describeHijriAdapter/describeHijriAdapter.js +1 -3
  218. package/node/tests/describeHijriAdapter/testCalculations.js +100 -27
  219. package/node/tests/describeHijriAdapter/testLocalization.js +8 -0
  220. package/node/tests/describeJalaliAdapter/describeJalaliAdapter.js +2 -6
  221. package/node/tests/describeJalaliAdapter/testCalculations.js +156 -23
  222. package/node/tests/describeJalaliAdapter/testLocalization.js +8 -0
  223. package/node/tests/describeValue/describeValue.js +29 -3
  224. package/node/tests/describeValue/testControlledUnControlled.js +23 -15
  225. package/node/tests/describeValue/testPickerActionBar.js +21 -14
  226. package/node/tests/describeValue/testPickerOpenCloseLifeCycle.js +79 -51
  227. package/package.json +2 -2
  228. package/tests/describeGregorianAdapter/describeGregorianAdapter.js +2 -7
  229. package/tests/describeGregorianAdapter/describeGregorianAdapter.utils.js +2 -0
  230. package/tests/describeGregorianAdapter/index.js +2 -1
  231. package/tests/describeGregorianAdapter/testCalculations.js +272 -198
  232. package/tests/describeGregorianAdapter/testLocalization.js +34 -0
  233. package/tests/describeHijriAdapter/describeHijriAdapter.js +1 -3
  234. package/tests/describeHijriAdapter/testCalculations.js +101 -28
  235. package/tests/describeHijriAdapter/testLocalization.js +8 -0
  236. package/tests/describeJalaliAdapter/describeJalaliAdapter.js +2 -6
  237. package/tests/describeJalaliAdapter/testCalculations.js +157 -24
  238. package/tests/describeJalaliAdapter/testLocalization.js +8 -0
  239. package/tests/describeValue/describeValue.js +29 -3
  240. package/tests/describeValue/testControlledUnControlled.js +23 -15
  241. package/tests/describeValue/testPickerActionBar.js +21 -14
  242. package/tests/describeValue/testPickerOpenCloseLifeCycle.js +79 -51
  243. package/themeAugmentation/props.d.ts +1 -1
@@ -1,8 +1,8 @@
1
1
  import { expect } from 'chai';
2
- import { TEST_DATE_ISO } from '../describeGregorianAdapter';
2
+ import { TEST_DATE_ISO_STRING } from '../describeGregorianAdapter';
3
3
  export var testCalculations = function testCalculations(_ref) {
4
- var adapter = _ref.adapter,
5
- testDate = _ref.testDate;
4
+ var adapter = _ref.adapter;
5
+ var testDateIso = adapter.date(TEST_DATE_ISO_STRING);
6
6
  it('Method: date', function () {
7
7
  expect(adapter.date(null)).to.equal(null);
8
8
  });
@@ -11,56 +11,129 @@ export var testCalculations = function testCalculations(_ref) {
11
11
  expect(adapter.parse('01/01/1395', 'iYYYY/iM/iD')).not.to.equal(null);
12
12
  });
13
13
  it('Method: isEqual', function () {
14
- var anotherDate = adapter.date(TEST_DATE_ISO);
15
- expect(adapter.isEqual(testDate, anotherDate)).to.equal(true);
14
+ var anotherDate = adapter.date(TEST_DATE_ISO_STRING);
15
+ expect(adapter.isEqual(testDateIso, anotherDate)).to.equal(true);
16
16
  expect(adapter.isEqual(null, null)).to.equal(true);
17
17
  });
18
+ it('Method: isAfter', function () {
19
+ expect(adapter.isAfter(adapter.date(), testDateIso)).to.equal(true);
20
+ expect(adapter.isAfter(testDateIso, adapter.date())).to.equal(false);
21
+ });
18
22
  it('Method: isAfterYear', function () {
19
- var afterYear = adapter.addYears(testDate, 2);
20
- expect(adapter.isAfterYear(afterYear, testDate)).to.equal(true);
23
+ var afterYear = adapter.addYears(testDateIso, 2);
24
+ expect(adapter.isAfterYear(afterYear, testDateIso)).to.equal(true);
25
+ });
26
+ it('Method: isAfterDay', function () {
27
+ var nextDayIso = adapter.addDays(testDateIso, 1);
28
+ expect(adapter.isAfterDay(nextDayIso, testDateIso)).to.equal(true);
29
+ expect(adapter.isAfterDay(testDateIso, nextDayIso)).to.equal(false);
30
+ });
31
+ it('Method: isBefore', function () {
32
+ expect(adapter.isBefore(testDateIso, adapter.date())).to.equal(true);
33
+ expect(adapter.isBefore(adapter.date(), testDateIso)).to.equal(false);
21
34
  });
22
35
  it('Method: isBeforeYear', function () {
23
- var afterYear = adapter.addYears(testDate, 2);
24
- expect(adapter.isBeforeYear(testDate, afterYear)).to.equal(true);
36
+ var afterYear = adapter.addYears(testDateIso, 2);
37
+ expect(adapter.isBeforeYear(testDateIso, afterYear)).to.equal(true);
38
+ });
39
+ it('Method: isBeforeDay', function () {
40
+ var nextDayIso = adapter.addDays(testDateIso, -1);
41
+ expect(adapter.isBeforeDay(nextDayIso, testDateIso)).to.equal(true);
42
+ expect(adapter.isBeforeDay(testDateIso, nextDayIso)).to.equal(false);
25
43
  });
26
44
  it('Method: startOfYear', function () {
27
- expect(adapter.startOfYear(testDate)).toEqualDateTime(new Date('2018-09-11T00:00:00.000Z'));
45
+ expect(adapter.startOfYear(testDateIso)).toEqualDateTime('2018-09-11T00:00:00.000Z');
46
+ });
47
+ it('Method: startOfWeek', function () {
48
+ expect(adapter.startOfWeek(testDateIso)).toEqualDateTime('2018-10-28T00:00:00.000Z');
49
+ });
50
+ it('Method: startOfDay', function () {
51
+ expect(adapter.startOfDay(testDateIso)).toEqualDateTime('2018-10-30T00:00:00.000Z');
28
52
  });
29
53
  it('Method: startOfMonth', function () {
30
- expect(adapter.startOfMonth(testDate)).toEqualDateTime(new Date('2018-10-10T00:00:00.000Z'));
54
+ expect(adapter.startOfMonth(testDateIso)).toEqualDateTime('2018-10-10T00:00:00.000Z');
31
55
  });
32
56
  it('Method: endOfYear', function () {
33
- expect(adapter.endOfYear(testDate)).toEqualDateTime(new Date('2019-08-30T23:59:59.999Z'));
57
+ expect(adapter.endOfYear(testDateIso)).toEqualDateTime('2019-08-30T23:59:59.999Z');
34
58
  });
35
59
  it('Method: endOfMonth', function () {
36
- expect(adapter.endOfMonth(testDate)).toEqualDateTime(new Date('2018-11-08T23:59:59.999Z'));
60
+ expect(adapter.endOfMonth(testDateIso)).toEqualDateTime('2018-11-08T23:59:59.999Z');
61
+ });
62
+ it('Method: endOfWeek', function () {
63
+ expect(adapter.endOfWeek(testDateIso)).toEqualDateTime('2018-11-03T23:59:59.999Z');
64
+ });
65
+ it('Method: endOfDay', function () {
66
+ expect(adapter.endOfDay(testDateIso)).toEqualDateTime('2018-10-30T23:59:59.999Z');
67
+ });
68
+ it('Method: addYears', function () {
69
+ expect(adapter.addYears(testDateIso, 2)).toEqualDateTime('2020-10-08T11:44:00.000Z');
70
+ expect(adapter.addYears(testDateIso, -2)).toEqualDateTime('2016-11-21T11:44:00.000Z');
71
+ });
72
+ it('Method: addMonths', function () {
73
+ expect(adapter.addMonths(testDateIso, 2)).toEqualDateTime('2018-12-28T11:44:00.000Z');
74
+ expect(adapter.addMonths(testDateIso, -2)).toEqualDateTime('2018-09-01T11:44:00.000Z');
75
+ expect(adapter.addMonths(testDateIso, 3)).toEqualDateTime('2019-01-27T11:44:00.000Z');
76
+ });
77
+ it('Method: addWeeks', function () {
78
+ expect(adapter.addWeeks(testDateIso, 2)).toEqualDateTime('2018-11-13T11:44:00.000Z');
79
+ expect(adapter.addWeeks(testDateIso, -2)).toEqualDateTime('2018-10-16T11:44:00.000Z');
80
+ });
81
+ it('Method: addDays', function () {
82
+ expect(adapter.addDays(testDateIso, 2)).toEqualDateTime('2018-11-01T11:44:00.000Z');
83
+ expect(adapter.addDays(testDateIso, -2)).toEqualDateTime('2018-10-28T11:44:00.000Z');
84
+ });
85
+ it('Method: addHours', function () {
86
+ expect(adapter.addHours(testDateIso, 2)).toEqualDateTime('2018-10-30T13:44:00.000Z');
87
+ expect(adapter.addHours(testDateIso, -2)).toEqualDateTime('2018-10-30T09:44:00.000Z');
88
+ expect(adapter.addHours(testDateIso, 15)).toEqualDateTime('2018-10-31T02:44:00.000Z');
89
+ });
90
+ it('Method: addMinutes', function () {
91
+ expect(adapter.addMinutes(testDateIso, 2)).toEqualDateTime('2018-10-30T11:46:00.000Z');
92
+ expect(adapter.addMinutes(testDateIso, -2)).toEqualDateTime('2018-10-30T11:42:00.000Z');
93
+ expect(adapter.addMinutes(testDateIso, 20)).toEqualDateTime('2018-10-30T12:04:00.000Z');
94
+ });
95
+ it('Method: addSeconds', function () {
96
+ expect(adapter.addSeconds(testDateIso, 2)).toEqualDateTime('2018-10-30T11:44:02.000Z');
97
+ expect(adapter.addSeconds(testDateIso, -2)).toEqualDateTime('2018-10-30T11:43:58.000Z');
98
+ expect(adapter.addSeconds(testDateIso, 70)).toEqualDateTime('2018-10-30T11:45:10.000Z');
37
99
  });
38
100
  it('Method: getYear', function () {
39
- expect(adapter.getYear(testDate)).to.equal(1440);
101
+ expect(adapter.getYear(testDateIso)).to.equal(1440);
40
102
  });
41
103
  it('Method: getMonth', function () {
42
- expect(adapter.getMonth(testDate)).to.equal(1);
104
+ expect(adapter.getMonth(testDateIso)).to.equal(1);
43
105
  });
44
106
  it('Method: getDate', function () {
45
- expect(adapter.getDate(testDate)).to.equal(21);
107
+ expect(adapter.getDate(testDateIso)).to.equal(21);
46
108
  });
47
109
  it('Method: setYear', function () {
48
- expect(adapter.setYear(testDate, 1441)).toEqualDateTime(new Date('2019-10-20T11:44:00.000Z'));
110
+ expect(adapter.setYear(testDateIso, 1441)).toEqualDateTime('2019-10-20T11:44:00.000Z');
111
+ });
112
+ it('Method: setMonth', function () {
113
+ expect(adapter.setMonth(testDateIso, 4)).toEqualDateTime('2019-01-27T11:44:00.000Z');
49
114
  });
50
115
  it('Method: setDate', function () {
51
- expect(adapter.setDate(testDate, 22)).toEqualDateTime(new Date('2018-10-31T11:44:00.000Z'));
116
+ expect(adapter.setDate(testDateIso, 22)).toEqualDateTime('2018-10-31T11:44:00.000Z');
52
117
  });
53
118
  it('Method: getNextMonth', function () {
54
- expect(adapter.getNextMonth(testDate)).toEqualDateTime(new Date('2018-11-29T11:44:00.000Z'));
119
+ expect(adapter.getNextMonth(testDateIso)).toEqualDateTime('2018-11-29T11:44:00.000Z');
55
120
  });
56
121
  it('Method: getPreviousMonth', function () {
57
- expect(adapter.getPreviousMonth(testDate)).toEqualDateTime(new Date('2018-10-01T11:44:00.000Z'));
122
+ expect(adapter.getPreviousMonth(testDateIso)).toEqualDateTime(new Date('2018-10-01T11:44:00.000Z'));
123
+ });
124
+ it('Method: getMonthArray', function () {
125
+ var monthArray = adapter.getMonthArray(testDateIso);
126
+ var expectedDate = adapter.date('2018-09-11T00:00:00.000Z');
127
+ monthArray.forEach(function (month) {
128
+ expect(month).toEqualDateTime(expectedDate);
129
+ expectedDate = adapter.addMonths(expectedDate, 1);
130
+ });
58
131
  });
59
132
  it('Method: getWeekdays', function () {
60
133
  expect(adapter.getWeekdays()).to.deep.equal(['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س']);
61
134
  });
62
135
  it('Method: getWeekArray', function () {
63
- var weekArray = adapter.getWeekArray(testDate);
136
+ var weekArray = adapter.getWeekArray(testDateIso);
64
137
  var expectedDate = new Date('2018-10-07T00:00:00.000Z');
65
138
  weekArray.forEach(function (week) {
66
139
  week.forEach(function (day) {
@@ -70,25 +143,25 @@ export var testCalculations = function testCalculations(_ref) {
70
143
  });
71
144
  });
72
145
  it('Method: getWeekNumber', function () {
73
- expect(adapter.getWeekNumber(testDate)).to.equal(8);
146
+ expect(adapter.getWeekNumber(testDateIso)).to.equal(8);
74
147
  });
75
148
  describe('Method: getYearRange', function () {
76
149
  it('Minimum limit', function () {
77
- var anotherYear = adapter.setYear(testDate, 1355);
150
+ var anotherYear = adapter.setYear(testDateIso, 1355);
78
151
  expect(function () {
79
- return adapter.getYearRange(anotherYear, testDate);
152
+ return adapter.getYearRange(anotherYear, testDateIso);
80
153
  }).to.throw('min date must be on or after 1356-01-01 H (1937-03-14)');
81
154
  });
82
155
  it('Maximum limit', function () {
83
- var anotherYear = adapter.setYear(testDate, 1500);
156
+ var anotherYear = adapter.setYear(testDateIso, 1500);
84
157
  expect(function () {
85
- return adapter.getYearRange(testDate, anotherYear);
158
+ return adapter.getYearRange(testDateIso, anotherYear);
86
159
  }).to.throw('max date must be on or before 1499-12-29 H (2076-11-26)');
87
160
  });
88
161
  });
89
162
  it('Method: getYearRange', function () {
90
- var anotherDate = adapter.setYear(testDate, 1445);
91
- var yearRange = adapter.getYearRange(testDate, anotherDate);
163
+ var anotherDate = adapter.setYear(testDateIso, 1445);
164
+ var yearRange = adapter.getYearRange(testDateIso, anotherDate);
92
165
  expect(yearRange).to.have.length(6);
93
166
  });
94
167
  };
@@ -9,4 +9,12 @@ export var testLocalization = function testLocalization(_ref) {
9
9
  expect(adapter.getMeridiemText('am')).to.equal('ص');
10
10
  expect(adapter.getMeridiemText('pm')).to.equal('م');
11
11
  });
12
+ it('Method: getFormatHelperText', function () {
13
+ expect(adapter.getFormatHelperText(adapter.formats.keyboardDate)).to.equal('yyyy/mm/dd');
14
+ expect(adapter.getFormatHelperText(adapter.formats.keyboardDateTime12h)).to.equal('yyyy/mm/dd hh:mm (a|p)m');
15
+ });
16
+ it('Method: getCurrentLocaleCode', function () {
17
+ // Returns the default locale
18
+ expect(adapter.getCurrentLocaleCode()).to.match(/ar/);
19
+ });
12
20
  };
@@ -2,15 +2,11 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import createDescribe from '@mui/monorepo/test/utils/createDescribe';
3
3
  import { testCalculations } from './testCalculations';
4
4
  import { testLocalization } from './testLocalization';
5
- import { TEST_DATE_ISO } from '../describeGregorianAdapter';
6
5
  function innerJalaliDescribeAdapter(Adapter, params) {
7
- var adapter = new Adapter({
8
- locale: params.locale
9
- });
6
+ var adapter = new Adapter();
10
7
  describe(adapter.lib, function () {
11
8
  var testSuitParams = _extends({}, params, {
12
- adapter: adapter,
13
- testDate: adapter.date(TEST_DATE_ISO)
9
+ adapter: adapter
14
10
  });
15
11
  if (params.before) {
16
12
  before(params.before);
@@ -1,8 +1,8 @@
1
1
  import { expect } from 'chai';
2
- import { TEST_DATE_ISO } from '../describeGregorianAdapter';
2
+ import { TEST_DATE_ISO_STRING } from '../describeGregorianAdapter';
3
3
  export var testCalculations = function testCalculations(_ref) {
4
- var adapter = _ref.adapter,
5
- testDate = _ref.testDate;
4
+ var adapter = _ref.adapter;
5
+ var testDateIso = adapter.date(TEST_DATE_ISO_STRING);
6
6
  it('Method: date', function () {
7
7
  expect(adapter.date(null)).to.equal(null);
8
8
  });
@@ -10,51 +10,184 @@ export var testCalculations = function testCalculations(_ref) {
10
10
  expect(adapter.parse('', adapter.formats.keyboardDate)).to.equal(null);
11
11
  expect(adapter.parse('01/01/1395', adapter.formats.keyboardDate)).not.to.equal(null);
12
12
  });
13
+ it('Method: parseISO', function () {
14
+ expect(adapter.parseISO(TEST_DATE_ISO_STRING)).toEqualDateTime(testDateIso);
15
+ });
16
+ it('Method: toISO', function () {
17
+ var outputtedISO = adapter.toISO(testDateIso);
18
+ if (adapter.lib === 'date-fns-jalali') {
19
+ // date-fns never suppress useless milliseconds in the end
20
+ expect(outputtedISO).to.equal(TEST_DATE_ISO_STRING.replace('.000Z', 'Z'));
21
+ } else {
22
+ expect(outputtedISO).to.equal(TEST_DATE_ISO_STRING);
23
+ }
24
+ });
25
+ it('Method: isNull', function () {
26
+ expect(adapter.isNull(null)).to.equal(true);
27
+ expect(adapter.isNull(testDateIso)).to.equal(false);
28
+ });
29
+ describe('Method: getDiff', function () {
30
+ it('should compute the millisecond diff when there is no unit', function () {
31
+ expect(adapter.getDiff(testDateIso, adapter.date('2018-10-29T11:44:00.000Z'))).to.equal(86400000);
32
+ expect(adapter.getDiff(testDateIso, adapter.date('2018-10-31T11:44:00.000Z'))).to.equal(-86400000);
33
+ expect(adapter.getDiff(testDateIso, adapter.date('2018-10-31T11:44:00.000Z'))).to.equal(-86400000);
34
+ });
35
+ it('should compute the diff in the provided unit (ISO)', function () {
36
+ expect(adapter.getDiff(testDateIso, adapter.date('2017-09-29T11:44:00.000Z'), 'years')).to.equal(1);
37
+ expect(adapter.getDiff(testDateIso, adapter.date('2018-08-29T11:44:00.000Z'), 'months')).to.equal(2);
38
+ expect(adapter.getDiff(testDateIso, adapter.date('2018-05-29T11:44:00.000Z'), 'quarters')).to.equal(1);
39
+ expect(adapter.getDiff(testDateIso, adapter.date('2018-09-29T11:44:00.000Z'), 'days')).to.equal(31);
40
+ expect(adapter.getDiff(testDateIso, adapter.date('2018-09-29T11:44:00.000Z'), 'weeks')).to.equal(4);
41
+ expect(adapter.getDiff(testDateIso, adapter.date('2018-09-29T11:44:00.000Z'), 'hours')).to.equal(744);
42
+ expect(adapter.getDiff(testDateIso, adapter.date('2018-09-29T11:44:00.000Z'), 'minutes')).to.equal(44640);
43
+ expect(adapter.getDiff(testDateIso, adapter.date('2018-10-30T10:44:00.000Z'), 'seconds')).to.equal(3600);
44
+ expect(adapter.getDiff(testDateIso, adapter.date('2018-10-30T10:44:00.000Z'), 'milliseconds')).to.equal(3600000);
45
+ });
46
+ });
13
47
  it('Method: isEqual', function () {
14
- var anotherDate = adapter.date(TEST_DATE_ISO);
15
- expect(adapter.isEqual(testDate, anotherDate)).to.equal(true);
48
+ var anotherDate = adapter.date(TEST_DATE_ISO_STRING);
49
+ expect(adapter.isEqual(testDateIso, anotherDate)).to.equal(true);
16
50
  expect(adapter.isEqual(null, null)).to.equal(true);
17
51
  });
52
+ it('Method: isSameYear', function () {
53
+ expect(adapter.isSameYear(testDateIso, adapter.date('2018-10-01T00:00:00.000Z'))).to.equal(true);
54
+ expect(adapter.isSameYear(testDateIso, adapter.date('2019-10-01T00:00:00.000Z'))).to.equal(false);
55
+ });
56
+ it('Method: isSameMonth', function () {
57
+ expect(adapter.isSameMonth(testDateIso, adapter.date('2018-11-04T00:00:00.000Z'))).to.equal(true);
58
+ expect(adapter.isSameMonth(testDateIso, adapter.date('2019-10-01T00:00:00.000Z'))).to.equal(false);
59
+ });
60
+ it('Method: isSameDay', function () {
61
+ expect(adapter.isSameDay(testDateIso, adapter.date('2018-10-30T00:00:00.000Z'))).to.equal(true);
62
+ expect(adapter.isSameDay(testDateIso, adapter.date('2019-10-30T00:00:00.000Z'))).to.equal(false);
63
+ });
64
+ it('Method: isSameHour', function () {
65
+ expect(adapter.isSameHour(testDateIso, adapter.date('2018-10-30T11:00:00.000Z'))).to.equal(true);
66
+ expect(adapter.isSameHour(testDateIso, adapter.date('2018-10-30T12:00:00.000Z'))).to.equal(false);
67
+ });
68
+ it('Method: isAfter', function () {
69
+ expect(adapter.isAfter(adapter.date(), testDateIso)).to.equal(true);
70
+ expect(adapter.isAfter(testDateIso, adapter.date())).to.equal(false);
71
+ });
18
72
  it('Method: isAfterYear', function () {
19
- var afterYear = adapter.addYears(testDate, 2);
20
- expect(adapter.isAfterYear(afterYear, testDate)).to.equal(true);
73
+ var afterYear = adapter.addYears(testDateIso, 2);
74
+ expect(adapter.isAfterYear(afterYear, testDateIso)).to.equal(true);
75
+ });
76
+ it('Method: isAfterDay', function () {
77
+ var nextDayIso = adapter.addDays(testDateIso, 1);
78
+ expect(adapter.isAfterDay(nextDayIso, testDateIso)).to.equal(true);
79
+ expect(adapter.isAfterDay(testDateIso, nextDayIso)).to.equal(false);
80
+ });
81
+ it('Method: isBefore', function () {
82
+ expect(adapter.isBefore(testDateIso, adapter.date())).to.equal(true);
83
+ expect(adapter.isBefore(adapter.date(), testDateIso)).to.equal(false);
21
84
  });
22
85
  it('Method: isBeforeYear', function () {
23
- var afterYear = adapter.addYears(testDate, 2);
24
- expect(adapter.isBeforeYear(testDate, afterYear)).to.equal(true);
86
+ var afterYear = adapter.addYears(testDateIso, 2);
87
+ expect(adapter.isBeforeYear(testDateIso, afterYear)).to.equal(true);
88
+ });
89
+ it('Method: isBeforeDay', function () {
90
+ var nextDayIso = adapter.addDays(testDateIso, -1);
91
+ expect(adapter.isBeforeDay(nextDayIso, testDateIso)).to.equal(true);
92
+ expect(adapter.isBeforeDay(testDateIso, nextDayIso)).to.equal(false);
93
+ });
94
+ it('Method: isWithinRange', function () {
95
+ 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);
96
+ 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);
97
+ expect(adapter.isWithinRange(adapter.date('2019-10-01'), [adapter.date('2019-09-01'), adapter.date('2019-11-01')])).to.equal(true);
98
+ expect(adapter.isWithinRange(adapter.date('2019-12-01'), [adapter.date('2019-09-01'), adapter.date('2019-11-01')])).to.equal(false);
25
99
  });
26
100
  it('Method: startOfYear', function () {
27
- expect(adapter.startOfYear(testDate)).toEqualDateTime(new Date('2018-03-21T00:00:00.000Z'));
101
+ expect(adapter.startOfYear(testDateIso)).toEqualDateTime('2018-03-21T00:00:00.000Z');
28
102
  });
29
103
  it('Method: startOfMonth', function () {
30
- expect(adapter.startOfMonth(testDate)).toEqualDateTime(new Date('2018-10-23T00:00:00.000Z'));
104
+ expect(adapter.startOfMonth(testDateIso)).toEqualDateTime('2018-10-23T00:00:00.000Z');
105
+ });
106
+ it('Method: startOfWeek', function () {
107
+ expect(adapter.startOfWeek(testDateIso)).toEqualDateTime('2018-10-27T00:00:00.000Z');
108
+ });
109
+ it('Method: startOfDay', function () {
110
+ expect(adapter.startOfDay(testDateIso)).toEqualDateTime('2018-10-30T00:00:00.000Z');
31
111
  });
32
112
  it('Method: endOfYear', function () {
33
- expect(adapter.endOfYear(testDate)).toEqualDateTime(new Date('2019-03-20T23:59:59.999Z'));
113
+ expect(adapter.endOfYear(testDateIso)).toEqualDateTime('2019-03-20T23:59:59.999Z');
34
114
  });
35
115
  it('Method: endOfMonth', function () {
36
- expect(adapter.endOfMonth(testDate)).toEqualDateTime(new Date('2018-11-21T23:59:59.999Z'));
116
+ expect(adapter.endOfMonth(testDateIso)).toEqualDateTime('2018-11-21T23:59:59.999Z');
117
+ });
118
+ it('Method: endOfWeek', function () {
119
+ expect(adapter.endOfWeek(testDateIso)).toEqualDateTime('2018-11-02T23:59:59.999Z');
120
+ });
121
+ it('Method: endOfDay', function () {
122
+ expect(adapter.endOfDay(testDateIso)).toEqualDateTime('2018-10-30T23:59:59.999Z');
123
+ });
124
+ it('Method: addYears', function () {
125
+ expect(adapter.addYears(testDateIso, 2)).toEqualDateTime('2020-10-29T11:44:00.000Z');
126
+ expect(adapter.addYears(testDateIso, -2)).toEqualDateTime('2016-10-29T11:44:00.000Z');
127
+ });
128
+ it('Method: addMonths', function () {
129
+ expect(adapter.addMonths(testDateIso, 2)).toEqualDateTime('2018-12-29T11:44:00.000Z');
130
+ expect(adapter.addMonths(testDateIso, -2)).toEqualDateTime('2018-08-30T11:44:00.000Z');
131
+ expect(adapter.addMonths(testDateIso, 3)).toEqualDateTime('2019-01-28T11:44:00.000Z');
132
+ });
133
+ it('Method: addWeeks', function () {
134
+ expect(adapter.addWeeks(testDateIso, 2)).toEqualDateTime('2018-11-13T11:44:00.000Z');
135
+ expect(adapter.addWeeks(testDateIso, -2)).toEqualDateTime('2018-10-16T11:44:00.000Z');
136
+ });
137
+ it('Method: addDays', function () {
138
+ expect(adapter.addDays(testDateIso, 2)).toEqualDateTime('2018-11-01T11:44:00.000Z');
139
+ expect(adapter.addDays(testDateIso, -2)).toEqualDateTime('2018-10-28T11:44:00.000Z');
140
+ });
141
+ it('Method: addHours', function () {
142
+ expect(adapter.addHours(testDateIso, 2)).toEqualDateTime('2018-10-30T13:44:00.000Z');
143
+ expect(adapter.addHours(testDateIso, -2)).toEqualDateTime('2018-10-30T09:44:00.000Z');
144
+ expect(adapter.addHours(testDateIso, 15)).toEqualDateTime('2018-10-31T02:44:00.000Z');
145
+ });
146
+ it('Method: addMinutes', function () {
147
+ expect(adapter.addMinutes(testDateIso, 2)).toEqualDateTime('2018-10-30T11:46:00.000Z');
148
+ expect(adapter.addMinutes(testDateIso, -2)).toEqualDateTime('2018-10-30T11:42:00.000Z');
149
+ expect(adapter.addMinutes(testDateIso, 20)).toEqualDateTime('2018-10-30T12:04:00.000Z');
150
+ });
151
+ it('Method: addSeconds', function () {
152
+ expect(adapter.addSeconds(testDateIso, 2)).toEqualDateTime('2018-10-30T11:44:02.000Z');
153
+ expect(adapter.addSeconds(testDateIso, -2)).toEqualDateTime('2018-10-30T11:43:58.000Z');
154
+ expect(adapter.addSeconds(testDateIso, 70)).toEqualDateTime('2018-10-30T11:45:10.000Z');
37
155
  });
38
156
  it('Method: getYear', function () {
39
- expect(adapter.getYear(testDate)).to.equal(1397);
157
+ expect(adapter.getYear(testDateIso)).to.equal(1397);
40
158
  });
41
159
  it('Method: getMonth', function () {
42
- expect(adapter.getMonth(testDate)).to.equal(7);
160
+ expect(adapter.getMonth(testDateIso)).to.equal(7);
43
161
  });
44
162
  it('Method: getDate', function () {
45
- expect(adapter.getDate(testDate)).to.equal(8);
163
+ expect(adapter.getDate(testDateIso)).to.equal(8);
46
164
  });
47
165
  it('Method: setYear', function () {
48
- expect(adapter.setYear(testDate, 1398)).toEqualDateTime(new Date('2019-10-30T11:44:00.000Z'));
166
+ expect(adapter.setYear(testDateIso, 1398)).toEqualDateTime('2019-10-30T11:44:00.000Z');
167
+ });
168
+ it('Method: setMonth', function () {
169
+ expect(adapter.setMonth(testDateIso, 4)).toEqualDateTime('2018-07-30T11:44:00.000Z');
49
170
  });
50
171
  it('Method: setDate', function () {
51
- expect(adapter.setDate(testDate, 9)).toEqualDateTime(new Date('2018-10-31T11:44:00.000Z'));
172
+ expect(adapter.setDate(testDateIso, 9)).toEqualDateTime('2018-10-31T11:44:00.000Z');
52
173
  });
53
174
  it('Method: getNextMonth', function () {
54
- expect(adapter.getNextMonth(testDate)).toEqualDateTime(new Date('2018-11-29T11:44:00.000Z'));
175
+ expect(adapter.getNextMonth(testDateIso)).toEqualDateTime('2018-11-29T11:44:00.000Z');
55
176
  });
56
177
  it('Method: getPreviousMonth', function () {
57
- expect(adapter.getPreviousMonth(testDate)).toEqualDateTime(new Date('2018-09-30T11:44:00.000Z'));
178
+ expect(adapter.getPreviousMonth(testDateIso)).toEqualDateTime(new Date('2018-09-30T11:44:00.000Z'));
179
+ });
180
+ it('Method: getMonthArray', function () {
181
+ var monthArray = adapter.getMonthArray(testDateIso);
182
+ var expectedDate = adapter.date('2018-03-21T00:00:00.000Z');
183
+ monthArray.forEach(function (month) {
184
+ expect(month).toEqualDateTime(expectedDate);
185
+ expectedDate = adapter.addMonths(expectedDate, 1);
186
+ });
187
+ });
188
+ it('Method: mergeDateAndTime', function () {
189
+ var mergedDate = adapter.mergeDateAndTime(testDateIso, adapter.date('2018-01-01T14:15:16.000Z'));
190
+ expect(adapter.toJsDate(mergedDate)).toEqualDateTime('2018-10-30T14:15:16.000Z');
58
191
  });
59
192
  it('Method: getWeekdays', function () {
60
193
  // TODO: AdapterDateFnsJalali `getWeekDays` method seems broken
@@ -62,7 +195,7 @@ export var testCalculations = function testCalculations(_ref) {
62
195
  expect(adapter.getWeekdays()).to.deep.equal(adapter.lib === 'date-fns-jalali' ? ['ش', '1ش', '2ش', '3ش', '4ش', '5ش', 'ج'] : ['ش', 'ی', 'د', 'س', 'چ', 'پ', 'ج']);
63
196
  });
64
197
  it('Method: getWeekArray', function () {
65
- var weekArray = adapter.getWeekArray(testDate);
198
+ var weekArray = adapter.getWeekArray(testDateIso);
66
199
  var expectedDate = new Date('2018-10-20T00:00:00.000Z');
67
200
  weekArray.forEach(function (week) {
68
201
  week.forEach(function (day) {
@@ -72,11 +205,11 @@ export var testCalculations = function testCalculations(_ref) {
72
205
  });
73
206
  });
74
207
  it('Method: getWeekNumber', function () {
75
- expect(adapter.getWeekNumber(testDate)).to.equal(33);
208
+ expect(adapter.getWeekNumber(testDateIso)).to.equal(33);
76
209
  });
77
210
  it('Method: getYearRange', function () {
78
- var anotherDate = adapter.setYear(testDate, 1400);
79
- var yearRange = adapter.getYearRange(testDate, anotherDate);
211
+ var anotherDate = adapter.setYear(testDateIso, 1400);
212
+ var yearRange = adapter.getYearRange(testDateIso, anotherDate);
80
213
  expect(yearRange).to.have.length(4);
81
214
  });
82
215
  };
@@ -9,4 +9,12 @@ export var testLocalization = function testLocalization(_ref) {
9
9
  expect(adapter.getMeridiemText('am')).to.equal('ق.ظ');
10
10
  expect(adapter.getMeridiemText('pm')).to.equal('ب.ظ');
11
11
  });
12
+ it('Method: getFormatHelperText', function () {
13
+ expect(adapter.getFormatHelperText(adapter.formats.keyboardDate)).to.equal('yyyy/mm/dd');
14
+ expect(adapter.getFormatHelperText(adapter.formats.keyboardDateTime12h)).to.equal('yyyy/mm/dd hh:mm (a|p)m');
15
+ });
16
+ it('Method: getCurrentLocaleCode', function () {
17
+ // Returns the default locale
18
+ expect(adapter.getCurrentLocaleCode()).to.match(/fa/);
19
+ });
12
20
  };
@@ -1,19 +1,46 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import createDescribe from '@mui/monorepo/test/utils/createDescribe';
4
+ import { buildFieldInteractions } from 'test/utils/pickers-utils';
4
5
  import { testControlledUnControlled } from './testControlledUnControlled';
5
6
  import { testPickerOpenCloseLifeCycle } from './testPickerOpenCloseLifeCycle';
6
7
  import { testPickerActionBar } from './testPickerActionBar';
7
8
  import { jsx as _jsx } from "react/jsx-runtime";
8
9
  var TEST_SUITES = [testControlledUnControlled, testPickerOpenCloseLifeCycle, testPickerActionBar];
9
10
  function innerDescribeValue(ElementToTest, getOptions) {
10
- var _getOptions = getOptions(),
11
- defaultProps = _getOptions.defaultProps;
11
+ var options = getOptions();
12
+ var defaultProps = options.defaultProps,
13
+ render = options.render,
14
+ clock = options.clock,
15
+ componentFamily = options.componentFamily;
12
16
  function WrappedElementToTest(props) {
13
17
  return /*#__PURE__*/_jsx(ElementToTest, _extends({}, defaultProps, props));
14
18
  }
19
+ var renderWithProps;
20
+ if (componentFamily === 'field' || componentFamily === 'picker') {
21
+ var interactions = buildFieldInteractions({
22
+ clock: clock,
23
+ render: render,
24
+ Component: ElementToTest
25
+ });
26
+ renderWithProps = function renderWithProps(props) {
27
+ return interactions.renderWithProps(_extends({}, defaultProps, props), componentFamily);
28
+ };
29
+ } else {
30
+ renderWithProps = function renderWithProps(props) {
31
+ var response = render( /*#__PURE__*/_jsx(WrappedElementToTest, _extends({}, props)));
32
+ return _extends({}, response, {
33
+ input: null,
34
+ selectSection: function selectSection() {
35
+ throw new Error('You can only select a section on components that render a field');
36
+ }
37
+ });
38
+ };
39
+ }
15
40
  TEST_SUITES.forEach(function (testSuite) {
16
- testSuite(WrappedElementToTest, getOptions);
41
+ testSuite(WrappedElementToTest, _extends({}, options, {
42
+ renderWithProps: renderWithProps
43
+ }));
17
44
  });
18
45
  }
19
46
  /**
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
- var _excluded = ["render", "values", "componentFamily", "emptyValue", "assertRenderedValue", "setNewValue", "clock"];
4
+ var _excluded = ["render", "renderWithProps", "values", "componentFamily", "emptyValue", "assertRenderedValue", "setNewValue", "clock"];
5
5
  import * as React from 'react';
6
6
  import { expect } from 'chai';
7
7
  import { spy } from 'sinon';
@@ -10,16 +10,16 @@ import { inputBaseClasses } from '@mui/material/InputBase';
10
10
  import { getExpectedOnChangeCount } from 'test/utils/pickers-utils';
11
11
  import { jsx as _jsx } from "react/jsx-runtime";
12
12
  import { jsxs as _jsxs } from "react/jsx-runtime";
13
- export var testControlledUnControlled = function testControlledUnControlled(ElementToTest, getOptions) {
14
- var _getOptions = getOptions(),
15
- render = _getOptions.render,
16
- values = _getOptions.values,
17
- componentFamily = _getOptions.componentFamily,
18
- emptyValue = _getOptions.emptyValue,
19
- assertRenderedValue = _getOptions.assertRenderedValue,
20
- setNewValue = _getOptions.setNewValue,
21
- clock = _getOptions.clock,
22
- pickerParams = _objectWithoutProperties(_getOptions, _excluded);
13
+ export var testControlledUnControlled = function testControlledUnControlled(ElementToTest, options) {
14
+ var render = options.render,
15
+ renderWithProps = options.renderWithProps,
16
+ values = options.values,
17
+ componentFamily = options.componentFamily,
18
+ emptyValue = options.emptyValue,
19
+ assertRenderedValue = options.assertRenderedValue,
20
+ setNewValue = options.setNewValue,
21
+ clock = options.clock,
22
+ pickerParams = _objectWithoutProperties(options, _excluded);
23
23
  var params = pickerParams;
24
24
  describe('Controlled / uncontrolled value', function () {
25
25
  it('should render `props.defaultValue` if no `props.value` is passed', function () {
@@ -47,11 +47,14 @@ export var testControlledUnControlled = function testControlledUnControlled(Elem
47
47
  });
48
48
  it('should call onChange when updating a value defined with `props.defaultValue` and update the rendered value', function () {
49
49
  var onChange = spy();
50
- render( /*#__PURE__*/_jsx(ElementToTest, {
51
- defaultValue: values[0],
52
- onChange: onChange
53
- }));
54
- var newValue = setNewValue(values[0]);
50
+ var _renderWithProps = renderWithProps({
51
+ defaultValue: values[0],
52
+ onChange: onChange
53
+ }),
54
+ selectSection = _renderWithProps.selectSection;
55
+ var newValue = setNewValue(values[0], {
56
+ selectSection: selectSection
57
+ });
55
58
  assertRenderedValue(newValue);
56
59
  // TODO: Clean this exception or change the clock behavior
57
60
  expect(onChange.callCount).to.equal(getExpectedOnChangeCount(componentFamily));
@@ -65,11 +68,14 @@ export var testControlledUnControlled = function testControlledUnControlled(Elem
65
68
  });
66
69
  it('should call onChange when updating a value defined with `props.value`', function () {
67
70
  var onChange = spy();
68
- render( /*#__PURE__*/_jsx(ElementToTest, {
69
- value: values[0],
70
- onChange: onChange
71
- }));
72
- var newValue = setNewValue(values[0]);
71
+ var _renderWithProps2 = renderWithProps({
72
+ defaultValue: values[0],
73
+ onChange: onChange
74
+ }),
75
+ selectSection = _renderWithProps2.selectSection;
76
+ var newValue = setNewValue(values[0], {
77
+ selectSection: selectSection
78
+ });
73
79
  expect(onChange.callCount).to.equal(getExpectedOnChangeCount(componentFamily));
74
80
  if (Array.isArray(newValue)) {
75
81
  newValue.forEach(function (value, index) {