@docsvision/material-ui-pickers 3.2.0-beta.26 → 3.2.0-beta.28

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 (233) hide show
  1. package/{build/DatePicker → DatePicker}/DatePickerToolbar.js +3 -3
  2. package/{build/DateTimePicker → DateTimePicker}/DateTimePicker.d.ts +2 -2
  3. package/{build/DateTimePicker → DateTimePicker}/DateTimePicker.js +2 -2
  4. package/{build/DateTimePicker → DateTimePicker}/DateTimePickerToolbar.js +4 -4
  5. package/{build/MuiPickersUtilsProvider.d.ts → MuiPickersUtilsProvider.d.ts} +1 -1
  6. package/{build/Picker → Picker}/Picker.d.ts +3 -3
  7. package/{build/Picker → Picker}/Picker.js +1 -1
  8. package/{build/Picker → Picker}/WrappedPurePicker.js +2 -1
  9. package/{build/TimePicker → TimePicker}/TimePicker.d.ts +4 -2
  10. package/{build/TimePicker → TimePicker}/TimePicker.js +2 -2
  11. package/{build/TimePicker → TimePicker}/TimePickerToolbar.js +3 -3
  12. package/{build/_helpers → _helpers}/date-utils.d.ts +2 -2
  13. package/{build/_helpers → _helpers}/date-utils.js +3 -3
  14. package/_helpers/text-field-helper.d.ts +32 -0
  15. package/{build/_helpers → _helpers}/text-field-helper.js +1 -1
  16. package/{build/_helpers → _helpers}/time-utils.d.ts +2 -2
  17. package/{build/_shared → _shared}/WithUtils.d.ts +1 -1
  18. package/{build/_shared → _shared}/hooks/useKeyboardPickerState.js +1 -1
  19. package/{build/_shared → _shared}/hooks/useUtils.d.ts +2 -2
  20. package/{build/dist → dist}/material-ui-pickers.esm.js +1187 -834
  21. package/dist/material-ui-pickers.esm.js.map +1 -0
  22. package/{build/dist → dist}/material-ui-pickers.js +1187 -834
  23. package/dist/material-ui-pickers.js.map +1 -0
  24. package/{build/dist → dist}/material-ui-pickers.umd.js +1178 -825
  25. package/dist/material-ui-pickers.umd.min.js +1 -0
  26. package/{build/index.d.ts → index.d.ts} +11 -11
  27. package/package.json +62 -135
  28. package/{build/typings → typings}/BasePicker.d.ts +1 -1
  29. package/{build/views → views}/Calendar/Calendar.js +1 -1
  30. package/{build/views → views}/Calendar/CalendarHeader.js +1 -1
  31. package/{build/views → views}/Clock/Clock.js +1 -1
  32. package/{build/views → views}/Clock/ClockNumbers.d.ts +2 -2
  33. package/{build/views → views}/Clock/ClockView.js +1 -1
  34. package/{build/views → views}/Month/MonthView.js +1 -1
  35. package/{build/views → views}/Year/YearView.js +2 -2
  36. package/.size-snapshot.json +0 -26
  37. package/9db1cba1a61cb58db53f38425bbd1f95.7z +0 -0
  38. package/build/_helpers/text-field-helper.d.ts +0 -32
  39. package/build/dist/material-ui-pickers.esm.js.map +0 -1
  40. package/build/dist/material-ui-pickers.js.map +0 -1
  41. package/build/dist/material-ui-pickers.umd.min.js +0 -1
  42. package/build/package.json +0 -62
  43. package/copy.js +0 -58
  44. package/remove-prop-types.js +0 -37
  45. package/rollup.config.js +0 -145
  46. package/src/DatePicker/DatePicker.tsx +0 -91
  47. package/src/DatePicker/DatePickerToolbar.tsx +0 -75
  48. package/src/DatePicker/index.ts +0 -7
  49. package/src/DateTimePicker/DateTimePicker.tsx +0 -72
  50. package/src/DateTimePicker/DateTimePickerTabs.tsx +0 -86
  51. package/src/DateTimePicker/DateTimePickerToolbar.tsx +0 -123
  52. package/src/DateTimePicker/index.ts +0 -7
  53. package/src/MuiPickersUtilsProvider.tsx +0 -39
  54. package/src/Picker/Picker.tsx +0 -275
  55. package/src/Picker/WrappedKeyboardPicker.tsx +0 -136
  56. package/src/Picker/WrappedPurePicker.tsx +0 -128
  57. package/src/Rifm/Rifm.ts +0 -213
  58. package/src/TimePicker/TimePicker.tsx +0 -67
  59. package/src/TimePicker/TimePickerToolbar.tsx +0 -180
  60. package/src/TimePicker/index.tsx +0 -7
  61. package/src/__tests__/DatePicker/Calendar.test.tsx +0 -51
  62. package/src/__tests__/DatePicker/Month.test.tsx +0 -36
  63. package/src/__tests__/DatePicker/MonthSelection.test.tsx +0 -37
  64. package/src/__tests__/MuiPickersUtilsProvider.test.tsx +0 -21
  65. package/src/__tests__/TimePicker/Clock.test.tsx +0 -68
  66. package/src/__tests__/_helpers/date-utils.test.tsx +0 -197
  67. package/src/__tests__/_helpers/text-field-helper.test.tsx +0 -34
  68. package/src/__tests__/_shared/ModalDialog.test.tsx +0 -109
  69. package/src/__tests__/e2e/DatePicker.test.tsx +0 -233
  70. package/src/__tests__/e2e/DatePickerProps.test.tsx +0 -18
  71. package/src/__tests__/e2e/DatePickerRoot.test.tsx +0 -154
  72. package/src/__tests__/e2e/DateTimePicker.test.tsx +0 -86
  73. package/src/__tests__/e2e/DateTimePickerRoot.test.tsx +0 -72
  74. package/src/__tests__/e2e/KeyboardDatePicker.test.tsx +0 -140
  75. package/src/__tests__/e2e/KeyboardDateTimePicker.test.tsx +0 -48
  76. package/src/__tests__/e2e/Theme.test.tsx +0 -30
  77. package/src/__tests__/e2e/TimePicker.test.tsx +0 -121
  78. package/src/__tests__/e2e/commands.tsx +0 -8
  79. package/src/__tests__/setup.js +0 -26
  80. package/src/__tests__/test-utils.tsx +0 -45
  81. package/src/__tests__/tsconfig.json +0 -5
  82. package/src/_helpers/date-utils.ts +0 -92
  83. package/src/_helpers/text-field-helper.ts +0 -239
  84. package/src/_helpers/time-utils.ts +0 -83
  85. package/src/_helpers/utils.ts +0 -8
  86. package/src/_shared/KeyboardDateInput.tsx +0 -161
  87. package/src/_shared/ModalDialog.tsx +0 -114
  88. package/src/_shared/PickerToolbar.tsx +0 -52
  89. package/src/_shared/PureDateInput.tsx +0 -45
  90. package/src/_shared/ToolbarButton.tsx +0 -63
  91. package/src/_shared/ToolbarText.tsx +0 -49
  92. package/src/_shared/WithUtils.tsx +0 -19
  93. package/src/_shared/hooks/useIsLandscape.tsx +0 -27
  94. package/src/_shared/hooks/useKeyDown.ts +0 -34
  95. package/src/_shared/hooks/useKeyboardPickerState.ts +0 -72
  96. package/src/_shared/hooks/useOpenState.ts +0 -22
  97. package/src/_shared/hooks/usePickerState.ts +0 -134
  98. package/src/_shared/hooks/useUtils.ts +0 -20
  99. package/src/_shared/hooks/useViews.tsx +0 -31
  100. package/src/_shared/icons/ArrowLeftIcon.tsx +0 -11
  101. package/src/_shared/icons/ArrowRightIcon.tsx +0 -11
  102. package/src/_shared/icons/DateRangeIcon.tsx +0 -11
  103. package/src/_shared/icons/KeyboardIcon.tsx +0 -11
  104. package/src/_shared/icons/TimeIcon.tsx +0 -12
  105. package/src/constants/ClockType.ts +0 -11
  106. package/src/constants/dimensions.ts +0 -5
  107. package/src/constants/prop-types.ts +0 -37
  108. package/src/index.ts +0 -48
  109. package/src/typings/BasePicker.tsx +0 -60
  110. package/src/typings/date.ts +0 -3
  111. package/src/typings/extendMui.ts +0 -10
  112. package/src/typings/overrides.ts +0 -44
  113. package/src/views/Calendar/Calendar.tsx +0 -361
  114. package/src/views/Calendar/CalendarHeader.tsx +0 -141
  115. package/src/views/Calendar/Day.tsx +0 -97
  116. package/src/views/Calendar/DayWrapper.tsx +0 -33
  117. package/src/views/Calendar/SlideTransition.tsx +0 -100
  118. package/src/views/Clock/Clock.tsx +0 -172
  119. package/src/views/Clock/ClockNumber.tsx +0 -91
  120. package/src/views/Clock/ClockNumbers.tsx +0 -76
  121. package/src/views/Clock/ClockPointer.tsx +0 -104
  122. package/src/views/Clock/ClockView.tsx +0 -105
  123. package/src/views/Month/Month.tsx +0 -76
  124. package/src/views/Month/MonthView.tsx +0 -94
  125. package/src/views/Year/Year.tsx +0 -77
  126. package/src/views/Year/YearView.tsx +0 -91
  127. package/src/wrappers/InlineWrapper.tsx +0 -80
  128. package/src/wrappers/ModalWrapper.tsx +0 -113
  129. package/src/wrappers/StaticWrapper.tsx +0 -22
  130. package/src/wrappers/Wrapper.tsx +0 -75
  131. package/tsconfig.json +0 -21
  132. package/typings.d.ts +0 -6
  133. /package/{build/DatePicker → DatePicker}/DatePicker.d.ts +0 -0
  134. /package/{build/DatePicker → DatePicker}/DatePicker.js +0 -0
  135. /package/{build/DatePicker → DatePicker}/DatePickerToolbar.d.ts +0 -0
  136. /package/{build/DatePicker → DatePicker}/index.d.ts +0 -0
  137. /package/{build/DatePicker → DatePicker}/index.js +0 -0
  138. /package/{build/DateTimePicker → DateTimePicker}/DateTimePickerTabs.d.ts +0 -0
  139. /package/{build/DateTimePicker → DateTimePicker}/DateTimePickerTabs.js +0 -0
  140. /package/{build/DateTimePicker → DateTimePicker}/DateTimePickerToolbar.d.ts +0 -0
  141. /package/{build/DateTimePicker → DateTimePicker}/index.d.ts +0 -0
  142. /package/{build/DateTimePicker → DateTimePicker}/index.js +0 -0
  143. /package/{build/MuiPickersUtilsProvider.js → MuiPickersUtilsProvider.js} +0 -0
  144. /package/{build/Picker → Picker}/WrappedKeyboardPicker.d.ts +0 -0
  145. /package/{build/Picker → Picker}/WrappedKeyboardPicker.js +0 -0
  146. /package/{build/Picker → Picker}/WrappedPurePicker.d.ts +0 -0
  147. /package/{build/README.md → README.md} +0 -0
  148. /package/{build/Rifm → Rifm}/Rifm.d.ts +0 -0
  149. /package/{build/Rifm → Rifm}/Rifm.js +0 -0
  150. /package/{build/TimePicker → TimePicker}/TimePickerToolbar.d.ts +0 -0
  151. /package/{build/TimePicker → TimePicker}/index.d.ts +0 -0
  152. /package/{build/TimePicker → TimePicker}/index.js +0 -0
  153. /package/{build/_helpers → _helpers}/time-utils.js +0 -0
  154. /package/{build/_helpers → _helpers}/utils.d.ts +0 -0
  155. /package/{build/_helpers → _helpers}/utils.js +0 -0
  156. /package/{build/_shared → _shared}/KeyboardDateInput.d.ts +0 -0
  157. /package/{build/_shared → _shared}/KeyboardDateInput.js +0 -0
  158. /package/{build/_shared → _shared}/ModalDialog.d.ts +0 -0
  159. /package/{build/_shared → _shared}/ModalDialog.js +0 -0
  160. /package/{build/_shared → _shared}/PickerToolbar.d.ts +0 -0
  161. /package/{build/_shared → _shared}/PickerToolbar.js +0 -0
  162. /package/{build/_shared → _shared}/PureDateInput.d.ts +0 -0
  163. /package/{build/_shared → _shared}/PureDateInput.js +0 -0
  164. /package/{build/_shared → _shared}/ToolbarButton.d.ts +0 -0
  165. /package/{build/_shared → _shared}/ToolbarButton.js +0 -0
  166. /package/{build/_shared → _shared}/ToolbarText.d.ts +0 -0
  167. /package/{build/_shared → _shared}/ToolbarText.js +0 -0
  168. /package/{build/_shared → _shared}/WithUtils.js +0 -0
  169. /package/{build/_shared → _shared}/hooks/useIsLandscape.d.ts +0 -0
  170. /package/{build/_shared → _shared}/hooks/useIsLandscape.js +0 -0
  171. /package/{build/_shared → _shared}/hooks/useKeyDown.d.ts +0 -0
  172. /package/{build/_shared → _shared}/hooks/useKeyDown.js +0 -0
  173. /package/{build/_shared → _shared}/hooks/useKeyboardPickerState.d.ts +0 -0
  174. /package/{build/_shared → _shared}/hooks/useOpenState.d.ts +0 -0
  175. /package/{build/_shared → _shared}/hooks/useOpenState.js +0 -0
  176. /package/{build/_shared → _shared}/hooks/usePickerState.d.ts +0 -0
  177. /package/{build/_shared → _shared}/hooks/usePickerState.js +0 -0
  178. /package/{build/_shared → _shared}/hooks/useUtils.js +0 -0
  179. /package/{build/_shared → _shared}/hooks/useViews.d.ts +0 -0
  180. /package/{build/_shared → _shared}/hooks/useViews.js +0 -0
  181. /package/{build/_shared → _shared}/icons/ArrowLeftIcon.d.ts +0 -0
  182. /package/{build/_shared → _shared}/icons/ArrowLeftIcon.js +0 -0
  183. /package/{build/_shared → _shared}/icons/ArrowRightIcon.d.ts +0 -0
  184. /package/{build/_shared → _shared}/icons/ArrowRightIcon.js +0 -0
  185. /package/{build/_shared → _shared}/icons/DateRangeIcon.d.ts +0 -0
  186. /package/{build/_shared → _shared}/icons/DateRangeIcon.js +0 -0
  187. /package/{build/_shared → _shared}/icons/KeyboardIcon.d.ts +0 -0
  188. /package/{build/_shared → _shared}/icons/KeyboardIcon.js +0 -0
  189. /package/{build/_shared → _shared}/icons/TimeIcon.d.ts +0 -0
  190. /package/{build/_shared → _shared}/icons/TimeIcon.js +0 -0
  191. /package/{build/constants → constants}/ClockType.d.ts +0 -0
  192. /package/{build/constants → constants}/ClockType.js +0 -0
  193. /package/{build/constants → constants}/dimensions.d.ts +0 -0
  194. /package/{build/constants → constants}/dimensions.js +0 -0
  195. /package/{build/constants → constants}/prop-types.d.ts +0 -0
  196. /package/{build/constants → constants}/prop-types.js +0 -0
  197. /package/{build/index.js → index.js} +0 -0
  198. /package/{build/typings → typings}/BasePicker.js +0 -0
  199. /package/{build/typings → typings}/date.d.ts +0 -0
  200. /package/{build/typings → typings}/date.js +0 -0
  201. /package/{build/typings → typings}/extendMui.d.ts +0 -0
  202. /package/{build/typings → typings}/extendMui.js +0 -0
  203. /package/{build/typings → typings}/overrides.d.ts +0 -0
  204. /package/{build/typings → typings}/overrides.js +0 -0
  205. /package/{build/views → views}/Calendar/Calendar.d.ts +0 -0
  206. /package/{build/views → views}/Calendar/CalendarHeader.d.ts +0 -0
  207. /package/{build/views → views}/Calendar/Day.d.ts +0 -0
  208. /package/{build/views → views}/Calendar/Day.js +0 -0
  209. /package/{build/views → views}/Calendar/DayWrapper.d.ts +0 -0
  210. /package/{build/views → views}/Calendar/DayWrapper.js +0 -0
  211. /package/{build/views → views}/Calendar/SlideTransition.d.ts +0 -0
  212. /package/{build/views → views}/Calendar/SlideTransition.js +0 -0
  213. /package/{build/views → views}/Clock/Clock.d.ts +0 -0
  214. /package/{build/views → views}/Clock/ClockNumber.d.ts +0 -0
  215. /package/{build/views → views}/Clock/ClockNumber.js +0 -0
  216. /package/{build/views → views}/Clock/ClockNumbers.js +0 -0
  217. /package/{build/views → views}/Clock/ClockPointer.d.ts +0 -0
  218. /package/{build/views → views}/Clock/ClockPointer.js +0 -0
  219. /package/{build/views → views}/Clock/ClockView.d.ts +0 -0
  220. /package/{build/views → views}/Month/Month.d.ts +0 -0
  221. /package/{build/views → views}/Month/Month.js +0 -0
  222. /package/{build/views → views}/Month/MonthView.d.ts +0 -0
  223. /package/{build/views → views}/Year/Year.d.ts +0 -0
  224. /package/{build/views → views}/Year/Year.js +0 -0
  225. /package/{build/views → views}/Year/YearView.d.ts +0 -0
  226. /package/{build/wrappers → wrappers}/InlineWrapper.d.ts +0 -0
  227. /package/{build/wrappers → wrappers}/InlineWrapper.js +0 -0
  228. /package/{build/wrappers → wrappers}/ModalWrapper.d.ts +0 -0
  229. /package/{build/wrappers → wrappers}/ModalWrapper.js +0 -0
  230. /package/{build/wrappers → wrappers}/StaticWrapper.d.ts +0 -0
  231. /package/{build/wrappers → wrappers}/StaticWrapper.js +0 -0
  232. /package/{build/wrappers → wrappers}/Wrapper.d.ts +0 -0
  233. /package/{build/wrappers → wrappers}/Wrapper.js +0 -0
