diff options
author | Marvin Borner | 2018-07-13 19:06:45 +0200 |
---|---|---|
committer | Marvin Borner | 2018-07-13 19:06:45 +0200 |
commit | 6fcfb7c04d32e1c8b26a312295bf7ac3ec2d2ad7 (patch) | |
tree | dbc87ef16fa01d5d99116de283592b8fe5e02944 /public/bower_components/bootstrap-datepicker/tests/suites/keyboard_navigation | |
parent | dfd839f27146df0ad0494e11734fc7d310c70ebf (diff) |
Fixed many permissions and began admin interface
Diffstat (limited to 'public/bower_components/bootstrap-datepicker/tests/suites/keyboard_navigation')
3 files changed, 773 insertions, 0 deletions
diff --git a/public/bower_components/bootstrap-datepicker/tests/suites/keyboard_navigation/2011.js b/public/bower_components/bootstrap-datepicker/tests/suites/keyboard_navigation/2011.js new file mode 100644 index 0000000..a64353a --- /dev/null +++ b/public/bower_components/bootstrap-datepicker/tests/suites/keyboard_navigation/2011.js @@ -0,0 +1,228 @@ +module('Keyboard Navigation 2011', { + setup: function(){ + /* + Tests start with picker on March 31, 2011. Fun facts: + + * March 1, 2011 was on a Tuesday + * March 31, 2011 was on a Thursday + */ + this.input = $('<input type="text" value="31-03-2011">') + .appendTo('#qunit-fixture') + .datepicker({format: "dd-mm-yyyy"}) + .focus(); // Activate for visibility checks + this.dp = this.input.data('datepicker'); + this.picker = this.dp.picker; + }, + teardown: function(){ + this.picker.remove(); + } +}); + +test('Regression: by week (up/down arrows); up from Mar 6, 2011 should go to Feb 27, 2011', function(){ + var target; + + this.input.val('06-03-2011').datepicker('update'); + + equal(this.dp.viewMode, 0); + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'March 2011', 'Title is "March 2011"'); + datesEqual(this.dp.viewDate, UTCDate(2011, 2, 6)); + datesEqual(this.dp.dates.get(-1), UTCDate(2011, 2, 6)); + equal(this.dp.focusDate, null); + + // Navigation: -1 week, up arrow key + this.input.trigger({ + type: 'keydown', + keyCode: 38 + }); + datesEqual(this.dp.viewDate, UTCDate(2011, 1, 27)); + datesEqual(this.dp.dates.get(-1), UTCDate(2011, 2, 6)); + datesEqual(this.dp.focusDate, UTCDate(2011, 1, 27)); + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'February 2011', 'Title is "February 2011"'); +}); + +test('Regression: by day (left/right arrows); left from Mar 1, 2011 should go to Feb 28, 2011', function(){ + var target; + + this.input.val('01-03-2011').datepicker('update'); + + equal(this.dp.viewMode, 0); + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'March 2011', 'Title is "March 2011"'); + datesEqual(this.dp.viewDate, UTCDate(2011, 2, 1)); + datesEqual(this.dp.dates.get(-1), UTCDate(2011, 2, 1)); + equal(this.dp.focusDate, null); + + // Navigation: -1 day left arrow key + this.input.trigger({ + type: 'keydown', + keyCode: 37 + }); + datesEqual(this.dp.viewDate, UTCDate(2011, 1, 28)); + datesEqual(this.dp.dates.get(-1), UTCDate(2011, 2, 1)); + datesEqual(this.dp.focusDate, UTCDate(2011, 1, 28)); + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'February 2011', 'Title is "February 2011"'); +}); + +test('Regression: by month (shift + left/right arrows); left from Mar 15, 2011 should go to Feb 15, 2011', function(){ + var target; + + this.input.val('15-03-2011').datepicker('update'); + + equal(this.dp.viewMode, 0); + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'March 2011', 'Title is "March 2011"'); + datesEqual(this.dp.viewDate, UTCDate(2011, 2, 15)); + datesEqual(this.dp.dates.get(-1), UTCDate(2011, 2, 15)); + equal(this.dp.focusDate, null); + + // Navigation: -1 month, shift + left arrow key + this.input.trigger({ + type: 'keydown', + keyCode: 37, + shiftKey: true + }); + datesEqual(this.dp.viewDate, UTCDate(2011, 1, 15)); + datesEqual(this.dp.dates.get(-1), UTCDate(2011, 2, 15)); + datesEqual(this.dp.focusDate, UTCDate(2011, 1, 15)); + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'February 2011', 'Title is "February 2011"'); +}); + +test('Regression: by month with view mode = 1 (left/right arrow); left from March 15, 2011 should go to February 15, 2011', function () { + this.picker.remove(); + this.input = $('<input type="text" value="15-03-2011">') + .appendTo('#qunit-fixture') + .datepicker({ + format: "dd-mm-yyyy", + minViewMode: 1, + startView: 1 + }) + .focus(); // Activate for visibility checks + this.dp = this.input.data('datepicker'); + this.picker = this.dp.picker; + + this.input.val('15-03-2011').datepicker('update'); + equal(this.dp.viewMode, 1); + + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'March 2011', 'Title is "March 2011"'); + datesEqual(this.dp.viewDate, UTCDate(2011, 2, 15)); + datesEqual(this.dp.dates.get(-1), UTCDate(2011, 2, 15)); + equal(this.dp.focusDate, null); + + this.input.trigger({ + type: 'keydown', + keyCode: 37 + }); + + datesEqual(this.dp.viewDate, UTCDate(2011, 1, 15)); + datesEqual(this.dp.dates.get(-1), UTCDate(2011, 2, 15)); + datesEqual(this.dp.focusDate, UTCDate(2011, 1, 15)); + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'February 2011', 'Title is "February 2011"'); +}); + +test('Regression: by month with view mode = 1 (up/down arrow); down from March 15, 2011 should go to July 15, 2010', function () { + this.picker.remove(); + this.input = $('<input type="text" value="15-03-2011">') + .appendTo('#qunit-fixture') + .datepicker({ + format: "dd-mm-yyyy", + minViewMode: 1, + startView: 1 + }) + .focus(); // Activate for visibility checks + this.dp = this.input.data('datepicker'); + this.picker = this.dp.picker; + + this.input.val('15-03-2011').datepicker('update'); + equal(this.dp.viewMode, 1); + + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'March 2011', 'Title is "March 2011"'); + datesEqual(this.dp.viewDate, UTCDate(2011, 2, 15)); + datesEqual(this.dp.dates.get(-1), UTCDate(2011, 2, 15)); + equal(this.dp.focusDate, null); + + this.input.trigger({ + type: 'keydown', + keyCode: 40 + }); + + datesEqual(this.dp.viewDate, UTCDate(2011, 6, 15)); + datesEqual(this.dp.dates.get(-1), UTCDate(2011, 2, 15)); + datesEqual(this.dp.focusDate, UTCDate(2011, 6, 15)); + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'July 2011', 'Title is "July 2011"'); +}); + +test('Regression: by year with view mode = 2 (left/right arrow); left from March 15, 2011 should go to March 15, 2010', function () { + this.picker.remove(); + this.input = $('<input type="text" value="15-03-2011">') + .appendTo('#qunit-fixture') + .datepicker({ + format: "dd-mm-yyyy", + minViewMode: 2, + startView: 2 + }) + .focus(); // Activate for visibility checks + this.dp = this.input.data('datepicker'); + this.picker = this.dp.picker; + + this.input.val('15-03-2011').datepicker('update'); + equal(this.dp.viewMode, 2); + + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'March 2011', 'Title is "March 2011"'); + datesEqual(this.dp.viewDate, UTCDate(2011, 2, 15)); + datesEqual(this.dp.dates.get(-1), UTCDate(2011, 2, 15)); + equal(this.dp.focusDate, null); + + this.input.trigger({ + type: 'keydown', + keyCode: 37 + }); + + datesEqual(this.dp.viewDate, UTCDate(2010, 2, 15)); + datesEqual(this.dp.dates.get(-1), UTCDate(2011, 2, 15)); + datesEqual(this.dp.focusDate, UTCDate(2010, 2, 15)); + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'March 2010', 'Title is "March 2010"'); +}); + +test('Regression: by year with view mode = 2 (up/down arrow); dows from March 15, 2011 should go to March 15, 2015', function () { + this.picker.remove(); + this.input = $('<input type="text" value="15-03-2011">') + .appendTo('#qunit-fixture') + .datepicker({ + format: "dd-mm-yyyy", + minViewMode: 2, + startView: 2 + }) + .focus(); // Activate for visibility checks + this.dp = this.input.data('datepicker'); + this.picker = this.dp.picker; + + this.input.val('15-03-2011').datepicker('update'); + equal(this.dp.viewMode, 2); + + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'March 2011', 'Title is "March 2011"'); + datesEqual(this.dp.viewDate, UTCDate(2011, 2, 15)); + datesEqual(this.dp.dates.get(-1), UTCDate(2011, 2, 15)); + equal(this.dp.focusDate, null); + + this.input.trigger({ + type: 'keydown', + keyCode: 40 + }); + + datesEqual(this.dp.viewDate, UTCDate(2015, 2, 15)); + datesEqual(this.dp.dates.get(-1), UTCDate(2011, 2, 15)); + datesEqual(this.dp.focusDate, UTCDate(2015, 2, 15)); + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'March 2015', 'Title is "March 2015"'); +}); diff --git a/public/bower_components/bootstrap-datepicker/tests/suites/keyboard_navigation/2012.js b/public/bower_components/bootstrap-datepicker/tests/suites/keyboard_navigation/2012.js new file mode 100644 index 0000000..53dbb7d --- /dev/null +++ b/public/bower_components/bootstrap-datepicker/tests/suites/keyboard_navigation/2012.js @@ -0,0 +1,483 @@ +module('Keyboard Navigation 2012', { + setup: function(){ + /* + Tests start with picker on March 31, 2012. Fun facts: + + * February 1, 2012 was on a Wednesday + * February 29, 2012 was on a Wednesday + * March 1, 2012 was on a Thursday + * March 31, 2012 was on a Saturday + */ + this.input = $('<input type="text" value="31-03-2012">') + .appendTo('#qunit-fixture') + .datepicker({format: "dd-mm-yyyy"}) + .focus(); // Activate for visibility checks + this.dp = this.input.data('datepicker'); + this.picker = this.dp.picker; + }, + teardown: function(){ + this.picker.remove(); + } +}); + + +test('by day (right/left arrows)', function(){ + var target; + + equal(this.dp.viewMode, 0); + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'March 2012', 'Title is "March 2012"'); + + // Navigation: -1 day, left arrow key + this.input.trigger({ + type: 'keydown', + keyCode: 37 + }); + // view and focus updated on keyboard navigation, not selected + datesEqual(this.dp.viewDate, UTCDate(2012, 2, 30)); + datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 31)); + datesEqual(this.dp.focusDate, UTCDate(2012, 2, 30)); + // Month not changed + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'March 2012', 'Title is "March 2012"'); + + // Navigation: +1 day, right arrow key + for (var i=0; i<2; i++) + this.input.trigger({ + type: 'keydown', + keyCode: 39 + }); + datesEqual(this.dp.viewDate, UTCDate(2012, 3, 1)); + datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 31)); + datesEqual(this.dp.focusDate, UTCDate(2012, 3, 1)); + // Month changed: April 1 (this is not a joke!) + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'April 2012', 'Title is "April 2012"'); +}); + +test('by week (up/down arrows)', function(){ + var target; + + equal(this.dp.viewMode, 0); + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'March 2012', 'Title is "March 2012"'); + + // Navigation: -1 week, up arrow key + this.input.trigger({ + type: 'keydown', + keyCode: 38 + }); + // view and focus updated on keyboard navigation, not selected + datesEqual(this.dp.viewDate, UTCDate(2012, 2, 24)); + datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 31)); + datesEqual(this.dp.focusDate, UTCDate(2012, 2, 24)); + // Month not changed + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'March 2012', 'Title is "March 2012"'); + + // Navigation: +1 week, down arrow key + for (var i=0; i<2; i++) + this.input.trigger({ + type: 'keydown', + keyCode: 40 + }); + datesEqual(this.dp.viewDate, UTCDate(2012, 3, 7)); + datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 31)); + datesEqual(this.dp.focusDate, UTCDate(2012, 3, 7)); + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'April 2012', 'Title is "April 2012"'); +}); + +test('by month, v1 (shift + left/right arrows)', function(){ + var target; + + equal(this.dp.viewMode, 0); + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'March 2012', 'Title is "March 2012"'); + + // Navigation: -1 month, shift + left arrow key + this.input.trigger({ + type: 'keydown', + keyCode: 37, + shiftKey: true + }); + // view and focus updated on keyboard navigation w/ graceful date ends, not selected + datesEqual(this.dp.viewDate, UTCDate(2012, 1, 29)); + datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 31)); + datesEqual(this.dp.focusDate, UTCDate(2012, 1, 29)); + // Month not changed + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'February 2012', 'Title is "February 2012"'); + + // Navigation: +1 month, shift + right arrow key + for (var i=0; i<2; i++) + this.input.trigger({ + type: 'keydown', + keyCode: 39, + shiftKey: true + }); + datesEqual(this.dp.viewDate, UTCDate(2012, 3, 29)); + datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 31)); + datesEqual(this.dp.focusDate, UTCDate(2012, 3, 29)); + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'April 2012', 'Title is "April 2012"'); +}); + +test('by month, v2 (shift + up/down arrows)', function(){ + var target; + + equal(this.dp.viewMode, 0); + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'March 2012', 'Title is "March 2012"'); + + // Navigation: -1 month, shift + up arrow key + this.input.trigger({ + type: 'keydown', + keyCode: 38, + shiftKey: true + }); + // view and focus updated on keyboard navigation w/ graceful date ends, not selected + datesEqual(this.dp.viewDate, UTCDate(2012, 1, 29)); + datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 31)); + datesEqual(this.dp.focusDate, UTCDate(2012, 1, 29)); + // Month not changed + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'February 2012', 'Title is "February 2012"'); + + // Navigation: +1 month, shift + down arrow key + for (var i=0; i<2; i++) + this.input.trigger({ + type: 'keydown', + keyCode: 40, + shiftKey: true + }); + datesEqual(this.dp.viewDate, UTCDate(2012, 3, 29)); + datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 31)); + datesEqual(this.dp.focusDate, UTCDate(2012, 3, 29)); + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'April 2012', 'Title is "April 2012"'); +}); + +test('by year, v1 (ctrl + left/right arrows)', function(){ + var target; + + equal(this.dp.viewMode, 0); + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'March 2012', 'Title is "March 2012"'); + + // Navigation: -1 year, ctrl + left arrow key + this.input.trigger({ + type: 'keydown', + keyCode: 37, + ctrlKey: true + }); + // view and focus updated on keyboard navigation, not selected + datesEqual(this.dp.viewDate, UTCDate(2011, 2, 31)); + datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 31)); + datesEqual(this.dp.focusDate, UTCDate(2011, 2, 31)); + // Month not changed + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'March 2011', 'Title is "March 2011"'); + + // Navigation: +1 year, ctrl + right arrow key + for (var i=0; i<2; i++) + this.input.trigger({ + type: 'keydown', + keyCode: 39, + ctrlKey: true + }); + datesEqual(this.dp.viewDate, UTCDate(2013, 2, 31)); + datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 31)); + datesEqual(this.dp.focusDate, UTCDate(2013, 2, 31)); + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'March 2013', 'Title is "March 2013"'); +}); + +test('by year, v2 (ctrl + up/down arrows)', function(){ + var target; + + equal(this.dp.viewMode, 0); + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'March 2012', 'Title is "March 2012"'); + + // Navigation: -1 year, ctrl + up arrow key + this.input.trigger({ + type: 'keydown', + keyCode: 38, + ctrlKey: true + }); + // view and focus updated on keyboard navigation, not selected + datesEqual(this.dp.viewDate, UTCDate(2011, 2, 31)); + datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 31)); + datesEqual(this.dp.focusDate, UTCDate(2011, 2, 31)); + // Month not changed + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'March 2011', 'Title is "March 2011"'); + + // Navigation: +1 year, ctrl + down arrow key + for (var i=0; i<2; i++) + this.input.trigger({ + type: 'keydown', + keyCode: 40, + ctrlKey: true + }); + datesEqual(this.dp.viewDate, UTCDate(2013, 2, 31)); + datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 31)); + datesEqual(this.dp.focusDate, UTCDate(2013, 2, 31)); + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'March 2013', 'Title is "March 2013"'); +}); + +test('by year, v3 (ctrl + shift + left/right arrows)', function(){ + var target; + + equal(this.dp.viewMode, 0); + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'March 2012', 'Title is "March 2012"'); + + // Navigation: -1 year, ctrl + left arrow key + this.input.trigger({ + type: 'keydown', + keyCode: 37, + ctrlKey: true, + shiftKey: true + }); + // view and focus updated on keyboard navigation, not selected + datesEqual(this.dp.viewDate, UTCDate(2011, 2, 31)); + datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 31)); + datesEqual(this.dp.focusDate, UTCDate(2011, 2, 31)); + // Month not changed + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'March 2011', 'Title is "March 2011"'); + + // Navigation: +1 year, ctrl + right arrow key + for (var i=0; i<2; i++) + this.input.trigger({ + type: 'keydown', + keyCode: 39, + ctrlKey: true, + shiftKey: true + }); + datesEqual(this.dp.viewDate, UTCDate(2013, 2, 31)); + datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 31)); + datesEqual(this.dp.focusDate, UTCDate(2013, 2, 31)); + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'March 2013', 'Title is "March 2013"'); +}); + +test('by year, v4 (ctrl + shift + up/down arrows)', function(){ + var target; + + equal(this.dp.viewMode, 0); + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'March 2012', 'Title is "March 2012"'); + + // Navigation: -1 year, ctrl + up arrow key + this.input.trigger({ + type: 'keydown', + keyCode: 38, + ctrlKey: true, + shiftKey: true + }); + // view and focus updated on keyboard navigation, not selected + datesEqual(this.dp.viewDate, UTCDate(2011, 2, 31)); + datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 31)); + datesEqual(this.dp.focusDate, UTCDate(2011, 2, 31)); + // Month not changed + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'March 2011', 'Title is "March 2011"'); + + // Navigation: +1 year, ctrl + down arrow key + for (var i=0; i<2; i++) + this.input.trigger({ + type: 'keydown', + keyCode: 40, + ctrlKey: true, + shiftKey: true + }); + datesEqual(this.dp.viewDate, UTCDate(2013, 2, 31)); + datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 31)); + datesEqual(this.dp.focusDate, UTCDate(2013, 2, 31)); + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'March 2013', 'Title is "March 2013"'); +}); + +test('by year, from leap day', function(){ + var target; + + equal(this.dp.viewMode, 0); + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + + this.input.val('29-02-2012').datepicker('update'); + datesEqual(this.dp.viewDate, UTCDate(2012, 1, 29)); + datesEqual(this.dp.dates.get(-1), UTCDate(2012, 1, 29)); + equal(this.dp.focusDate, null); + equal(target.text(), 'February 2012', 'Title is "February 2012"'); + + // Navigation: -1 year + this.input.trigger({ + type: 'keydown', + keyCode: 37, + ctrlKey: true + }); + // view and focus updated on keyboard navigation w/ graceful month ends, not selected + datesEqual(this.dp.viewDate, UTCDate(2011, 1, 28)); + datesEqual(this.dp.dates.get(-1), UTCDate(2012, 1, 29)); + datesEqual(this.dp.focusDate, UTCDate(2011, 1, 28)); + // Month not changed + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'February 2011', 'Title is "February 2011"'); + + // Navigation: +1 year, back to leap year + this.input.trigger({ + type: 'keydown', + keyCode: 39, + ctrlKey: true + }); + // view and focus updated on keyboard navigation w/ graceful month ends, not selected + datesEqual(this.dp.viewDate, UTCDate(2012, 1, 28)); + datesEqual(this.dp.dates.get(-1), UTCDate(2012, 1, 29)); + datesEqual(this.dp.focusDate, UTCDate(2012, 1, 28)); + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'February 2012', 'Title is "February 2012"'); + + // Navigation: +1 year + this.input.trigger({ + type: 'keydown', + keyCode: 39, + ctrlKey: true + }); + // view and focus updated on keyboard navigation w/ graceful month ends, not selected + datesEqual(this.dp.viewDate, UTCDate(2013, 1, 28)); + datesEqual(this.dp.dates.get(-1), UTCDate(2012, 1, 29)); + datesEqual(this.dp.focusDate, UTCDate(2013, 1, 28)); + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'February 2013', 'Title is "February 2013"'); +}); + +test('Selection (enter)', function(){ + var target; + + equal(this.dp.viewMode, 0); + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'March 2012', 'Title is "March 2012"'); + + // Navigation: -1 day, left arrow key + this.input.trigger({ + type: 'keydown', + keyCode: 37 + }); + // view and focus updated on keyboard navigation, not selected + datesEqual(this.dp.viewDate, UTCDate(2012, 2, 30)); + datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 31)); + datesEqual(this.dp.focusDate, UTCDate(2012, 2, 30)); + // Month not changed + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'March 2012', 'Title is "March 2012"'); + + // Selection: Enter + this.input.trigger({ + type: 'keydown', + keyCode: 13 + }); + // view and selection updated, focus cleared + datesEqual(this.dp.viewDate, UTCDate(2012, 2, 30)); + datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 30)); + equal(this.dp.focusDate, null); + // Month not changed + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'March 2012', 'Title is "March 2012"'); + + ok(this.picker.is(':visible'), 'Picker is not hidden'); +}); + +test('Selection + hide (enter)', function(){ + var target; + + this.dp._process_options({autoclose: true}); + equal(this.dp.viewMode, 0); + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'March 2012', 'Title is "March 2012"'); + + // Navigation: -1 day, left arrow key + this.input.trigger({ + type: 'keydown', + keyCode: 37 + }); + // view and focus updated on keyboard navigation, not selected + datesEqual(this.dp.viewDate, UTCDate(2012, 2, 30)); + datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 31)); + datesEqual(this.dp.focusDate, UTCDate(2012, 2, 30)); + // Month not changed + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'March 2012', 'Title is "March 2012"'); + + // Selection: Enter + this.input.trigger({ + type: 'keydown', + keyCode: 13 + }); + // view and selection updatedfocus cleared + datesEqual(this.dp.viewDate, UTCDate(2012, 2, 30)); + datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 30)); + equal(this.dp.focusDate, null); + // Month not changed + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'March 2012', 'Title is "March 2012"'); + + ok(this.picker.is(':not(:visible)'), 'Picker is hidden'); +}); + +test('Toggle hide/show (escape); navigation while hidden is suppressed', function(){ + var target; + + equal(this.dp.viewMode, 0); + target = this.picker.find('.datepicker-days thead th.datepicker-switch'); + equal(target.text(), 'March 2012', 'Title is "March 2012"'); + + ok(this.picker.is(':visible'), 'Picker is visible'); + + // Hide + this.input.trigger({ + type: 'keydown', + keyCode: 27 + }); + + ok(this.picker.is(':not(:visible)'), 'Picker is hidden'); + datesEqual(this.dp.viewDate, UTCDate(2012, 2, 31)); + datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 31)); + + // left arrow key, *doesn't* navigate + this.input.trigger({ + type: 'keydown', + keyCode: 37 + }); + + datesEqual(this.dp.viewDate, UTCDate(2012, 2, 31)); + datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 31)); + + // Show - with escape key + this.input.trigger({ + type: 'keydown', + keyCode: 27 + }); + + ok(this.picker.is(':visible'), 'Picker is visible'); + datesEqual(this.dp.viewDate, UTCDate(2012, 2, 31)); + datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 31)); + + // Hide + this.input.trigger({ + type: 'keydown', + keyCode: 27 + }); + + // Show - with down key + this.input.trigger({ + type: 'keydown', + keyCode: 40 + }); + + ok(this.picker.is(':visible'), 'Picker is visible'); +}); + diff --git a/public/bower_components/bootstrap-datepicker/tests/suites/keyboard_navigation/all.js b/public/bower_components/bootstrap-datepicker/tests/suites/keyboard_navigation/all.js new file mode 100644 index 0000000..4fb6d2f --- /dev/null +++ b/public/bower_components/bootstrap-datepicker/tests/suites/keyboard_navigation/all.js @@ -0,0 +1,62 @@ +module('Keyboard Navigation (All)', { + setup: function(){ + this.input = $('<input type="text">') + .appendTo('#qunit-fixture') + .datepicker({format: "dd-mm-yyyy"}) + .focus(); // Activate for visibility checks + this.dp = this.input.data('datepicker'); + this.picker = this.dp.picker; + }, + teardown: function(){ + this.picker.remove(); + } +}); + +test('TAB hides picker', function(){ + var target; + + ok(this.picker.is(':visible'), 'Picker is visible'); + + this.input.trigger({ + type: 'keydown', + keyCode: 9 + }); + + ok(this.picker.is(':not(:visible)'), 'Picker is hidden'); +}); + +test('by day (right/left arrows) with daysOfWeekDisabled', function(){ + var target; + + this.input.val('04-03-2013'); + this.dp.setDaysOfWeekDisabled('0,6'); + this.dp.update(); + + this.input.focus(); + + // Navigation: -1 day left arrow key + this.input.trigger({ + type: 'keydown', + keyCode: 37 + }); + + datesEqual(this.dp.viewDate, UTCDate(2013, 2, 1)); +}); + +test('by day (right/left arrows) with datesDisabled', function(){ + var target; + + this.input.val('04-03-2013'); + this.dp.setDatesDisabled(['05-03-2013']); + this.dp.update(); + + this.input.focus(); + + // Navigation: +1 day right arrow key + this.input.trigger({ + type: 'keydown', + keyCode: 39 + }); + + datesEqual(this.dp.viewDate, UTCDate(2013, 2, 6)); +}); |