aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/datepicker/events.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/datepicker/events.js')
-rw-r--r--tests/unit/datepicker/events.js93
1 files changed, 47 insertions, 46 deletions
diff --git a/tests/unit/datepicker/events.js b/tests/unit/datepicker/events.js
index 4a5654d09..941822ef8 100644
--- a/tests/unit/datepicker/events.js
+++ b/tests/unit/datepicker/events.js
@@ -1,10 +1,11 @@
define( [
+ "qunit",
"jquery",
"./helper",
"ui/widgets/datepicker"
-], function( $, testHelper ) {
+], function( QUnit, $, testHelper ) {
-module( "datepicker: events" );
+QUnit.module( "datepicker: events" );
var selectedThis = null,
selectedDate = null,
@@ -22,36 +23,36 @@ function callback2( year, month, inst ) {
selectedInst = inst;
}
-test( "events", function() {
- expect( 26 );
+QUnit.test( "events", function( assert ) {
+ assert.expect( 26 );
var dateStr, newMonthYear, inp2,
inp = testHelper.init( "#inp", { onSelect: callback } ),
date = new Date();
- // onSelect
+ // OnSelect
inp.val( "" ).datepicker( "show" ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- equal( selectedThis, inp[ 0 ], "Callback selected this" );
- equal( selectedInst, $.data( inp[ 0 ], testHelper.PROP_NAME ), "Callback selected inst" );
- equal( selectedDate, $.datepicker.formatDate( "mm/dd/yy", date ),
+ assert.equal( selectedThis, inp[ 0 ], "Callback selected this" );
+ assert.equal( selectedInst, $.data( inp[ 0 ], testHelper.PROP_NAME ), "Callback selected inst" );
+ assert.equal( selectedDate, $.datepicker.formatDate( "mm/dd/yy", date ),
"Callback selected date" );
inp.val( "" ).datepicker( "show" ).
simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.DOWN } ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
date.setDate( date.getDate() + 7 );
- equal( selectedDate, $.datepicker.formatDate( "mm/dd/yy", date ),
+ assert.equal( selectedDate, $.datepicker.formatDate( "mm/dd/yy", date ),
"Callback selected date - ctrl+down" );
inp.val( "" ).datepicker( "show" ).
simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
- equal( selectedDate, $.datepicker.formatDate( "mm/dd/yy", date ),
+ assert.equal( selectedDate, $.datepicker.formatDate( "mm/dd/yy", date ),
"Callback selected date - esc" );
- dateStr = "02/04/2008";
- inp.val( dateStr ).datepicker( "show" ).
- simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- equal( dateStr, selectedDate,
- "onSelect is called after enter keydown" );
+ dateStr = "02/04/2008";
+ inp.val( dateStr ).datepicker( "show" ).
+ simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
+ assert.equal( dateStr, selectedDate,
+ "onSelect is called after enter keydown" );
- // onChangeMonthYear
+ // OnChangeMonthYear
inp.datepicker( "option", { onChangeMonthYear: callback2, onSelect: null } ).
val( "" ).datepicker( "show" );
newMonthYear = function( date ) {
@@ -61,84 +62,84 @@ test( "events", function() {
date.setDate( 1 );
inp.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
date.setMonth( date.getMonth() - 1 );
- equal( selectedThis, inp[ 0 ], "Callback change month/year this" );
- equal( selectedInst, $.data( inp[ 0 ], testHelper.PROP_NAME ), "Callback change month/year inst" );
- equal( selectedDate, newMonthYear( date ),
+ assert.equal( selectedThis, inp[ 0 ], "Callback change month/year this" );
+ assert.equal( selectedInst, $.data( inp[ 0 ], testHelper.PROP_NAME ), "Callback change month/year inst" );
+ assert.equal( selectedDate, newMonthYear( date ),
"Callback change month/year date - pgup" );
inp.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
date.setMonth( date.getMonth() + 1 );
- equal( selectedDate, newMonthYear( date ),
+ assert.equal( selectedDate, newMonthYear( date ),
"Callback change month/year date - pgdn" );
inp.simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP } );
date.setFullYear( date.getFullYear() - 1 );
- equal( selectedDate, newMonthYear( date ),
+ assert.equal( selectedDate, newMonthYear( date ),
"Callback change month/year date - ctrl+pgup" );
inp.simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.HOME } );
date.setFullYear( date.getFullYear() + 1 );
- equal( selectedDate, newMonthYear( date ),
+ assert.equal( selectedDate, newMonthYear( date ),
"Callback change month/year date - ctrl+home" );
inp.simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN } );
date.setFullYear( date.getFullYear() + 1 );
- equal( selectedDate, newMonthYear( date ),
+ assert.equal( selectedDate, newMonthYear( date ),
"Callback change month/year date - ctrl+pgdn" );
inp.datepicker( "setDate", new Date( 2007, 1 - 1, 26 ) );
- equal( selectedDate, "2007/1", "Callback change month/year date - setDate" );
+ assert.equal( selectedDate, "2007/1", "Callback change month/year date - setDate" );
selectedDate = null;
inp.datepicker( "setDate", new Date( 2007, 1 - 1, 12 ) );
- ok( selectedDate == null, "Callback change month/year date - setDate no change" );
+ assert.ok( selectedDate == null, "Callback change month/year date - setDate no change" );
- // onChangeMonthYear step by 2
+ // OnChangeMonthYear step by 2
inp.datepicker( "option", { stepMonths: 2 } ).
datepicker( "hide" ).val( "" ).datepicker( "show" ).
simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
date.setMonth( date.getMonth() - 14 );
- equal( selectedDate, newMonthYear( date ),
+ assert.equal( selectedDate, newMonthYear( date ),
"Callback change month/year by 2 date - pgup" );
inp.simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP } );
date.setMonth( date.getMonth() - 12 );
- equal( selectedDate, newMonthYear( date ),
+ assert.equal( selectedDate, newMonthYear( date ),
"Callback change month/year by 2 date - ctrl+pgup" );
inp.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
date.setMonth( date.getMonth() + 2 );
- equal( selectedDate, newMonthYear( date ),
+ assert.equal( selectedDate, newMonthYear( date ),
"Callback change month/year by 2 date - pgdn" );
inp.simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN } );
date.setMonth( date.getMonth() + 12 );
- equal( selectedDate, newMonthYear( date ),
+ assert.equal( selectedDate, newMonthYear( date ),
"Callback change month/year by 2 date - ctrl+pgdn" );
- // onClose
+ // OnClose
inp.datepicker( "option", { onClose: callback, onChangeMonthYear: null, stepMonths: 1 } ).
val( "" ).datepicker( "show" ).
simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
- equal( selectedThis, inp[ 0 ], "Callback close this" );
- equal( selectedInst, $.data( inp[ 0 ], testHelper.PROP_NAME ), "Callback close inst" );
- equal( selectedDate, "", "Callback close date - esc" );
+ assert.equal( selectedThis, inp[ 0 ], "Callback close this" );
+ assert.equal( selectedInst, $.data( inp[ 0 ], testHelper.PROP_NAME ), "Callback close inst" );
+ assert.equal( selectedDate, "", "Callback close date - esc" );
inp.val( "" ).datepicker( "show" ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- equal( selectedDate, $.datepicker.formatDate( "mm/dd/yy", new Date() ),
+ assert.equal( selectedDate, $.datepicker.formatDate( "mm/dd/yy", new Date() ),
"Callback close date - enter" );
inp.val( "02/04/2008" ).datepicker( "show" ).
simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
- equal( selectedDate, "02/04/2008", "Callback close date - preset" );
+ assert.equal( selectedDate, "02/04/2008", "Callback close date - preset" );
inp.val( "02/04/2008" ).datepicker( "show" ).
simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.END } );
- equal( selectedDate, "", "Callback close date - ctrl+end" );
+ assert.equal( selectedDate, "", "Callback close date - ctrl+end" );
inp2 = testHelper.init( "#inp2" );
inp2.datepicker().datepicker( "option", { onClose: callback } ).datepicker( "show" );
inp.datepicker( "show" );
- equal( selectedThis, inp2[ 0 ], "Callback close this" );
+ assert.equal( selectedThis, inp2[ 0 ], "Callback close this" );
} );
-test( "beforeShowDay-getDate", function() {
- expect( 3 );
+QUnit.test( "beforeShowDay-getDate", function( assert ) {
+ assert.expect( 3 );
var inp = testHelper.init( "#inp", { beforeShowDay: function() { inp.datepicker( "getDate" ); return [ true, "" ]; } } ),
dp = $( "#ui-datepicker-div" );
inp.val( "01/01/2010" ).datepicker( "show" );
- // contains non-breaking space
- equal( $( "div.ui-datepicker-title" ).text(),
+ // Contains non-breaking space
+ assert.equal( $( "div.ui-datepicker-title" ).text(),
// Support: IE <9, jQuery <1.8
// In IE7/8 with jQuery <1.8, encoded spaces behave in strange ways
@@ -146,15 +147,15 @@ test( "beforeShowDay-getDate", function() {
$( "a.ui-datepicker-next", dp ).trigger( "click" );
$( "a.ui-datepicker-next", dp ).trigger( "click" );
- // contains non-breaking space
- equal( $( "div.ui-datepicker-title" ).text(),
+ // Contains non-breaking space
+ assert.equal( $( "div.ui-datepicker-title" ).text(),
$( "<span>March&#xa0;2010</span>" ).text(), "After next clicks" );
inp.datepicker( "hide" ).datepicker( "show" );
$( "a.ui-datepicker-prev", dp ).trigger( "click" );
$( "a.ui-datepicker-prev", dp ).trigger( "click" );
- // contains non-breaking space
- equal( $( "div.ui-datepicker-title" ).text(),
+ // Contains non-breaking space
+ assert.equal( $( "div.ui-datepicker-title" ).text(),
$( "<span>November&#xa0;2009</span>" ).text(), "After prev clicks" );
inp.datepicker( "hide" );
} );