@ohos-ports/flowbite-datepicker 2.0.0-beta.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.
- package/.eslintignore +2 -0
- package/.eslintrc.js +73 -0
- package/.stylelintrc +12 -0
- package/CHANGELOG.md +72 -0
- package/LICENSE +21 -0
- package/README.md +71 -0
- package/demo/index.html +582 -0
- package/demo/live-demo.js +471 -0
- package/dist/DateRangePicker.cjs.js +2996 -0
- package/dist/DateRangePicker.esm.js +2994 -0
- package/dist/DateRangePicker.umd.js +3002 -0
- package/dist/Datepicker.cjs.js +2778 -0
- package/dist/Datepicker.esm.js +2776 -0
- package/dist/Datepicker.umd.js +2784 -0
- package/dist/css/datepicker-bs4.css +276 -0
- package/dist/css/datepicker-bs4.min.css +1 -0
- package/dist/css/datepicker-bs5.css +276 -0
- package/dist/css/datepicker-bs5.min.css +1 -0
- package/dist/css/datepicker-bulma.css +258 -0
- package/dist/css/datepicker-bulma.min.css +1 -0
- package/dist/css/datepicker-foundation.css +262 -0
- package/dist/css/datepicker-foundation.min.css +1 -0
- package/dist/css/datepicker.css +306 -0
- package/dist/css/datepicker.min.css +1403 -0
- package/dist/js/datepicker-full.js +2777 -0
- package/dist/js/datepicker-full.min.js +1 -0
- package/dist/js/datepicker.js +2569 -0
- package/dist/js/datepicker.min.js +1 -0
- package/dist/js/locales/ar-tn.js +15 -0
- package/dist/js/locales/ar.js +15 -0
- package/dist/js/locales/az.js +14 -0
- package/dist/js/locales/bg.js +14 -0
- package/dist/js/locales/bm.js +18 -0
- package/dist/js/locales/bn.js +19 -0
- package/dist/js/locales/br.js +18 -0
- package/dist/js/locales/bs.js +15 -0
- package/dist/js/locales/ca.js +18 -0
- package/dist/js/locales/cs.js +19 -0
- package/dist/js/locales/cy.js +14 -0
- package/dist/js/locales/da.js +19 -0
- package/dist/js/locales/de.js +18 -0
- package/dist/js/locales/el.js +16 -0
- package/dist/js/locales/en-AU.js +18 -0
- package/dist/js/locales/en-CA.js +18 -0
- package/dist/js/locales/en-GB.js +18 -0
- package/dist/js/locales/en-IE.js +17 -0
- package/dist/js/locales/en-NZ.js +17 -0
- package/dist/js/locales/en-ZA.js +17 -0
- package/dist/js/locales/eo.js +17 -0
- package/dist/js/locales/es.js +18 -0
- package/dist/js/locales/et.js +18 -0
- package/dist/js/locales/eu.js +18 -0
- package/dist/js/locales/fa.js +17 -0
- package/dist/js/locales/fi.js +17 -0
- package/dist/js/locales/fo.js +15 -0
- package/dist/js/locales/fr-CH.js +21 -0
- package/dist/js/locales/fr.js +18 -0
- package/dist/js/locales/gl.js +16 -0
- package/dist/js/locales/he.js +15 -0
- package/dist/js/locales/hi.js +18 -0
- package/dist/js/locales/hr.js +13 -0
- package/dist/js/locales/hu.js +18 -0
- package/dist/js/locales/hy.js +18 -0
- package/dist/js/locales/id.js +15 -0
- package/dist/js/locales/is.js +14 -0
- package/dist/js/locales/it-CH.js +20 -0
- package/dist/js/locales/it.js +18 -0
- package/dist/js/locales/ja.js +17 -0
- package/dist/js/locales/ka.js +17 -0
- package/dist/js/locales/kk.js +15 -0
- package/dist/js/locales/km.js +15 -0
- package/dist/js/locales/ko.js +18 -0
- package/dist/js/locales/lt.js +19 -0
- package/dist/js/locales/lv.js +18 -0
- package/dist/js/locales/me.js +17 -0
- package/dist/js/locales/mk.js +15 -0
- package/dist/js/locales/mn.js +17 -0
- package/dist/js/locales/mr.js +18 -0
- package/dist/js/locales/ms.js +15 -0
- package/dist/js/locales/nl-BE.js +18 -0
- package/dist/js/locales/nl.js +18 -0
- package/dist/js/locales/no.js +18 -0
- package/dist/js/locales/oc.js +17 -0
- package/dist/js/locales/pl.js +17 -0
- package/dist/js/locales/pt-BR.js +17 -0
- package/dist/js/locales/pt.js +18 -0
- package/dist/js/locales/ro.js +17 -0
- package/dist/js/locales/ru.js +18 -0
- package/dist/js/locales/si.js +18 -0
- package/dist/js/locales/sk.js +18 -0
- package/dist/js/locales/sl.js +15 -0
- package/dist/js/locales/sq.js +18 -0
- package/dist/js/locales/sr-latn.js +16 -0
- package/dist/js/locales/sr.js +16 -0
- package/dist/js/locales/sv.js +17 -0
- package/dist/js/locales/sw.js +15 -0
- package/dist/js/locales/ta.js +18 -0
- package/dist/js/locales/tg.js +19 -0
- package/dist/js/locales/th.js +14 -0
- package/dist/js/locales/tk.js +18 -0
- package/dist/js/locales/tr.js +17 -0
- package/dist/js/locales/uk.js +17 -0
- package/dist/js/locales/uz-cyrl.js +18 -0
- package/dist/js/locales/uz-latn.js +18 -0
- package/dist/js/locales/vi.js +16 -0
- package/dist/js/locales/zh-CN.js +19 -0
- package/dist/js/locales/zh-TW.js +18 -0
- package/dist/locales/index.cjs.js +1028 -0
- package/dist/locales/index.esm.js +1028 -0
- package/dist/main.cjs.js +2999 -0
- package/dist/main.esm.js +2994 -0
- package/dist/main.umd.js +3005 -0
- package/docs/.nojekyll +0 -0
- package/docs/README.md +266 -0
- package/docs/_sidebar.md +6 -0
- package/docs/api.md +284 -0
- package/docs/date-string+format.md +90 -0
- package/docs/i18n.md +99 -0
- package/docs/images/datepicker-inline.jpg +0 -0
- package/docs/images/datepicker.jpg +0 -0
- package/docs/images/multidate.jpg +0 -0
- package/docs/images/picker-structure.jpg +0 -0
- package/docs/images/rangepicker.jpg +0 -0
- package/docs/images/view-days.jpg +0 -0
- package/docs/images/view-decades.jpg +0 -0
- package/docs/images/view-months.jpg +0 -0
- package/docs/images/view-years.jpg +0 -0
- package/docs/index.html +26 -0
- package/docs/options.md +354 -0
- package/docs/overview.md +174 -0
- package/extras/twoDigitToFullYear/test/twoDigitToFullYear.js +58 -0
- package/extras/twoDigitToFullYear/twoDigitToFullYear.js +26 -0
- package/js/DateRangePicker.js +210 -0
- package/js/Datepicker.js +487 -0
- package/js/datepicker-full.js +5 -0
- package/js/events/functions.js +48 -0
- package/js/events/inputFieldListeners.js +206 -0
- package/js/events/otherListeners.js +15 -0
- package/js/events/pickerListeners.js +70 -0
- package/js/i18n/base-locales.js +13 -0
- package/js/i18n/locales/ar-tn.js +15 -0
- package/js/i18n/locales/ar.js +15 -0
- package/js/i18n/locales/az.js +14 -0
- package/js/i18n/locales/bg.js +14 -0
- package/js/i18n/locales/bm.js +18 -0
- package/js/i18n/locales/bn.js +19 -0
- package/js/i18n/locales/br.js +18 -0
- package/js/i18n/locales/bs.js +15 -0
- package/js/i18n/locales/ca.js +18 -0
- package/js/i18n/locales/cs.js +19 -0
- package/js/i18n/locales/cy.js +14 -0
- package/js/i18n/locales/da.js +19 -0
- package/js/i18n/locales/de.js +18 -0
- package/js/i18n/locales/el.js +16 -0
- package/js/i18n/locales/en-AU.js +18 -0
- package/js/i18n/locales/en-CA.js +18 -0
- package/js/i18n/locales/en-GB.js +18 -0
- package/js/i18n/locales/en-IE.js +17 -0
- package/js/i18n/locales/en-NZ.js +17 -0
- package/js/i18n/locales/en-ZA.js +17 -0
- package/js/i18n/locales/eo.js +17 -0
- package/js/i18n/locales/es.js +18 -0
- package/js/i18n/locales/et.js +18 -0
- package/js/i18n/locales/eu.js +18 -0
- package/js/i18n/locales/fa.js +17 -0
- package/js/i18n/locales/fi.js +17 -0
- package/js/i18n/locales/fo.js +15 -0
- package/js/i18n/locales/fr-CH.js +21 -0
- package/js/i18n/locales/fr.js +18 -0
- package/js/i18n/locales/gl.js +16 -0
- package/js/i18n/locales/he.js +15 -0
- package/js/i18n/locales/hi.js +18 -0
- package/js/i18n/locales/hr.js +13 -0
- package/js/i18n/locales/hu.js +18 -0
- package/js/i18n/locales/hy.js +18 -0
- package/js/i18n/locales/id.js +15 -0
- package/js/i18n/locales/is.js +14 -0
- package/js/i18n/locales/it-CH.js +20 -0
- package/js/i18n/locales/it.js +18 -0
- package/js/i18n/locales/ja.js +17 -0
- package/js/i18n/locales/ka.js +17 -0
- package/js/i18n/locales/kk.js +15 -0
- package/js/i18n/locales/km.js +15 -0
- package/js/i18n/locales/ko.js +18 -0
- package/js/i18n/locales/lt.js +19 -0
- package/js/i18n/locales/lv.js +18 -0
- package/js/i18n/locales/me.js +17 -0
- package/js/i18n/locales/mk.js +15 -0
- package/js/i18n/locales/mn.js +17 -0
- package/js/i18n/locales/mr.js +18 -0
- package/js/i18n/locales/ms.js +15 -0
- package/js/i18n/locales/nl-BE.js +18 -0
- package/js/i18n/locales/nl.js +18 -0
- package/js/i18n/locales/no.js +18 -0
- package/js/i18n/locales/oc.js +17 -0
- package/js/i18n/locales/pl.js +17 -0
- package/js/i18n/locales/pt-BR.js +17 -0
- package/js/i18n/locales/pt.js +18 -0
- package/js/i18n/locales/ro.js +17 -0
- package/js/i18n/locales/ru.js +18 -0
- package/js/i18n/locales/si.js +18 -0
- package/js/i18n/locales/sk.js +18 -0
- package/js/i18n/locales/sl.js +15 -0
- package/js/i18n/locales/sq.js +18 -0
- package/js/i18n/locales/sr-latn.js +16 -0
- package/js/i18n/locales/sr.js +16 -0
- package/js/i18n/locales/sv.js +17 -0
- package/js/i18n/locales/sw.js +15 -0
- package/js/i18n/locales/ta.js +18 -0
- package/js/i18n/locales/tg.js +19 -0
- package/js/i18n/locales/th.js +14 -0
- package/js/i18n/locales/tk.js +18 -0
- package/js/i18n/locales/tr.js +17 -0
- package/js/i18n/locales/uk.js +17 -0
- package/js/i18n/locales/uz-cyrl.js +18 -0
- package/js/i18n/locales/uz-latn.js +18 -0
- package/js/i18n/locales/vi.js +16 -0
- package/js/i18n/locales/zh-CN.js +19 -0
- package/js/i18n/locales/zh-TW.js +18 -0
- package/js/lib/date-format.js +185 -0
- package/js/lib/date.js +82 -0
- package/js/lib/dom.js +55 -0
- package/js/lib/event.js +68 -0
- package/js/lib/utils.js +61 -0
- package/js/main.js +4 -0
- package/js/options/defaultOptions.js +38 -0
- package/js/options/processOptions.js +263 -0
- package/js/picker/Picker.js +334 -0
- package/js/picker/templates/calendarWeeksTemplate.js +8 -0
- package/js/picker/templates/daysTemplate.js +8 -0
- package/js/picker/templates/pickerTemplate.js +23 -0
- package/js/picker/views/DaysView.js +250 -0
- package/js/picker/views/MonthsView.js +198 -0
- package/js/picker/views/View.js +55 -0
- package/js/picker/views/YearsView.js +170 -0
- package/package.json +81 -0
- package/postcss.config.js +5 -0
- package/rollup.config.js +75 -0
- package/sass/_mixins.scss +12 -0
- package/sass/datepicker-bs4.scss +91 -0
- package/sass/datepicker-bs5.scss +91 -0
- package/sass/datepicker-bulma.scss +69 -0
- package/sass/datepicker-foundation.scss +66 -0
- package/sass/datepicker.scss +436 -0
- package/sass/index-bs4.scss +5 -0
- package/sass/index-bs5.scss +5 -0
- package/sass/index-bulma.scss +6 -0
- package/sass/index-foundation.scss +3 -0
- package/scripts/build-css.js +39 -0
- package/scripts/build-locales.js +57 -0
- package/scripts/convert-bsdp-locales.js +65 -0
- package/scripts/minify-css.js +31 -0
- package/scripts/minify-js.js +17 -0
- package/style.css +10 -0
- package/tailwind.config.js +16 -0
- package/tailwind.css +1389 -0
- package/test/DateRangePicker/DateRangePicker.js +547 -0
- package/test/DateRangePicker/api-methods.js +415 -0
- package/test/DateRangePicker/date-selection.js +472 -0
- package/test/DateRangePicker/options.js +308 -0
- package/test/Datepicker/Datepicker-object.js +236 -0
- package/test/Datepicker/api-methods.js +328 -0
- package/test/_utils/date.js +102 -0
- package/test/_utils/dom.js +70 -0
- package/test/events.js +785 -0
- package/test/inline-mode.js +45 -0
- package/test/keyboard-operation/arrow-down.js +293 -0
- package/test/keyboard-operation/arrow-left.js +255 -0
- package/test/keyboard-operation/arrow-right.js +215 -0
- package/test/keyboard-operation/arrow-up.js +461 -0
- package/test/keyboard-operation/edit-mode.js +458 -0
- package/test/keyboard-operation/keyboard-operation.js +146 -0
- package/test/mouse-operation.js +580 -0
- package/test/options/before-show.js +635 -0
- package/test/options/bulma-datepicker.sublime-workspace +1280 -0
- package/test/options/buttons.js +383 -0
- package/test/options/date-restrictions.js +802 -0
- package/test/options/format.js +281 -0
- package/test/options/multidate.js +380 -0
- package/test/options/options.js +727 -0
- package/test/options/orientation.js +410 -0
- package/test/options/pick-levle+view.js +357 -0
- package/test/test.html +94 -0
- package/test/unit/DateRangePicker.js +192 -0
- package/test/unit/Datepicker.js +307 -0
- package/test/unit/_setup.js +28 -0
- package/test/unit/lib/date-format.js +310 -0
- package/test/unit/lib/date.js +211 -0
- package/test/unit/lib/dom.js +142 -0
- package/test/unit/lib/event.js +207 -0
- package/test/unit/lib/utils.js +135 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
describe('keyboard operation - arrow-right', function () {
|
|
2
|
+
let input;
|
|
3
|
+
|
|
4
|
+
beforeEach(function () {
|
|
5
|
+
input = document.createElement('input');
|
|
6
|
+
testContainer.appendChild(input);
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
afterEach(function () {
|
|
10
|
+
testContainer.removeChild(input);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('moves the view date/month/year/decade to 1 step right side', function () {
|
|
14
|
+
const clock = sinon.useFakeTimers({now: new Date(2024, 5, 12)});
|
|
15
|
+
const {dp, picker} = createDP(input);
|
|
16
|
+
const viewSwitch = getViewSwitch(picker);
|
|
17
|
+
input.focus();
|
|
18
|
+
|
|
19
|
+
simulant.fire(input, 'keydown', {key: 'ArrowRight'});
|
|
20
|
+
expect(viewSwitch.textContent, 'to be', 'June 2024');
|
|
21
|
+
|
|
22
|
+
let cells = getCells(picker);
|
|
23
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[10]]);
|
|
24
|
+
expect(cells[18].textContent, 'to be', '13');
|
|
25
|
+
|
|
26
|
+
viewSwitch.click();
|
|
27
|
+
simulant.fire(input, 'keydown', {key: 'ArrowRight'});
|
|
28
|
+
expect(viewSwitch.textContent, 'to be', '2024');
|
|
29
|
+
|
|
30
|
+
cells = getCells(picker);
|
|
31
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[6]]);
|
|
32
|
+
|
|
33
|
+
viewSwitch.click();
|
|
34
|
+
simulant.fire(input, 'keydown', {key: 'ArrowRight'});
|
|
35
|
+
expect(viewSwitch.textContent, 'to be', '2020-2029');
|
|
36
|
+
|
|
37
|
+
cells = getCells(picker);
|
|
38
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[6]]);
|
|
39
|
+
expect(cells[6].textContent, 'to be', '2025');
|
|
40
|
+
|
|
41
|
+
viewSwitch.click();
|
|
42
|
+
simulant.fire(input, 'keydown', {key: 'ArrowRight'});
|
|
43
|
+
expect(viewSwitch.textContent, 'to be', '2000-2090');
|
|
44
|
+
|
|
45
|
+
cells = getCells(picker);
|
|
46
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[4]]);
|
|
47
|
+
expect(cells[4].textContent, 'to be', '2030');
|
|
48
|
+
|
|
49
|
+
dp.destroy();
|
|
50
|
+
clock.restore();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('also changes month of the days view if the current view date is the last day', function () {
|
|
54
|
+
const clock = sinon.useFakeTimers({now: new Date(2020, 1, 29)});
|
|
55
|
+
const {dp, picker} = createDP(input);
|
|
56
|
+
const viewSwitch = getViewSwitch(picker);
|
|
57
|
+
input.focus();
|
|
58
|
+
|
|
59
|
+
simulant.fire(input, 'keydown', {key: 'ArrowRight'});
|
|
60
|
+
expect(viewSwitch.textContent, 'to be', 'March 2020');
|
|
61
|
+
|
|
62
|
+
let cells = getCells(picker);
|
|
63
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[0]]);
|
|
64
|
+
expect(cells[0].textContent, 'to be', '1');
|
|
65
|
+
|
|
66
|
+
dp.destroy();
|
|
67
|
+
clock.restore();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('also changes year of the months view if the current view month is December', function () {
|
|
71
|
+
const clock = sinon.useFakeTimers({now: new Date(2020, 11, 1)});
|
|
72
|
+
const {dp, picker} = createDP(input);
|
|
73
|
+
const viewSwitch = getViewSwitch(picker);
|
|
74
|
+
input.focus();
|
|
75
|
+
viewSwitch.click();
|
|
76
|
+
|
|
77
|
+
simulant.fire(input, 'keydown', {key: 'ArrowRight'});
|
|
78
|
+
expect(viewSwitch.textContent, 'to be', '2021');
|
|
79
|
+
|
|
80
|
+
let cells = getCells(picker);
|
|
81
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[0]]);
|
|
82
|
+
|
|
83
|
+
dp.destroy();
|
|
84
|
+
clock.restore();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('also changes decade of the years view if the current view year is the end of the decade', function () {
|
|
88
|
+
const clock = sinon.useFakeTimers({now: new Date(2019, 1, 1)});
|
|
89
|
+
const {dp, picker} = createDP(input);
|
|
90
|
+
const viewSwitch = getViewSwitch(picker);
|
|
91
|
+
input.focus();
|
|
92
|
+
viewSwitch.click();
|
|
93
|
+
viewSwitch.click();
|
|
94
|
+
|
|
95
|
+
simulant.fire(input, 'keydown', {key: 'ArrowRight'});
|
|
96
|
+
expect(viewSwitch.textContent, 'to be', '2020-2029');
|
|
97
|
+
|
|
98
|
+
let cells = getCells(picker);
|
|
99
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[1]]);
|
|
100
|
+
expect(cells[1].textContent, 'to be', '2020');
|
|
101
|
+
|
|
102
|
+
dp.destroy();
|
|
103
|
+
clock.restore();
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('also changes century of the decades view if the current view decade is the end of the century', function () {
|
|
107
|
+
const clock = sinon.useFakeTimers({now: new Date(1990, 1, 1)});
|
|
108
|
+
const {dp, picker} = createDP(input);
|
|
109
|
+
const viewSwitch = getViewSwitch(picker);
|
|
110
|
+
input.focus();
|
|
111
|
+
viewSwitch.click();
|
|
112
|
+
viewSwitch.click();
|
|
113
|
+
viewSwitch.click();
|
|
114
|
+
|
|
115
|
+
simulant.fire(input, 'keydown', {key: 'ArrowRight'});
|
|
116
|
+
expect(viewSwitch.textContent, 'to be', '2000-2090');
|
|
117
|
+
|
|
118
|
+
let cells = getCells(picker);
|
|
119
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[1]]);
|
|
120
|
+
expect(cells[1].textContent, 'to be', '2000');
|
|
121
|
+
|
|
122
|
+
dp.destroy();
|
|
123
|
+
clock.restore();
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
describe('with control', function () {
|
|
127
|
+
it('functions as the shortcut key of the next button', function () {
|
|
128
|
+
const clock = sinon.useFakeTimers({now: new Date(2020, 3, 22)});
|
|
129
|
+
const {dp, picker} = createDP(input);
|
|
130
|
+
const viewSwitch = getViewSwitch(picker);
|
|
131
|
+
input.focus();
|
|
132
|
+
|
|
133
|
+
simulant.fire(input, 'keydown', {key: 'ArrowRight', ctrlKey: true});
|
|
134
|
+
expect(viewSwitch.textContent, 'to be', 'May 2020');
|
|
135
|
+
|
|
136
|
+
// view date is changed to the same day of the next month
|
|
137
|
+
let cells = getCells(picker);
|
|
138
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[26]]);
|
|
139
|
+
expect(cells[26].textContent, 'to be', '22');
|
|
140
|
+
|
|
141
|
+
viewSwitch.click();
|
|
142
|
+
simulant.fire(input, 'keydown', {key: 'ArrowRight', ctrlKey: true});
|
|
143
|
+
expect(viewSwitch.textContent, 'to be', '2021');
|
|
144
|
+
|
|
145
|
+
// view date is changed to the same month of the previous year
|
|
146
|
+
cells = getCells(picker);
|
|
147
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[4]]);
|
|
148
|
+
expect(filterCells(cells, '.selected'), 'to equal', []);
|
|
149
|
+
|
|
150
|
+
viewSwitch.click();
|
|
151
|
+
simulant.fire(input, 'keydown', {key: 'ArrowRight', ctrlKey: true});
|
|
152
|
+
expect(viewSwitch.textContent, 'to be', '2030-2039');
|
|
153
|
+
|
|
154
|
+
cells = getCells(picker);
|
|
155
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[2]]);
|
|
156
|
+
expect(cells[2].textContent, 'to be', '2031');
|
|
157
|
+
|
|
158
|
+
viewSwitch.click();
|
|
159
|
+
simulant.fire(input, 'keydown', {key: 'ArrowRight', ctrlKey: true});
|
|
160
|
+
expect(viewSwitch.textContent, 'to be', '2100-2190');
|
|
161
|
+
|
|
162
|
+
cells = getCells(picker);
|
|
163
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[2]]);
|
|
164
|
+
expect(cells[4].textContent, 'to be', '2130');
|
|
165
|
+
|
|
166
|
+
dp.destroy();
|
|
167
|
+
clock.reset();
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
describe('with meta', function () {
|
|
172
|
+
it('functions as a substitute for the "+ctrl" key combination', function () {
|
|
173
|
+
let clock = sinon.useFakeTimers({now: new Date(2020, 3, 22)});
|
|
174
|
+
let {dp, picker} = createDP(input);
|
|
175
|
+
let viewSwitch = getViewSwitch(picker);
|
|
176
|
+
input.focus();
|
|
177
|
+
|
|
178
|
+
simulant.fire(input, 'keydown', {key: 'ArrowRight', metaKey: true});
|
|
179
|
+
expect(viewSwitch.textContent, 'to be', 'May 2020');
|
|
180
|
+
|
|
181
|
+
// view date is changed to the same day of the next month
|
|
182
|
+
let cells = getCells(picker);
|
|
183
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[26]]);
|
|
184
|
+
expect(cells[26].textContent, 'to be', '22');
|
|
185
|
+
|
|
186
|
+
viewSwitch.click();
|
|
187
|
+
simulant.fire(input, 'keydown', {key: 'ArrowRight', metaKey: true});
|
|
188
|
+
expect(viewSwitch.textContent, 'to be', '2021');
|
|
189
|
+
|
|
190
|
+
// view date is changed to the same month of the previous year
|
|
191
|
+
cells = getCells(picker);
|
|
192
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[4]]);
|
|
193
|
+
expect(filterCells(cells, '.selected'), 'to equal', []);
|
|
194
|
+
|
|
195
|
+
viewSwitch.click();
|
|
196
|
+
simulant.fire(input, 'keydown', {key: 'ArrowRight', metaKey: true});
|
|
197
|
+
expect(viewSwitch.textContent, 'to be', '2030-2039');
|
|
198
|
+
|
|
199
|
+
cells = getCells(picker);
|
|
200
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[2]]);
|
|
201
|
+
expect(cells[2].textContent, 'to be', '2031');
|
|
202
|
+
|
|
203
|
+
viewSwitch.click();
|
|
204
|
+
simulant.fire(input, 'keydown', {key: 'ArrowRight', metaKey: true});
|
|
205
|
+
expect(viewSwitch.textContent, 'to be', '2100-2190');
|
|
206
|
+
|
|
207
|
+
cells = getCells(picker);
|
|
208
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[2]]);
|
|
209
|
+
expect(cells[4].textContent, 'to be', '2130');
|
|
210
|
+
|
|
211
|
+
dp.destroy();
|
|
212
|
+
clock.restore();
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
});
|
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
describe('keyboard operation - arrow-up', function () {
|
|
2
|
+
const replaceInput = () => {
|
|
3
|
+
const newInput = document.createElement('input');
|
|
4
|
+
testContainer.replaceChild(newInput, input);
|
|
5
|
+
return newInput;
|
|
6
|
+
};
|
|
7
|
+
let input;
|
|
8
|
+
|
|
9
|
+
beforeEach(function () {
|
|
10
|
+
input = document.createElement('input');
|
|
11
|
+
testContainer.appendChild(input);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
afterEach(function () {
|
|
15
|
+
testContainer.removeChild(input);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('moves the view date/month/year/decade to 1 step up side', function () {
|
|
19
|
+
const clock = sinon.useFakeTimers({now: new Date(2044, 5, 15)});
|
|
20
|
+
const {dp, picker} = createDP(input);
|
|
21
|
+
const viewSwitch = getViewSwitch(picker);
|
|
22
|
+
input.focus();
|
|
23
|
+
|
|
24
|
+
simulant.fire(input, 'keydown', {key: 'ArrowUp'});
|
|
25
|
+
expect(viewSwitch.textContent, 'to be', 'June 2044');
|
|
26
|
+
|
|
27
|
+
let cells = getCells(picker);
|
|
28
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[10]]);
|
|
29
|
+
expect(cells[10].textContent, 'to be', '8');
|
|
30
|
+
|
|
31
|
+
viewSwitch.click();
|
|
32
|
+
simulant.fire(input, 'keydown', {key: 'ArrowUp'});
|
|
33
|
+
expect(viewSwitch.textContent, 'to be', '2044');
|
|
34
|
+
|
|
35
|
+
cells = getCells(picker);
|
|
36
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[1]]);
|
|
37
|
+
|
|
38
|
+
viewSwitch.click();
|
|
39
|
+
simulant.fire(input, 'keydown', {key: 'ArrowUp'});
|
|
40
|
+
expect(viewSwitch.textContent, 'to be', '2040-2049');
|
|
41
|
+
|
|
42
|
+
cells = getCells(picker);
|
|
43
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[1]]);
|
|
44
|
+
expect(cells[1].textContent, 'to be', '2040');
|
|
45
|
+
|
|
46
|
+
viewSwitch.click();
|
|
47
|
+
simulant.fire(input, 'keydown', {key: 'ArrowUp'});
|
|
48
|
+
expect(viewSwitch.textContent, 'to be', '2000-2090');
|
|
49
|
+
|
|
50
|
+
cells = getCells(picker);
|
|
51
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[1]]);
|
|
52
|
+
expect(cells[1].textContent, 'to be', '2000');
|
|
53
|
+
|
|
54
|
+
dp.destroy();
|
|
55
|
+
clock.restore();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('also changes month of the days view if the current view date <= 7th', function () {
|
|
59
|
+
let clock = sinon.useFakeTimers({now: new Date(2020, 2, 1)});
|
|
60
|
+
let {dp, picker} = createDP(input);
|
|
61
|
+
let viewSwitch = getViewSwitch(picker);
|
|
62
|
+
input.focus();
|
|
63
|
+
|
|
64
|
+
simulant.fire(input, 'keydown', {key: 'ArrowUp'});
|
|
65
|
+
expect(viewSwitch.textContent, 'to be', 'February 2020');
|
|
66
|
+
|
|
67
|
+
let cells = getCells(picker);
|
|
68
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[28]]);
|
|
69
|
+
expect(cells[28].textContent, 'to be', '23');
|
|
70
|
+
|
|
71
|
+
dp.destroy();
|
|
72
|
+
clock.restore();
|
|
73
|
+
input = replaceInput();
|
|
74
|
+
|
|
75
|
+
clock = sinon.useFakeTimers({now: new Date(2020, 2, 4)});
|
|
76
|
+
({dp, picker} = createDP(input));
|
|
77
|
+
viewSwitch = getViewSwitch(picker);
|
|
78
|
+
input.focus();
|
|
79
|
+
|
|
80
|
+
simulant.fire(input, 'keydown', {key: 'ArrowUp'});
|
|
81
|
+
expect(viewSwitch.textContent, 'to be', 'February 2020');
|
|
82
|
+
|
|
83
|
+
cells = getCells(picker);
|
|
84
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[31]]);
|
|
85
|
+
expect(cells[31].textContent, 'to be', '26');
|
|
86
|
+
|
|
87
|
+
dp.destroy();
|
|
88
|
+
clock.restore();
|
|
89
|
+
input = replaceInput();
|
|
90
|
+
|
|
91
|
+
clock = sinon.useFakeTimers({now: new Date(2020, 2, 7)});
|
|
92
|
+
({dp, picker} = createDP(input));
|
|
93
|
+
viewSwitch = getViewSwitch(picker);
|
|
94
|
+
input.focus();
|
|
95
|
+
|
|
96
|
+
simulant.fire(input, 'keydown', {key: 'ArrowUp'});
|
|
97
|
+
expect(viewSwitch.textContent, 'to be', 'February 2020');
|
|
98
|
+
|
|
99
|
+
cells = getCells(picker);
|
|
100
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[34]]);
|
|
101
|
+
expect(cells[34].textContent, 'to be', '29');
|
|
102
|
+
|
|
103
|
+
dp.destroy();
|
|
104
|
+
clock.restore();
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('also changes year of the months view if the current view month is Jan/Feb/Mar/Apr', function () {
|
|
108
|
+
let clock = sinon.useFakeTimers({now: new Date(2020, 0, 1)});
|
|
109
|
+
let {dp, picker} = createDP(input);
|
|
110
|
+
let viewSwitch = getViewSwitch(picker);
|
|
111
|
+
input.focus();
|
|
112
|
+
viewSwitch.click();
|
|
113
|
+
|
|
114
|
+
simulant.fire(input, 'keydown', {key: 'ArrowUp'});
|
|
115
|
+
expect(viewSwitch.textContent, 'to be', '2019');
|
|
116
|
+
|
|
117
|
+
let cells = getCells(picker);
|
|
118
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[8]]);
|
|
119
|
+
|
|
120
|
+
dp.destroy();
|
|
121
|
+
clock.restore();
|
|
122
|
+
input = replaceInput();
|
|
123
|
+
|
|
124
|
+
clock = sinon.useFakeTimers({now: new Date(2020, 1, 1)});
|
|
125
|
+
({dp, picker} = createDP(input));
|
|
126
|
+
viewSwitch = getViewSwitch(picker);
|
|
127
|
+
input.focus();
|
|
128
|
+
viewSwitch.click();
|
|
129
|
+
|
|
130
|
+
simulant.fire(input, 'keydown', {key: 'ArrowUp'});
|
|
131
|
+
expect(viewSwitch.textContent, 'to be', '2019');
|
|
132
|
+
|
|
133
|
+
cells = getCells(picker);
|
|
134
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[9]]);
|
|
135
|
+
|
|
136
|
+
dp.destroy();
|
|
137
|
+
clock.restore();
|
|
138
|
+
input = replaceInput();
|
|
139
|
+
|
|
140
|
+
clock = sinon.useFakeTimers({now: new Date(2020, 2, 1)});
|
|
141
|
+
({dp, picker} = createDP(input));
|
|
142
|
+
viewSwitch = getViewSwitch(picker);
|
|
143
|
+
input.focus();
|
|
144
|
+
viewSwitch.click();
|
|
145
|
+
|
|
146
|
+
simulant.fire(input, 'keydown', {key: 'ArrowUp'});
|
|
147
|
+
expect(viewSwitch.textContent, 'to be', '2019');
|
|
148
|
+
|
|
149
|
+
cells = getCells(picker);
|
|
150
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[10]]);
|
|
151
|
+
|
|
152
|
+
dp.destroy();
|
|
153
|
+
clock.restore();
|
|
154
|
+
input = replaceInput();
|
|
155
|
+
|
|
156
|
+
clock = sinon.useFakeTimers({now: new Date(2020, 3, 1)});
|
|
157
|
+
({dp, picker} = createDP(input));
|
|
158
|
+
viewSwitch = getViewSwitch(picker);
|
|
159
|
+
input.focus();
|
|
160
|
+
viewSwitch.click();
|
|
161
|
+
|
|
162
|
+
simulant.fire(input, 'keydown', {key: 'ArrowUp'});
|
|
163
|
+
expect(viewSwitch.textContent, 'to be', '2019');
|
|
164
|
+
|
|
165
|
+
cells = getCells(picker);
|
|
166
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[11]]);
|
|
167
|
+
|
|
168
|
+
dp.destroy();
|
|
169
|
+
clock.restore();
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it('also changes decade of the years view if the current view year is the first 4 of the decade', function () {
|
|
173
|
+
let clock = sinon.useFakeTimers({now: new Date(2020, 1, 1)});
|
|
174
|
+
let {dp, picker} = createDP(input);
|
|
175
|
+
let viewSwitch = getViewSwitch(picker);
|
|
176
|
+
input.focus();
|
|
177
|
+
viewSwitch.click();
|
|
178
|
+
viewSwitch.click();
|
|
179
|
+
|
|
180
|
+
simulant.fire(input, 'keydown', {key: 'ArrowUp'});
|
|
181
|
+
expect(viewSwitch.textContent, 'to be', '2010-2019');
|
|
182
|
+
|
|
183
|
+
let cells = getCells(picker);
|
|
184
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[7]]);
|
|
185
|
+
expect(cells[7].textContent, 'to be', '2016');
|
|
186
|
+
|
|
187
|
+
dp.destroy();
|
|
188
|
+
clock.restore();
|
|
189
|
+
input = replaceInput();
|
|
190
|
+
|
|
191
|
+
clock = sinon.useFakeTimers({now: new Date(2022, 1, 1)});
|
|
192
|
+
({dp, picker} = createDP(input));
|
|
193
|
+
viewSwitch = getViewSwitch(picker);
|
|
194
|
+
input.focus();
|
|
195
|
+
viewSwitch.click();
|
|
196
|
+
viewSwitch.click();
|
|
197
|
+
|
|
198
|
+
simulant.fire(input, 'keydown', {key: 'ArrowUp'});
|
|
199
|
+
expect(viewSwitch.textContent, 'to be', '2010-2019');
|
|
200
|
+
|
|
201
|
+
cells = getCells(picker);
|
|
202
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[9]]);
|
|
203
|
+
expect(cells[9].textContent, 'to be', '2018');
|
|
204
|
+
|
|
205
|
+
dp.destroy();
|
|
206
|
+
clock.restore();
|
|
207
|
+
input = replaceInput();
|
|
208
|
+
|
|
209
|
+
clock = sinon.useFakeTimers({now: new Date(2023, 1, 1)});
|
|
210
|
+
({dp, picker} = createDP(input));
|
|
211
|
+
viewSwitch = getViewSwitch(picker);
|
|
212
|
+
input.focus();
|
|
213
|
+
viewSwitch.click();
|
|
214
|
+
viewSwitch.click();
|
|
215
|
+
|
|
216
|
+
simulant.fire(input, 'keydown', {key: 'ArrowUp'});
|
|
217
|
+
expect(viewSwitch.textContent, 'to be', '2010-2019');
|
|
218
|
+
|
|
219
|
+
cells = getCells(picker);
|
|
220
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[10]]);
|
|
221
|
+
expect(cells[10].textContent, 'to be', '2019');
|
|
222
|
+
|
|
223
|
+
dp.destroy();
|
|
224
|
+
clock.restore();
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
it('also changes century of the decades view if the current view decade is the first 4 of the century', function () {
|
|
228
|
+
let clock = sinon.useFakeTimers({now: new Date(2000, 1, 1)});
|
|
229
|
+
let {dp, picker} = createDP(input);
|
|
230
|
+
let viewSwitch = getViewSwitch(picker);
|
|
231
|
+
input.focus();
|
|
232
|
+
viewSwitch.click();
|
|
233
|
+
viewSwitch.click();
|
|
234
|
+
viewSwitch.click();
|
|
235
|
+
|
|
236
|
+
simulant.fire(input, 'keydown', {key: 'ArrowUp'});
|
|
237
|
+
expect(viewSwitch.textContent, 'to be', '1900-1990');
|
|
238
|
+
|
|
239
|
+
let cells = getCells(picker);
|
|
240
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[7]]);
|
|
241
|
+
expect(cells[7].textContent, 'to be', '1960');
|
|
242
|
+
|
|
243
|
+
dp.destroy();
|
|
244
|
+
clock.restore();
|
|
245
|
+
input = replaceInput();
|
|
246
|
+
|
|
247
|
+
clock = sinon.useFakeTimers({now: new Date(2020, 1, 1)});
|
|
248
|
+
({dp, picker} = createDP(input));
|
|
249
|
+
viewSwitch = getViewSwitch(picker);
|
|
250
|
+
input.focus();
|
|
251
|
+
viewSwitch.click();
|
|
252
|
+
viewSwitch.click();
|
|
253
|
+
viewSwitch.click();
|
|
254
|
+
|
|
255
|
+
simulant.fire(input, 'keydown', {key: 'ArrowUp'});
|
|
256
|
+
expect(viewSwitch.textContent, 'to be', '1900-1990');
|
|
257
|
+
|
|
258
|
+
cells = getCells(picker);
|
|
259
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[9]]);
|
|
260
|
+
expect(cells[9].textContent, 'to be', '1980');
|
|
261
|
+
|
|
262
|
+
dp.destroy();
|
|
263
|
+
clock.restore();
|
|
264
|
+
input = replaceInput();
|
|
265
|
+
|
|
266
|
+
clock = sinon.useFakeTimers({now: new Date(2030, 1, 1)});
|
|
267
|
+
({dp, picker} = createDP(input));
|
|
268
|
+
viewSwitch = getViewSwitch(picker);
|
|
269
|
+
input.focus();
|
|
270
|
+
viewSwitch.click();
|
|
271
|
+
viewSwitch.click();
|
|
272
|
+
viewSwitch.click();
|
|
273
|
+
|
|
274
|
+
simulant.fire(input, 'keydown', {key: 'ArrowUp'});
|
|
275
|
+
expect(viewSwitch.textContent, 'to be', '1900-1990');
|
|
276
|
+
|
|
277
|
+
cells = getCells(picker);
|
|
278
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[10]]);
|
|
279
|
+
expect(cells[10].textContent, 'to be', '1990');
|
|
280
|
+
|
|
281
|
+
dp.destroy();
|
|
282
|
+
clock.restore();
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
it('does nothing if the current view date <= 0000-01-07 in the days view', function () {
|
|
286
|
+
input.value = '01/01/0000';
|
|
287
|
+
|
|
288
|
+
const {dp, picker} = createDP(input);
|
|
289
|
+
const viewSwitch = getViewSwitch(picker);
|
|
290
|
+
input.focus();
|
|
291
|
+
|
|
292
|
+
simulant.fire(input, 'keydown', {key: 'ArrowUp'});
|
|
293
|
+
expect(viewSwitch.textContent, 'to be', 'January 0');
|
|
294
|
+
|
|
295
|
+
let cells = getCells(picker);
|
|
296
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[6]]);
|
|
297
|
+
expect(cells[6].textContent, 'to be', '1');
|
|
298
|
+
|
|
299
|
+
dp.setDate('01/07/0000');
|
|
300
|
+
simulant.fire(input, 'keydown', {key: 'ArrowUp'});
|
|
301
|
+
expect(viewSwitch.textContent, 'to be', 'January 0');
|
|
302
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[12]]);
|
|
303
|
+
expect(cells[12].textContent, 'to be', '7');
|
|
304
|
+
|
|
305
|
+
dp.destroy();
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
it('does nothing if the current view month <= April 0000 in the months view', function () {
|
|
309
|
+
input.value = '01/01/0000';
|
|
310
|
+
|
|
311
|
+
const {dp, picker} = createDP(input);
|
|
312
|
+
const viewSwitch = getViewSwitch(picker);
|
|
313
|
+
input.focus();
|
|
314
|
+
viewSwitch.click();
|
|
315
|
+
|
|
316
|
+
simulant.fire(input, 'keydown', {key: 'ArrowUp'});
|
|
317
|
+
expect(viewSwitch.textContent, 'to be', '0');
|
|
318
|
+
|
|
319
|
+
let cells = getCells(picker);
|
|
320
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[0]]);
|
|
321
|
+
|
|
322
|
+
dp.setDate('04/07/0000');
|
|
323
|
+
viewSwitch.click();
|
|
324
|
+
|
|
325
|
+
simulant.fire(input, 'keydown', {key: 'ArrowUp'});
|
|
326
|
+
expect(viewSwitch.textContent, 'to be', '0');
|
|
327
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[3]]);
|
|
328
|
+
|
|
329
|
+
dp.destroy();
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
it('does nothing if the current view year <= 0004 in the years view', function () {
|
|
333
|
+
input.value = '01/01/0000';
|
|
334
|
+
|
|
335
|
+
const {dp, picker} = createDP(input);
|
|
336
|
+
const viewSwitch = getViewSwitch(picker);
|
|
337
|
+
input.focus();
|
|
338
|
+
viewSwitch.click();
|
|
339
|
+
viewSwitch.click();
|
|
340
|
+
|
|
341
|
+
simulant.fire(input, 'keydown', {key: 'ArrowUp'});
|
|
342
|
+
expect(viewSwitch.textContent, 'to be', '0-9');
|
|
343
|
+
|
|
344
|
+
let cells = getCells(picker);
|
|
345
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[1]]);
|
|
346
|
+
expect(cells[1].textContent, 'to be', '0');
|
|
347
|
+
|
|
348
|
+
dp.setDate('04/07/0004');
|
|
349
|
+
viewSwitch.click();
|
|
350
|
+
viewSwitch.click();
|
|
351
|
+
|
|
352
|
+
simulant.fire(input, 'keydown', {key: 'ArrowUp'});
|
|
353
|
+
expect(viewSwitch.textContent, 'to be', '0-9');
|
|
354
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[5]]);
|
|
355
|
+
expect(cells[5].textContent, 'to be', '4');
|
|
356
|
+
|
|
357
|
+
dp.destroy();
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
it('does nothing if the current view decade <= 0040 in the decades view', function () {
|
|
361
|
+
input.value = '01/01/0000';
|
|
362
|
+
|
|
363
|
+
const {dp, picker} = createDP(input);
|
|
364
|
+
const viewSwitch = getViewSwitch(picker);
|
|
365
|
+
input.focus();
|
|
366
|
+
viewSwitch.click();
|
|
367
|
+
viewSwitch.click();
|
|
368
|
+
viewSwitch.click();
|
|
369
|
+
|
|
370
|
+
simulant.fire(input, 'keydown', {key: 'ArrowLeft'});
|
|
371
|
+
expect(viewSwitch.textContent, 'to be', '0-90');
|
|
372
|
+
|
|
373
|
+
let cells = getCells(picker);
|
|
374
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[1]]);
|
|
375
|
+
expect(cells[1].textContent, 'to be', '0');
|
|
376
|
+
|
|
377
|
+
dp.setDate('04/07/0047');
|
|
378
|
+
viewSwitch.click();
|
|
379
|
+
viewSwitch.click();
|
|
380
|
+
viewSwitch.click();
|
|
381
|
+
|
|
382
|
+
simulant.fire(input, 'keydown', {key: 'ArrowUp'});
|
|
383
|
+
expect(viewSwitch.textContent, 'to be', '0-90');
|
|
384
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[5]]);
|
|
385
|
+
expect(cells[5].textContent, 'to be', '40');
|
|
386
|
+
|
|
387
|
+
dp.destroy();
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
describe('with control', function () {
|
|
391
|
+
it('functions as the shortcut key of the view switch', function () {
|
|
392
|
+
const clock = sinon.useFakeTimers({now: new Date(2020, 3, 22)});
|
|
393
|
+
const {dp, picker} = createDP(input);
|
|
394
|
+
const viewSwitch = getViewSwitch(picker);
|
|
395
|
+
input.focus();
|
|
396
|
+
|
|
397
|
+
simulant.fire(input, 'keydown', {key: 'ArrowUp', ctrlKey: true});
|
|
398
|
+
expect(viewSwitch.textContent, 'to be', '2020');
|
|
399
|
+
|
|
400
|
+
let cells = getCells(picker);
|
|
401
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[3]]);
|
|
402
|
+
|
|
403
|
+
simulant.fire(input, 'keydown', {key: 'ArrowUp', ctrlKey: true});
|
|
404
|
+
expect(viewSwitch.textContent, 'to be', '2020-2029');
|
|
405
|
+
|
|
406
|
+
cells = getCells(picker);
|
|
407
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[1]]);
|
|
408
|
+
expect(cells[1].textContent, 'to be', '2020');
|
|
409
|
+
|
|
410
|
+
simulant.fire(input, 'keydown', {key: 'ArrowUp', ctrlKey: true});
|
|
411
|
+
expect(viewSwitch.textContent, 'to be', '2000-2090');
|
|
412
|
+
|
|
413
|
+
cells = getCells(picker);
|
|
414
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[3]]);
|
|
415
|
+
expect(cells[3].textContent, 'to be', '2020');
|
|
416
|
+
|
|
417
|
+
// does nothig if the view has reached to the max view
|
|
418
|
+
simulant.fire(input, 'keydown', {key: 'ArrowUp', ctrlKey: true});
|
|
419
|
+
expect(viewSwitch.textContent, 'to be', '2000-2090');
|
|
420
|
+
|
|
421
|
+
dp.destroy();
|
|
422
|
+
clock.reset();
|
|
423
|
+
});
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
describe('with meta', function () {
|
|
427
|
+
it('functions as a substitute for the "+ctrl" key combination', function () {
|
|
428
|
+
const clock = sinon.useFakeTimers({now: new Date(2020, 3, 22)});
|
|
429
|
+
const {dp, picker} = createDP(input);
|
|
430
|
+
const viewSwitch = getViewSwitch(picker);
|
|
431
|
+
input.focus();
|
|
432
|
+
|
|
433
|
+
simulant.fire(input, 'keydown', {key: 'ArrowUp', metaKey: true});
|
|
434
|
+
expect(viewSwitch.textContent, 'to be', '2020');
|
|
435
|
+
|
|
436
|
+
let cells = getCells(picker);
|
|
437
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[3]]);
|
|
438
|
+
|
|
439
|
+
simulant.fire(input, 'keydown', {key: 'ArrowUp', metaKey: true});
|
|
440
|
+
expect(viewSwitch.textContent, 'to be', '2020-2029');
|
|
441
|
+
|
|
442
|
+
cells = getCells(picker);
|
|
443
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[1]]);
|
|
444
|
+
expect(cells[1].textContent, 'to be', '2020');
|
|
445
|
+
|
|
446
|
+
simulant.fire(input, 'keydown', {key: 'ArrowUp', metaKey: true});
|
|
447
|
+
expect(viewSwitch.textContent, 'to be', '2000-2090');
|
|
448
|
+
|
|
449
|
+
cells = getCells(picker);
|
|
450
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[3]]);
|
|
451
|
+
expect(cells[3].textContent, 'to be', '2020');
|
|
452
|
+
|
|
453
|
+
// does nothig if the view has reached to the max view
|
|
454
|
+
simulant.fire(input, 'keydown', {key: 'ArrowUp', metaKey: true});
|
|
455
|
+
expect(viewSwitch.textContent, 'to be', '2000-2090');
|
|
456
|
+
|
|
457
|
+
dp.destroy();
|
|
458
|
+
clock.reset();
|
|
459
|
+
});
|
|
460
|
+
});
|
|
461
|
+
});
|