2015-07-15 13:40:38 +00:00
|
|
|
define( [
|
|
|
|
"jquery",
|
|
|
|
"./helper",
|
2015-08-20 13:48:11 +00:00
|
|
|
"ui/widgets/calendar"
|
|
|
|
], function( $, testHelper ) {
|
2014-06-03 21:18:51 +00:00
|
|
|
|
2016-05-22 19:58:20 +00:00
|
|
|
module( "calendar: core", {
|
|
|
|
setup: function() {
|
|
|
|
this.element = $( "#calendar" ).calendar();
|
|
|
|
this.widget = this.element.calendar( "widget" );
|
|
|
|
},
|
|
|
|
teardown: function() {
|
|
|
|
this.element.calendar( "destroy" );
|
|
|
|
}
|
|
|
|
} );
|
2014-06-03 21:18:51 +00:00
|
|
|
|
|
|
|
test( "base structure", function() {
|
2015-12-03 10:57:35 +00:00
|
|
|
expect( 28 );
|
2014-06-03 21:18:51 +00:00
|
|
|
|
2016-05-22 19:58:20 +00:00
|
|
|
var that = this,
|
|
|
|
buttons, header, title, table, thead, week, child, buttonpane;
|
2014-06-03 21:18:51 +00:00
|
|
|
|
|
|
|
function step1() {
|
2016-05-22 19:58:20 +00:00
|
|
|
ok( !that.widget.is( ".ui-calendar-rtl" ), "Structure - not right-to-left" );
|
|
|
|
ok( !that.widget.is( ".ui-calendar-multi" ), "Structure - not multi-month" );
|
|
|
|
equal( that.widget.children().length, 3, "Structure - child count (header, calendar)" );
|
2014-06-03 21:18:51 +00:00
|
|
|
|
2016-05-22 19:58:20 +00:00
|
|
|
buttons = that.widget.children( ":first" );
|
2015-12-03 10:57:35 +00:00
|
|
|
ok( buttons.is( "div.ui-calendar-header-buttons" ), "Structure - header button division" );
|
|
|
|
equal( buttons.children().length, 2, "Structure - header buttons child count" );
|
|
|
|
ok( buttons.children( ":first" ).is( ".ui-calendar-prev" ) && buttons.children( ":first" ).html() !== "", "Structure - prev link" );
|
|
|
|
ok( buttons.children( ":last" ).is( ".ui-calendar-next" ) && buttons.children( ":last" ).html() !== "", "Structure - next link" );
|
|
|
|
|
2016-05-22 19:58:20 +00:00
|
|
|
header = that.widget.children( ":eq(1)" );
|
2014-06-03 21:18:51 +00:00
|
|
|
ok( header.is( "div.ui-calendar-header" ), "Structure - header division" );
|
2015-12-03 10:57:35 +00:00
|
|
|
equal( header.children().length, 1, "Structure - header child count" );
|
2014-06-03 21:18:51 +00:00
|
|
|
|
|
|
|
title = header.children( ":last" ).children( ":first" );
|
|
|
|
ok( title.is( "div.ui-calendar-title" ) && title.html() !== "", "Structure - title division" );
|
|
|
|
equal( title.children().length, 2, "Structure - title child count" );
|
|
|
|
ok( title.children( ":first" ).is( "span.ui-calendar-month" ) && title.children( ":first" ).text() !== "", "Structure - month text" );
|
|
|
|
ok( title.children( ":last" ).is( "span.ui-calendar-year" ) && title.children( ":last" ).text() !== "", "Structure - year text" );
|
|
|
|
|
2016-05-22 19:58:20 +00:00
|
|
|
table = that.widget.children( ":eq(2)" );
|
2014-06-03 21:18:51 +00:00
|
|
|
ok( table.is( "table.ui-calendar-calendar" ), "Structure - month table" );
|
|
|
|
ok( table.children( ":first" ).is( "thead" ), "Structure - month table thead" );
|
|
|
|
|
|
|
|
thead = table.children( ":first" ).children( ":first" );
|
|
|
|
ok( thead.is( "tr" ), "Structure - month table title row" );
|
|
|
|
equal( thead.find( "th" ).length, 7, "Structure - month table title cells" );
|
|
|
|
ok( table.children( ":eq(1)" ).is( "tbody" ), "Structure - month table body" );
|
|
|
|
ok( table.children( ":eq(1)" ).children( "tr" ).length >= 4, "Structure - month table week count" );
|
|
|
|
|
|
|
|
week = table.children( ":eq(1)" ).children( ":first" );
|
|
|
|
ok( week.is( "tr" ), "Structure - month table week row" );
|
|
|
|
equal( week.children().length, 7, "Structure - week child count" );
|
|
|
|
|
|
|
|
step2();
|
|
|
|
}
|
|
|
|
|
|
|
|
function step2() {
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( "option", "buttons", {
|
2014-06-19 22:13:20 +00:00
|
|
|
"test": function() {},
|
|
|
|
"test button": function() {}
|
2015-10-08 13:06:55 +00:00
|
|
|
} );
|
2014-06-19 22:13:20 +00:00
|
|
|
|
2016-05-22 19:58:20 +00:00
|
|
|
equal( that.widget.children().length, 4, "Structure buttons - child count (header buttons, header, calendar, buttonpane)" );
|
2014-06-19 22:13:20 +00:00
|
|
|
|
2016-05-22 19:58:20 +00:00
|
|
|
buttonpane = that.widget.children( ".ui-calendar-buttonpane" );
|
2014-06-19 22:13:20 +00:00
|
|
|
equal( buttonpane.children( "div.ui-calendar-buttonset" ).length, 1, "Structure buttons - buttonset" );
|
|
|
|
equal( buttonpane.find( "button.ui-button:first" ).text(), "test", "Structure buttons - buttonset" );
|
|
|
|
equal( buttonpane.find( "button.ui-button:eq(1)" ).text(), "test button", "Structure buttons - buttonset" );
|
|
|
|
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( "destroy" );
|
2014-06-19 22:13:20 +00:00
|
|
|
step3();
|
|
|
|
}
|
|
|
|
|
|
|
|
function step3() {
|
2015-10-08 13:06:55 +00:00
|
|
|
|
2014-06-19 22:13:20 +00:00
|
|
|
// Multi-month 2
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( { numberOfMonths: 2 } );
|
2014-06-03 21:18:51 +00:00
|
|
|
|
2016-05-22 19:58:20 +00:00
|
|
|
ok( that.widget.is( ".ui-calendar-multi" ), "Structure multi [2] - multi-month" );
|
|
|
|
equal( that.widget.children().length, 4, "Structure multi [2] - child count" );
|
2014-06-03 21:18:51 +00:00
|
|
|
|
2016-05-22 19:58:20 +00:00
|
|
|
child = that.widget.children( ":eq(3)" );
|
2014-06-03 21:18:51 +00:00
|
|
|
ok( child.is( "div.ui-calendar-row-break" ), "Structure multi [2] - row break" );
|
|
|
|
}
|
|
|
|
|
|
|
|
step1();
|
2015-10-08 13:06:55 +00:00
|
|
|
} );
|
2014-06-03 21:18:51 +00:00
|
|
|
|
|
|
|
test( "Localization", function() {
|
2014-06-19 16:59:28 +00:00
|
|
|
expect( 10 );
|
2014-06-03 21:18:51 +00:00
|
|
|
|
2016-05-22 19:58:20 +00:00
|
|
|
var that = this,
|
2014-06-03 21:18:51 +00:00
|
|
|
date = new Date( 2014, 0, 1 ),
|
2015-04-30 11:06:56 +00:00
|
|
|
optionsDe = {
|
|
|
|
locale: "de",
|
|
|
|
labels: {
|
|
|
|
"nextText": "Vor",
|
|
|
|
"prevText": "Zurück"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
initCalendar = function( options ) {
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element
|
2015-04-30 11:06:56 +00:00
|
|
|
.calendar( options )
|
2014-06-03 21:18:51 +00:00
|
|
|
.calendar( "valueAsDate", date );
|
|
|
|
},
|
|
|
|
testLocalization = function( message ) {
|
|
|
|
equal(
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.find( ".ui-calendar-month" ).text(),
|
2014-06-03 21:18:51 +00:00
|
|
|
"Januar", message + "titlebar year"
|
|
|
|
);
|
|
|
|
equal(
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.find( "thead th:first" ).text(),
|
2014-06-03 21:18:51 +00:00
|
|
|
"Mo.", message + "teader first day"
|
|
|
|
);
|
|
|
|
equal(
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.find( "thead th:last" ).text(),
|
2014-06-03 21:18:51 +00:00
|
|
|
"So.", message + "header last day"
|
|
|
|
);
|
|
|
|
equal(
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.find( ".ui-calendar-prev" ).text(),
|
2015-04-30 11:06:56 +00:00
|
|
|
"Zurück", message + "header prev"
|
2014-06-03 21:18:51 +00:00
|
|
|
);
|
|
|
|
equal(
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.find( ".ui-calendar-next" ).text(),
|
2015-04-30 11:06:56 +00:00
|
|
|
"Vor", message + "header next"
|
2014-06-03 21:18:51 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2015-04-30 11:06:56 +00:00
|
|
|
initCalendar( optionsDe );
|
2014-06-03 21:18:51 +00:00
|
|
|
testLocalization( "Init: " );
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( "destroy" );
|
2014-06-03 21:18:51 +00:00
|
|
|
|
2015-04-30 11:06:56 +00:00
|
|
|
initCalendar( {} );
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element
|
2015-04-30 11:06:56 +00:00
|
|
|
.calendar( "option", optionsDe )
|
|
|
|
.calendar( "refresh" );
|
2014-06-19 16:59:28 +00:00
|
|
|
testLocalization( "After init: " );
|
2015-10-08 13:06:55 +00:00
|
|
|
} );
|
2014-06-03 21:18:51 +00:00
|
|
|
|
2016-05-22 19:12:10 +00:00
|
|
|
asyncTest( "keyboard handling", function( assert ) {
|
2014-06-03 21:18:51 +00:00
|
|
|
expect( 10 );
|
|
|
|
|
2016-05-22 19:58:20 +00:00
|
|
|
var that = this;
|
2014-06-03 21:18:51 +00:00
|
|
|
|
|
|
|
function step1() {
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( { value: new Date( 2014, 1 - 1, 1 ) } );
|
2014-06-03 21:18:51 +00:00
|
|
|
|
2015-07-15 13:40:38 +00:00
|
|
|
testHelper
|
2016-05-22 19:58:20 +00:00
|
|
|
.focusGrid( that.element )
|
2014-06-03 21:18:51 +00:00
|
|
|
.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
|
2015-10-08 13:06:55 +00:00
|
|
|
setTimeout( function() {
|
2015-01-19 16:56:11 +00:00
|
|
|
$( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
2016-05-22 19:12:10 +00:00
|
|
|
assert.dateEqual(
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( "valueAsDate" ),
|
2014-06-03 21:18:51 +00:00
|
|
|
new Date( 2013, 12 - 1, 31 ),
|
|
|
|
"Keystroke left to switch to previous day"
|
|
|
|
);
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( "destroy" );
|
2014-06-03 21:18:51 +00:00
|
|
|
step2();
|
|
|
|
}, 50 );
|
|
|
|
}
|
|
|
|
|
|
|
|
function step2() {
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( { value: new Date( 2014, 1 - 1, 1 ) } );
|
2014-06-03 21:18:51 +00:00
|
|
|
|
2016-05-22 19:58:20 +00:00
|
|
|
testHelper.focusGrid( that.element )
|
2014-06-03 21:18:51 +00:00
|
|
|
.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } )
|
|
|
|
.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
|
|
|
|
2016-05-22 19:12:10 +00:00
|
|
|
assert.dateEqual(
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( "valueAsDate" ),
|
2014-06-03 21:18:51 +00:00
|
|
|
new Date( 2014, 1 - 1, 2 ),
|
|
|
|
"Keystroke right to switch to next day"
|
|
|
|
);
|
|
|
|
step3();
|
|
|
|
}
|
|
|
|
|
|
|
|
function step3() {
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( { value: new Date( 2014, 1 - 1, 1 ) } );
|
2014-06-03 21:18:51 +00:00
|
|
|
|
2016-05-22 19:58:20 +00:00
|
|
|
testHelper.focusGrid( that.element ).simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
|
2015-10-08 13:06:55 +00:00
|
|
|
setTimeout( function() {
|
2015-01-19 16:56:11 +00:00
|
|
|
$( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
2016-05-22 19:12:10 +00:00
|
|
|
assert.dateEqual(
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( "valueAsDate" ),
|
2014-06-03 21:18:51 +00:00
|
|
|
new Date( 2013, 12 - 1, 25 ),
|
|
|
|
"Keystroke up to move to the previous week"
|
|
|
|
);
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( "destroy" );
|
2014-06-03 21:18:51 +00:00
|
|
|
step4();
|
|
|
|
}, 50 );
|
|
|
|
}
|
|
|
|
|
|
|
|
function step4() {
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( { value: new Date( 2014, 1 - 1, 1 ) } );
|
2014-06-03 21:18:51 +00:00
|
|
|
|
2016-05-22 19:58:20 +00:00
|
|
|
testHelper.focusGrid( that.element ).simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
2015-10-08 13:06:55 +00:00
|
|
|
setTimeout( function() {
|
2015-01-19 16:56:11 +00:00
|
|
|
$( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
2016-05-22 19:12:10 +00:00
|
|
|
assert.dateEqual(
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( "valueAsDate" ),
|
2014-06-03 21:18:51 +00:00
|
|
|
new Date( 2014, 1 - 1, 8 ),
|
|
|
|
"Keystroke down to move to the next week"
|
|
|
|
);
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( "destroy" );
|
2014-06-03 21:18:51 +00:00
|
|
|
step5();
|
|
|
|
}, 50 );
|
|
|
|
}
|
|
|
|
|
|
|
|
function step5() {
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( { value: new Date( 2014, 1 - 1, 1 ) } );
|
2014-06-03 21:18:51 +00:00
|
|
|
|
2016-05-22 19:58:20 +00:00
|
|
|
testHelper.focusGrid( that.element ).simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
|
2015-10-08 13:06:55 +00:00
|
|
|
setTimeout( function() {
|
2015-01-19 16:56:11 +00:00
|
|
|
$( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
2016-05-22 19:12:10 +00:00
|
|
|
assert.dateEqual(
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( "valueAsDate" ),
|
2014-06-03 21:18:51 +00:00
|
|
|
new Date( 2013, 12 - 1, 1 ),
|
|
|
|
"Keystroke Page Up moves date to previous month"
|
|
|
|
);
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( "destroy" );
|
2014-06-03 21:18:51 +00:00
|
|
|
step6();
|
|
|
|
}, 50 );
|
|
|
|
}
|
|
|
|
|
|
|
|
function step6() {
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( { value: new Date( 2014, 1 - 1, 1 ) } );
|
2014-06-03 21:18:51 +00:00
|
|
|
|
2016-05-22 19:58:20 +00:00
|
|
|
testHelper.focusGrid( that.element )
|
2014-06-03 21:18:51 +00:00
|
|
|
.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP, altKey: true } );
|
2015-10-08 13:06:55 +00:00
|
|
|
setTimeout( function() {
|
2015-01-19 16:56:11 +00:00
|
|
|
$( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
2016-05-22 19:12:10 +00:00
|
|
|
assert.dateEqual(
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( "valueAsDate" ),
|
2014-06-03 21:18:51 +00:00
|
|
|
new Date( 2013, 1 - 1, 1 ),
|
|
|
|
"Keystroke Page Up + ALT moves date to previous year"
|
|
|
|
);
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( "destroy" );
|
2014-06-03 21:18:51 +00:00
|
|
|
step7();
|
|
|
|
}, 50 );
|
|
|
|
}
|
|
|
|
|
|
|
|
function step7() {
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( { value: new Date( 2014, 1 - 1, 1 ) } );
|
2014-06-03 21:18:51 +00:00
|
|
|
|
2016-05-22 19:58:20 +00:00
|
|
|
testHelper.focusGrid( that.element ).simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
|
2015-10-08 13:06:55 +00:00
|
|
|
setTimeout( function() {
|
2015-01-19 16:56:11 +00:00
|
|
|
$( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
2016-05-22 19:12:10 +00:00
|
|
|
assert.dateEqual(
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( "valueAsDate" ),
|
2014-06-03 21:18:51 +00:00
|
|
|
new Date( 2014, 2 - 1, 1 ),
|
|
|
|
"Keystroke Page Down moves date to next month"
|
|
|
|
);
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( "destroy" );
|
2014-06-03 21:18:51 +00:00
|
|
|
step8();
|
|
|
|
}, 50 );
|
|
|
|
}
|
|
|
|
|
|
|
|
function step8() {
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( { value: new Date( 2014, 1 - 1, 1 ) } );
|
2014-06-03 21:18:51 +00:00
|
|
|
|
2016-05-22 19:58:20 +00:00
|
|
|
testHelper.focusGrid( that.element )
|
2014-06-03 21:18:51 +00:00
|
|
|
.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN, altKey: true } );
|
2015-10-08 13:06:55 +00:00
|
|
|
setTimeout( function() {
|
2015-01-19 16:56:11 +00:00
|
|
|
$( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
2016-05-22 19:12:10 +00:00
|
|
|
assert.dateEqual(
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( "valueAsDate" ),
|
2014-06-03 21:18:51 +00:00
|
|
|
new Date( 2015, 1 - 1, 1 ),
|
|
|
|
"Keystroke Page Down + ALT moves date to next year"
|
|
|
|
);
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( "destroy" );
|
2014-06-03 21:18:51 +00:00
|
|
|
step9();
|
|
|
|
}, 50 );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check for moving to short months
|
|
|
|
function step9() {
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( { value: new Date( 2014, 3 - 1, 31 ) } );
|
2014-06-03 21:18:51 +00:00
|
|
|
|
2016-05-22 19:58:20 +00:00
|
|
|
testHelper.focusGrid( that.element ).simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
|
2015-10-08 13:06:55 +00:00
|
|
|
setTimeout( function() {
|
2015-01-19 16:56:11 +00:00
|
|
|
$( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
2016-05-22 19:12:10 +00:00
|
|
|
assert.dateEqual(
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( "valueAsDate" ),
|
2014-06-03 21:18:51 +00:00
|
|
|
new Date( 2014, 2 - 1, 28 ),
|
|
|
|
"Keystroke Page Up and short months"
|
|
|
|
);
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( "destroy" );
|
2014-06-03 21:18:51 +00:00
|
|
|
step10();
|
|
|
|
}, 50 );
|
|
|
|
}
|
|
|
|
|
|
|
|
function step10() {
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( { value: new Date( 2016, 1 - 1, 30 ) } );
|
2014-06-03 21:18:51 +00:00
|
|
|
|
2016-05-22 19:58:20 +00:00
|
|
|
testHelper.focusGrid( that.element ).simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
|
2015-10-08 13:06:55 +00:00
|
|
|
setTimeout( function() {
|
2015-01-19 16:56:11 +00:00
|
|
|
$( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
2016-05-22 19:12:10 +00:00
|
|
|
assert.dateEqual(
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( "valueAsDate" ),
|
2014-06-03 21:18:51 +00:00
|
|
|
new Date( 2016, 2 - 1, 29 ),
|
|
|
|
"Keystroke Page Down and leap years"
|
|
|
|
);
|
|
|
|
start();
|
|
|
|
}, 50 );
|
|
|
|
}
|
|
|
|
|
|
|
|
step1();
|
2015-10-08 13:06:55 +00:00
|
|
|
} );
|
2014-06-03 21:18:51 +00:00
|
|
|
|
2016-05-22 19:12:10 +00:00
|
|
|
asyncTest( "mouse", function( assert ) {
|
2014-06-03 21:18:51 +00:00
|
|
|
expect( 6 );
|
|
|
|
|
2016-05-22 19:58:20 +00:00
|
|
|
var that = this,
|
2014-06-03 21:18:51 +00:00
|
|
|
date = new Date();
|
|
|
|
|
|
|
|
function step1() {
|
2016-05-22 19:58:20 +00:00
|
|
|
$( "tbody button:contains(10)", that.element ).simulate( "mousedown" );
|
2014-06-03 21:18:51 +00:00
|
|
|
date.setDate( 10 );
|
2016-05-22 19:12:10 +00:00
|
|
|
assert.dateEqual(
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( "valueAsDate" ),
|
2014-06-03 21:18:51 +00:00
|
|
|
date,
|
|
|
|
"Mouse click"
|
|
|
|
);
|
|
|
|
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( "option", "value", new Date( 2008, 2 - 1, 4 ) );
|
|
|
|
$( ".ui-calendar-calendar tbody button:contains(12)", that.element ).simulate( "mousedown" );
|
2016-05-22 19:12:10 +00:00
|
|
|
assert.dateEqual(
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( "valueAsDate" ),
|
2014-06-03 21:18:51 +00:00
|
|
|
new Date( 2008, 2 - 1, 12 ),
|
|
|
|
"Mouse click - preset"
|
|
|
|
);
|
|
|
|
|
|
|
|
// Previous/next
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( "option", "value", new Date( 2008, 2 - 1, 4 ) );
|
|
|
|
$( ".ui-calendar-prev", that.element ).simulate( "click" );
|
|
|
|
$( ".ui-calendar-calendar tbody button:contains(16)", that.element ).simulate( "mousedown" );
|
2016-05-22 19:12:10 +00:00
|
|
|
assert.dateEqual(
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( "valueAsDate" ),
|
2014-06-03 21:18:51 +00:00
|
|
|
new Date( 2008, 1 - 1, 16 ),
|
|
|
|
"Mouse click - previous"
|
|
|
|
);
|
|
|
|
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( "option", "value", new Date( 2008, 2 - 1, 4 ) );
|
|
|
|
$( ".ui-calendar-next", that.element ).simulate( "click" );
|
|
|
|
$( ".ui-calendar-calendar tbody button:contains(18)", that.element ).simulate( "mousedown" );
|
2016-05-22 19:12:10 +00:00
|
|
|
assert.dateEqual(
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( "valueAsDate" ),
|
2014-06-03 21:18:51 +00:00
|
|
|
new Date( 2008, 3 - 1, 18 ),
|
|
|
|
"Mouse click - next"
|
|
|
|
);
|
|
|
|
|
|
|
|
step2();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Previous/next with minimum/maximum
|
|
|
|
function step2() {
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( "destroy" );
|
|
|
|
that.element.calendar( {
|
2015-10-08 13:06:55 +00:00
|
|
|
value: new Date( 2008, 3 - 1, 4 ),
|
2014-06-03 21:18:51 +00:00
|
|
|
min: new Date( 2008, 2 - 1, 2 ),
|
|
|
|
max: new Date( 2008, 2 - 1, 26 )
|
2015-10-08 13:06:55 +00:00
|
|
|
} );
|
2014-06-03 21:18:51 +00:00
|
|
|
|
2016-05-22 19:58:20 +00:00
|
|
|
$( ".ui-calendar-prev", that.element ).simulate( "click" );
|
|
|
|
$( "tbody button:contains(16)", that.element ).simulate( "mousedown" );
|
2016-05-22 19:12:10 +00:00
|
|
|
assert.dateEqual(
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( "valueAsDate" ),
|
2014-06-03 21:18:51 +00:00
|
|
|
new Date( 2008, 2 - 1, 16 ),
|
|
|
|
"Mouse click - previous + min/max"
|
|
|
|
);
|
|
|
|
step3();
|
|
|
|
}
|
|
|
|
|
|
|
|
function step3() {
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( "destroy" );
|
|
|
|
that.element.calendar( {
|
2015-10-08 13:06:55 +00:00
|
|
|
value: new Date( 2008, 1 - 1, 4 ),
|
2014-06-03 21:18:51 +00:00
|
|
|
min: new Date( 2008, 2 - 1, 2 ),
|
|
|
|
max: new Date( 2008, 2 - 1, 26 )
|
2015-10-08 13:06:55 +00:00
|
|
|
} );
|
2014-06-03 21:18:51 +00:00
|
|
|
|
2016-05-22 19:58:20 +00:00
|
|
|
$( ".ui-calendar-next", that.element ).simulate( "click" );
|
|
|
|
$( "tbody button:contains(18)", that.element ).simulate( "mousedown" );
|
2016-05-22 19:12:10 +00:00
|
|
|
assert.dateEqual(
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( "valueAsDate" ),
|
2014-06-03 21:18:51 +00:00
|
|
|
new Date( 2008, 2 - 1, 18 ),
|
|
|
|
"Mouse click - next + min/max"
|
|
|
|
);
|
|
|
|
start();
|
|
|
|
}
|
|
|
|
|
|
|
|
step1();
|
2015-10-08 13:06:55 +00:00
|
|
|
} );
|
2014-06-03 21:18:51 +00:00
|
|
|
|
2015-07-15 13:40:38 +00:00
|
|
|
} );
|