@@ -1,197 +0,0 @@
1
- import { utilsToUse } from '../test-utils';
2
- import { findClosestEnabledDate } from '../../_helpers/date-utils';
3
-
4
- describe('findClosestEnabledDate', () => {
5
- const day18thText = utilsToUse.getDayText(utilsToUse.date('2018-08-18'));
6
- const only18th = (date: any) => utilsToUse.getDayText(date) !== day18thText;
7
-
8
- it('Should return null if all dates are disabled', () => {
9
- const result = findClosestEnabledDate({
10
- date: utilsToUse.date('2000-01-01'),
11
- minDate: utilsToUse.date('1999-01-01'), // Use close-by min/max dates to reduce the test runtime.
12
- maxDate: utilsToUse.date('2001-01-01'),
13
- utils: utilsToUse,
14
- shouldDisableDate: () => true,
15
- disableFuture: false,
16
- disablePast: false,
17
- });
18
-
19
- expect(result).toBe(null);
20
- });
21
-
22
- it('Should return given date if it is enabled', () => {
23
- const result = findClosestEnabledDate({
24
- date: utilsToUse.date('2000-01-01'),
25
- minDate: utilsToUse.date('1900-01-01'),
26
- maxDate: utilsToUse.date('2200-01-01'),
27
- utils: utilsToUse,
28
- shouldDisableDate: () => false,
29
- disableFuture: false,
30
- disablePast: false,
31
- });
32
-
33
- expect(utilsToUse.isSameDay(result, utilsToUse.date('2000-01-01'))).toBe(true);
34
- });
35
-
36
- it('Should return next 18th going from 10th', () => {
37
- const result = findClosestEnabledDate({
38
- date: utilsToUse.date('2018-08-10'),
39
- minDate: utilsToUse.date('1900-01-01'),
40
- maxDate: utilsToUse.date('2200-01-01'),
41
- utils: utilsToUse,
42
- shouldDisableDate: only18th,
43
- disableFuture: false,
44
- disablePast: false,
45
- });
46
-
47
- expect(utilsToUse.isSameDay(result, utilsToUse.date('2018-08-18'))).toBe(true);
48
- });
49
-
50
- it('Should return previous 18th going from 1st', () => {
51
- const result = findClosestEnabledDate({
52
- date: utilsToUse.date('2018-08-01'),
53
- minDate: utilsToUse.date('1900-01-01'),
54
- maxDate: utilsToUse.date('2200-01-01'),
55
- utils: utilsToUse,
56
- shouldDisableDate: only18th,
57
- disableFuture: false,
58
- disablePast: false,
59
- });
60
-
61
- expect(utilsToUse.isSameDay(result, utilsToUse.date('2018-07-18'))).toBe(true);
62
- });
63
-
64
- it('Should return future 18th if disablePast', () => {
65
- const today = utilsToUse.startOfDay(utilsToUse.date());
66
- const result = findClosestEnabledDate({
67
- date: utilsToUse.date('2000-01-01'),
68
- minDate: utilsToUse.date('1900-01-01'),
69
- maxDate: utilsToUse.date('2200-01-01'),
70
- utils: utilsToUse,
71
- shouldDisableDate: only18th,
72
- disableFuture: false,
73
- disablePast: true,
74
- });
75
-
76
- expect(utilsToUse.getDayText(result)).toBe(day18thText);
77
- expect(utilsToUse.isBefore(result, today)).toBe(false);
78
- expect(utilsToUse.isBefore(result, utilsToUse.addDays(today, 31))).toBe(true);
79
- });
80
-
81
- it('Should return past Saturday if disableFuture', () => {
82
- const today = utilsToUse.startOfDay(utilsToUse.date());
83
- const result = findClosestEnabledDate({
84
- date: utilsToUse.date('2099-01-01'),
85
- minDate: utilsToUse.date('1900-01-01'),
86
- maxDate: utilsToUse.date('2200-01-01'),
87
- utils: utilsToUse,
88
- shouldDisableDate: only18th,
89
- disableFuture: true,
90
- disablePast: false,
91
- });
92
-
93
- expect(utilsToUse.isBeforeDay(result, today)).toBe(true);
94
- expect(utilsToUse.getDayText(result)).toBe(day18thText);
95
- expect(utilsToUse.isBefore(result, utilsToUse.addDays(today, -31))).toBe(false);
96
- });
97
-
98
- it('Should return now if disablePast+disableFuture and now is valid', () => {
99
- const today = utilsToUse.startOfDay(utilsToUse.date());
100
- const result = findClosestEnabledDate({
101
- date: utilsToUse.date('2000-01-01'),
102
- minDate: utilsToUse.date('1900-01-01'),
103
- maxDate: utilsToUse.date('2200-01-01'),
104
- utils: utilsToUse,
105
- shouldDisableDate: () => false,
106
- disableFuture: true,
107
- disablePast: true,
108
- });
109
-
110
- expect(utilsToUse.isSameDay(result, today)).toBe(true);
111
- });
112
-
113
- it('Should return null if disablePast+disableFuture and now is invalid', () => {
114
- const today = utilsToUse.date();
115
- const result = findClosestEnabledDate({
116
- date: utilsToUse.date('2000-01-01'),
117
- minDate: utilsToUse.date('1900-01-01'),
118
- maxDate: utilsToUse.date('2200-01-01'),
119
- utils: utilsToUse,
120
- shouldDisableDate: date => utilsToUse.isSameDay(date, today),
121
- disableFuture: true,
122
- disablePast: true,
123
- });
124
-
125
- expect(result).toBeNull();
126
- });
127
-
128
- it('Should return minDate if it is after the date and valid', () => {
129
- const result = findClosestEnabledDate({
130
- date: utilsToUse.date('2000-01-01'),
131
- minDate: utilsToUse.date('2018-08-18'),
132
- maxDate: utilsToUse.date('2200-01-01'),
133
- utils: utilsToUse,
134
- shouldDisableDate: only18th,
135
- disableFuture: false,
136
- disablePast: false,
137
- });
138
-
139
- expect(utilsToUse.isSameDay(result, utilsToUse.date('2018-08-18'))).toBe(true);
140
- });
141
-
142
- it('Should return next 18th after minDate', () => {
143
- const result = findClosestEnabledDate({
144
- date: utilsToUse.date('2000-01-01'),
145
- minDate: utilsToUse.date('2018-08-01'),
146
- maxDate: utilsToUse.date('2200-01-01'),
147
- utils: utilsToUse,
148
- shouldDisableDate: only18th,
149
- disableFuture: false,
150
- disablePast: false,
151
- });
152
-
153
- expect(utilsToUse.isSameDay(result, utilsToUse.date('2018-08-18'))).toBe(true);
154
- });
155
-
156
- it('Should return maxDate if it is before the date and valid', () => {
157
- const result = findClosestEnabledDate({
158
- date: utilsToUse.date('2050-01-01'),
159
- minDate: utilsToUse.date('1900-01-01'),
160
- maxDate: utilsToUse.date('2018-07-18'),
161
- utils: utilsToUse,
162
- shouldDisableDate: only18th,
163
- disableFuture: false,
164
- disablePast: false,
165
- });
166
-
167
- expect(utilsToUse.isSameDay(result, utilsToUse.date('2018-07-18'))).toBe(true);
168
- });
169
-
170
- it('Should return previous 18th before maxDate', () => {
171
- const result = findClosestEnabledDate({
172
- date: utilsToUse.date('2050-01-01'),
173
- minDate: utilsToUse.date('1900-01-01'),
174
- maxDate: utilsToUse.date('2018-08-17'),
175
- utils: utilsToUse,
176
- shouldDisableDate: only18th,
177
- disableFuture: false,
178
- disablePast: false,
179
- });
180
-
181
- expect(utilsToUse.isSameDay(result, utilsToUse.date('2018-07-18'))).toBe(true);
182
- });
183
-
184
- it('Should return null if minDate is after maxDate', () => {
185
- const result = findClosestEnabledDate({
186
- date: utilsToUse.date('2000-01-01'),
187
- minDate: utilsToUse.date('2000-01-01'),
188
- maxDate: utilsToUse.date('1999-01-01'),
189
- utils: utilsToUse,
190
- shouldDisableDate: () => false,
191
- disableFuture: false,
192
- disablePast: false,
193
- });
194
-
195
- expect(result).toBeNull();
196
- });
197
- });
@@ -1,34 +0,0 @@
1
- import {
2
- makeMaskFromFormat,
3
- maskedDateFormatter,
4
- pick12hOr24hFormat,
5
- } from '../../_helpers/text-field-helper';
6
-
7
- const refuse = /[^\d]+/gi;
8
- describe('test-field-helper', () => {
9
- test('maskedDateFormatter', () => {
10
- const formatterFn = maskedDateFormatter('__/__/____', '_', refuse);
11
-
12
- expect(formatterFn('21')).toBe('21/__/____');
13
- expect(formatterFn('21-12-21')).toBe('21/12/21__');
14
- expect(formatterFn('21-12-2010')).toBe('21/12/2010');
15
- });
16
-
17
- test('makeMaskFromFormat', () => {
18
- expect(makeMaskFromFormat('yyyy-mm-dd', '_')).toBe('____-__-__');
19
- expect(makeMaskFromFormat('YYYY/LL/DD', '_')).toBe('____/__/__');
20
- expect(makeMaskFromFormat('yyyy-mm-dd mm:hh', '_')).toBe('____-__-__ __:__');
21
- });
22
-
23
- test('pick12hOr24hFormat', () => {
24
- expect(pick12hOr24hFormat(undefined, true, { '12h': 'hh:mm a', '24h': 'HH:mm' })).toBe(
25
- 'hh:mm a'
26
- );
27
- expect(pick12hOr24hFormat(undefined, undefined, { '12h': 'hh:mm a', '24h': 'HH:mm' })).toBe(
28
- 'hh:mm a'
29
- );
30
- expect(pick12hOr24hFormat(undefined, false, { '12h': 'hh:mm a', '24h': 'HH:mm' })).toBe(
31
- 'HH:mm'
32
- );
33
- });
34
- });
@@ -1,109 +0,0 @@
1
- import * as React from 'react';
2
- import { ShallowWrapper } from 'enzyme';
3
- import { shallow } from '../test-utils';
4
- import { ModalDialog, ModalDialogProps } from '../../_shared/ModalDialog';
5
-
6
- const initialProps = {
7
- onAccept: jest.fn(),
8
- onDismiss: jest.fn(),
9
- onClear: jest.fn(),
10
- onKeyDownInner: jest.fn(),
11
- okLabel: 'OK',
12
- open: false,
13
- cancelLabel: 'Cancel',
14
- clearLabel: 'Clear',
15
- clearable: false,
16
- todayLabel: 'Today',
17
- showTodayButton: false,
18
- onSetToday: jest.fn(),
19
- children: 'Test',
20
- classes: {} as any,
21
- };
22
-
23
- describe('ModalDialog', () => {
24
- let component: ShallowWrapper<ModalDialogProps>;
25
- const props = { ...initialProps };
26
-
27
- beforeEach(() => {
28
- component = shallow(<ModalDialog {...props} />);
29
- });
30
-
31
- it('Should render dialog content', () => {
32
- expect(component.find('WithStyles(ForwardRef(DialogContent))').props().children).toBe(
33
- props.children
34
- );
35
- });
36
-
37
- it('Should render dialog actions with 2 buttons', () => {
38
- expect(component.find('WithStyles(ForwardRef(DialogActions))').length).toBe(1);
39
- expect(
40
- component
41
- .find('WithStyles(ForwardRef(Button))')
42
- .at(0)
43
- .props().children
44
- ).toBe('Cancel');
45
-
46
- expect(
47
- component
48
- .find('WithStyles(ForwardRef(Button))')
49
- .at(1)
50
- .props().children
51
- ).toBe('OK');
52
- });
53
-
54
- it('Should handle on OK button click', () => {
55
- component
56
- .find('WithStyles(ForwardRef(Button))')
57
- .at(1)
58
- .simulate('click');
59
- expect(props.onAccept).toHaveBeenCalled();
60
- });
61
-
62
- it('Should handle on Cancel button click', () => {
63
- component
64
- .find('WithStyles(ForwardRef(Button))')
65
- .at(0)
66
- .simulate('click');
67
- expect(props.onDismiss).toHaveBeenCalled();
68
- });
69
- });
70
-
71
- describe('ModalDialog with Clear Button', () => {
72
- let component: ShallowWrapper<ModalDialogProps>;
73
- const props = {
74
- ...initialProps,
75
- clearable: true,
76
- };
77
-
78
- beforeEach(() => {
79
- component = shallow(<ModalDialog {...props} />);
80
- });
81
-
82
- it('Should handle on Clear button click', () => {
83
- component
84
- .find('WithStyles(ForwardRef(Button))')
85
- .at(0)
86
- .simulate('click');
87
- expect(props.onClear).toHaveBeenCalled();
88
- });
89
- });
90
-
91
- describe('ModalDialog with Today Button', () => {
92
- let component: ShallowWrapper<ModalDialogProps>;
93
- const props = {
94
- ...initialProps,
95
- showTodayButton: true,
96
- };
97
-
98
- beforeEach(() => {
99
- component = shallow(<ModalDialog {...props} />);
100
- });
101
-
102
- it('Should handle on Clear button click', () => {
103
- component
104
- .find('WithStyles(ForwardRef(Button))')
105
- .at(0)
106
- .simulate('click');
107
- expect(props.onSetToday).toHaveBeenCalled();
108
- });
109
- });
@@ -1,233 +0,0 @@
1
- import * as React from 'react';
2
- import { ReactWrapper } from 'enzyme';
3
- import { mount, utilsToUse } from '../test-utils';
4
- import { DatePicker, DatePickerProps } from '../../DatePicker/DatePicker';
5
-
6
- describe('e2e - DatePicker default year format', () => {
7
- let component: ReactWrapper<DatePickerProps>;
8
- const onChangeMock = jest.fn();
9
- const date = utilsToUse.date('2018-01-01T00:00:00.000Z');
10
-
11
- beforeEach(() => {
12
- jest.clearAllMocks();
13
- component = mount(
14
- <DatePicker
15
- animateYearScrolling={false}
16
- value={utilsToUse.date('2018-01-01T00:00:00.000')}
17
- onChange={onChangeMock}
18
- views={['year']}
19
- />
20
- );
21
- });
22
-
23
- it('Should use year format by default for year only view', () => {
24
- expect(component.find('input').props().value).toBe(
25
- utilsToUse.format(date, utilsToUse.yearFormat)
26
- );
27
- });
28
- });
29
-
30
- describe('e2e - DatePicker default year month format', () => {
31
- let component: ReactWrapper<DatePickerProps>;
32
- const onChangeMock = jest.fn();
33
- const date = utilsToUse.date('2018-01-01T00:00:00.000Z');
34
-
35
- beforeEach(() => {
36
- component = mount(
37
- <DatePicker onChange={onChangeMock} value={date} views={['year', 'month']} />
38
- );
39
- });
40
-
41
- it('Should use year month format by default for year & month views', () => {
42
- expect(component.find('input').props().value).toBe(
43
- utilsToUse.format(date, utilsToUse.yearMonthFormat)
44
- );
45
- });
46
- });
47
-
48
- describe('e2e - DatePicker default year month day format', () => {
49
- let component: ReactWrapper<DatePickerProps>;
50
- const onChangeMock = jest.fn();
51
- const date = utilsToUse.date('2018-01-01T00:00:00.000Z');
52
-
53
- beforeEach(() => {
54
- component = mount(
55
- <DatePicker onChange={onChangeMock} value={date} views={['year', 'month', 'date']} />
56
- );
57
- });
58
-
59
- it('Should use default for year & month & day views', () => {
60
- expect(component.find('input').props().value).toBe(
61
- utilsToUse.format(date, utilsToUse.dateFormat)
62
- );
63
- });
64
- });
65
-
66
- describe('e2e - DatePicker inline variant', () => {
67
- let component: ReactWrapper<DatePickerProps>;
68
- const onChangeMock = jest.fn();
69
- const onCloseMock = jest.fn();
70
- const onOpenMock = jest.fn();
71
-
72
- beforeEach(() => {
73
- jest.clearAllMocks();
74
- component = mount(
75
- <DatePicker
76
- autoOk
77
- variant="inline"
78
- animateYearScrolling={false}
79
- onChange={onChangeMock}
80
- onClose={onCloseMock}
81
- onOpen={onOpenMock}
82
- value={utilsToUse.date('2018-01-01T00:00:00.000Z')}
83
- />
84
- );
85
- });
86
-
87
- it('Should renders', () => {
88
- expect(component).toBeTruthy();
89
- });
90
-
91
- it('Should open modal with picker on click', () => {
92
- component.find('input').simulate('click');
93
-
94
- expect(component.find('WithStyles(ForwardRef(Popover))').props().open).toBeTruthy();
95
- expect(onOpenMock).toHaveBeenCalled();
96
- });
97
-
98
- it('Should close on popover close request', () => {
99
- const popoverOnClose = component
100
- .find('WithStyles(ForwardRef(Popover))')
101
- .prop('onClose') as () => void;
102
-
103
- popoverOnClose();
104
-
105
- expect(component.find('WithStyles(ForwardRef(Popover))').prop('open')).toBeFalsy();
106
- expect(onCloseMock).toHaveBeenCalled();
107
- });
108
-
109
- it('Should dispatch onChange and close on day select', () => {
110
- component.find('input').simulate('click');
111
- component
112
- .find('Day button')
113
- .at(10)
114
- .simulate('click');
115
-
116
- expect(onChangeMock).toHaveBeenCalled();
117
- expect(component.find('WithStyles(ForwardRef(Popover))').props().open).toBeFalsy();
118
- });
119
- });
120
-
121
- describe('e2e - DatePicker without month change', () => {
122
- let component: ReactWrapper<DatePickerProps>;
123
- const onChangeMock = jest.fn();
124
- const date = utilsToUse.date('2018-01-01T00:00:00.000Z');
125
-
126
- beforeEach(() => {
127
- component = mount(<DatePicker open onChange={onChangeMock} value={date} />);
128
- });
129
-
130
- it('Should not add to loading queue if callback is undefined', () => {
131
- component
132
- .find('CalendarHeader button')
133
- .first()
134
- .simulate('click');
135
- expect(
136
- component
137
- .find('Calendar')
138
- .first()
139
- .state('loadingQueue')
140
- ).toEqual(0);
141
- });
142
- });
143
-
144
- describe('e2e - DatePicker month change sync', () => {
145
- let component: ReactWrapper<DatePickerProps>;
146
- const onChangeMock = jest.fn();
147
- const onMonthChangeMock = jest.fn();
148
- const date = utilsToUse.date('2018-01-01T00:00:00.000Z');
149
-
150
- beforeEach(() => {
151
- component = mount(
152
- <DatePicker open onChange={onChangeMock} onMonthChange={onMonthChangeMock} value={date} />
153
- );
154
- });
155
-
156
- it('Should not add to loading queue when synchronous', () => {
157
- component
158
- .find('CalendarHeader button')
159
- .first()
160
- .simulate('click');
161
- expect(
162
- component
163
- .find('Calendar')
164
- .first()
165
- .state('loadingQueue')
166
- ).toEqual(0);
167
- });
168
- });
169
-
170
- describe('e2e - DatePicker month change async', () => {
171
- let component: ReactWrapper<DatePickerProps>;
172
- const onChangeMock = jest.fn();
173
-
174
- const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));
175
- const promise = sleep(50);
176
- const onMonthChangeAsyncMock = jest.fn(async () => {
177
- await promise;
178
- });
179
-
180
- const date = utilsToUse.date('2018-01-01T00:00:00.000Z');
181
-
182
- beforeEach(() => {
183
- component = mount(
184
- <DatePicker
185
- open
186
- onChange={onChangeMock}
187
- onMonthChange={onMonthChangeAsyncMock}
188
- value={date}
189
- />
190
- );
191
- });
192
-
193
- it('Should add to loading queue when loading asynchronous data', () => {
194
- component
195
- .find('CalendarHeader button')
196
- .first()
197
- .simulate('click');
198
-
199
- expect(
200
- component
201
- .find('Calendar')
202
- .first()
203
- .state('loadingQueue')
204
- ).toEqual(1);
205
- });
206
-
207
- it('Should empty loading queue after loading asynchronous data', async () => {
208
- component
209
- .find('CalendarHeader button')
210
- .first()
211
- .simulate('click');
212
- await sleep(100);
213
- expect(
214
- component
215
- .find('Calendar')
216
- .first()
217
- .state('loadingQueue')
218
- ).toEqual(0);
219
- });
220
- });
221
-
222
- test('Custom toolbar component', () => {
223
- const component = mount(
224
- <DatePicker
225
- open
226
- value={new Date()}
227
- onChange={jest.fn()}
228
- ToolbarComponent={() => <div id="custom-toolbar" />}
229
- />
230
- );
231
-
232
- expect(component.find('#custom-toolbar').length).toBe(1);
233
- });
@@ -1,18 +0,0 @@
1
- import * as React from 'react';
2
- import { mount, utilsToUse } from '../test-utils';
3
- import { DatePicker } from '../../DatePicker/DatePicker';
4
-
5
- describe('DatePicker - different props', () => {
6
- it('Should not render toolbar if onlyCalendar = true', () => {
7
- const component = mount(
8
- <DatePicker
9
- open
10
- disableToolbar
11
- onChange={jest.fn()}
12
- value={utilsToUse.date('2018-01-01T00:00:00.000Z')}
13
- />
14
- );
15
-
16
- expect(component.find('WithStyles(PickerToolbar)').length).toBe(0);
17
- });
18
- });