aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAmanpreet Singh <apsdehal@gmail.com>2016-04-03 20:41:33 +0530
committerAmanpreet Singh <apsdehal@gmail.com>2016-04-14 00:06:12 +0530
commite8e886770757bc21ddb1151fbbd956c031a8e2c4 (patch)
treeecaeb26c7d173238f3bebeae519b3d147d4e6902 /tests
parent20b6e976fb594e7e3606f842ded99878a907d719 (diff)
downloadjquery-ui-e8e886770757bc21ddb1151fbbd956c031a8e2c4.tar.gz
jquery-ui-e8e886770757bc21ddb1151fbbd956c031a8e2c4.zip
Datepicker: Shift to use no globals
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/datepicker/core.js287
-rw-r--r--tests/unit/datepicker/events.js93
-rw-r--r--tests/unit/datepicker/helper.js9
-rw-r--r--tests/unit/datepicker/methods.js145
-rw-r--r--tests/unit/datepicker/options.js698
5 files changed, 620 insertions, 612 deletions
diff --git a/tests/unit/datepicker/core.js b/tests/unit/datepicker/core.js
index ec4c0efed..943a188b8 100644
--- a/tests/unit/datepicker/core.js
+++ b/tests/unit/datepicker/core.js
@@ -1,81 +1,83 @@
define( [
+ "qunit",
"jquery",
"lib/common",
"./helper",
"ui/widgets/datepicker",
"ui/i18n/datepicker-he"
-], function( $, common, testHelper ) {
+], function( QUnit, $, common, testHelper ) {
-module( "datepicker: core", {
- setup: function() {
+QUnit.module( "datepicker: core", {
+ beforeEach: function() {
$( "body" ).trigger( "focus" );
}
} );
common.testJshint( "widgets/datepicker" );
-test( "initialization - Reinitialization after body had been emptied.", function() {
- expect( 1 );
+QUnit.test( "initialization - Reinitialization after body had been emptied.", function( assert ) {
+ assert.expect( 1 );
var bodyContent = $( "body" ).children(), inp = $( "#inp" );
$( "#inp" ).datepicker();
$( "body" ).empty().append( inp );
$( "#inp" ).datepicker();
- ok( $( "#" + $.datepicker._mainDivId ).length === 1, "Datepicker container added" );
+ assert.ok( $( "#" + $.datepicker._mainDivId ).length === 1, "Datepicker container added" );
$( "body" ).empty().append( bodyContent ); // Returning to initial state for later tests
} );
-test( "widget method - empty collection", function() {
- expect( 1 );
- $( "#nonExist" ).datepicker(); // should create nothing
- ok( !$( "#ui-datepicker-div" ).length, "Non init on empty collection" );
+QUnit.test( "widget method - empty collection", function( assert ) {
+ assert.expect( 1 );
+ $( "#nonExist" ).datepicker(); // Should create nothing
+ assert.ok( !$( "#ui-datepicker-div" ).length, "Non init on empty collection" );
} );
-test( "widget method", function() {
- expect( 1 );
+QUnit.test( "widget method", function( assert ) {
+ assert.expect( 1 );
var actual = $( "#inp" ).datepicker().datepicker( "widget" )[ 0 ];
- deepEqual( $( "body > #ui-datepicker-div:last-child" )[ 0 ], actual );
+ assert.deepEqual( $( "body > #ui-datepicker-div:last-child" )[ 0 ], actual );
} );
-asyncTest( "baseStructure", function() {
- expect( 58 );
+QUnit.test( "baseStructure", function( assert ) {
+ var ready = assert.async();
+ assert.expect( 58 );
var header, title, table, thead, week, panel, inl, child,
inp = testHelper.initNewInput(),
dp = $( "#ui-datepicker-div" );
function step1() {
testHelper.onFocus( inp, function() {
- ok( dp.is( ":visible" ), "Structure - datepicker visible" );
- ok( !dp.is( ".ui-datepicker-rtl" ), "Structure - not right-to-left" );
- ok( !dp.is( ".ui-datepicker-multi" ), "Structure - not multi-month" );
- equal( dp.children().length, 2, "Structure - child count" );
+ assert.ok( dp.is( ":visible" ), "Structure - datepicker visible" );
+ assert.ok( !dp.is( ".ui-datepicker-rtl" ), "Structure - not right-to-left" );
+ assert.ok( !dp.is( ".ui-datepicker-multi" ), "Structure - not multi-month" );
+ assert.equal( dp.children().length, 2, "Structure - child count" );
header = dp.children( ":first" );
- ok( header.is( "div.ui-datepicker-header" ), "Structure - header division" );
- equal( header.children().length, 3, "Structure - header child count" );
- ok( header.children( ":first" ).is( "a.ui-datepicker-prev" ) && header.children( ":first" ).html() !== "", "Structure - prev link" );
- ok( header.children( ":eq(1)" ).is( "a.ui-datepicker-next" ) && header.children( ":eq(1)" ).html() !== "", "Structure - next link" );
+ assert.ok( header.is( "div.ui-datepicker-header" ), "Structure - header division" );
+ assert.equal( header.children().length, 3, "Structure - header child count" );
+ assert.ok( header.children( ":first" ).is( "a.ui-datepicker-prev" ) && header.children( ":first" ).html() !== "", "Structure - prev link" );
+ assert.ok( header.children( ":eq(1)" ).is( "a.ui-datepicker-next" ) && header.children( ":eq(1)" ).html() !== "", "Structure - next link" );
title = header.children( ":last" );
- ok( title.is( "div.ui-datepicker-title" ) && title.html() !== "", "Structure - title division" );
- equal( title.children().length, 2, "Structure - title child count" );
- ok( title.children( ":first" ).is( "span.ui-datepicker-month" ) && title.children( ":first" ).text() !== "", "Structure - month text" );
- ok( title.children( ":last" ).is( "span.ui-datepicker-year" ) && title.children( ":last" ).text() !== "", "Structure - year text" );
+ assert.ok( title.is( "div.ui-datepicker-title" ) && title.html() !== "", "Structure - title division" );
+ assert.equal( title.children().length, 2, "Structure - title child count" );
+ assert.ok( title.children( ":first" ).is( "span.ui-datepicker-month" ) && title.children( ":first" ).text() !== "", "Structure - month text" );
+ assert.ok( title.children( ":last" ).is( "span.ui-datepicker-year" ) && title.children( ":last" ).text() !== "", "Structure - year text" );
table = dp.children( ":eq(1)" );
- ok( table.is( "table.ui-datepicker-calendar" ), "Structure - month table" );
- ok( table.children( ":first" ).is( "thead" ), "Structure - month table thead" );
+ assert.ok( table.is( "table.ui-datepicker-calendar" ), "Structure - month table" );
+ assert.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" );
+ assert.ok( thead.is( "tr" ), "Structure - month table title row" );
+ assert.equal( thead.find( "th" ).length, 7, "Structure - month table title cells" );
+ assert.ok( table.children( ":eq(1)" ).is( "tbody" ), "Structure - month table body" );
+ assert.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" );
- ok( week.children( ":first" ).is( "td.ui-datepicker-week-end" ), "Structure - month table first day cell" );
- ok( week.children( ":last" ).is( "td.ui-datepicker-week-end" ), "Structure - month table second day cell" );
+ assert.ok( week.is( "tr" ), "Structure - month table week row" );
+ assert.equal( week.children().length, 7, "Structure - week child count" );
+ assert.ok( week.children( ":first" ).is( "td.ui-datepicker-week-end" ), "Structure - month table first day cell" );
+ assert.ok( week.children( ":last" ).is( "td.ui-datepicker-week-end" ), "Structure - month table second day cell" );
inp.datepicker( "hide" ).datepicker( "destroy" );
step2();
@@ -92,14 +94,14 @@ asyncTest( "baseStructure", function() {
} );
testHelper.onFocus( inp, function() {
title = dp.find( "div.ui-datepicker-title" );
- ok( title.children( ":first" ).is( "select.ui-datepicker-month" ), "Structure - month selector" );
- ok( title.children( ":last" ).is( "select.ui-datepicker-year" ), "Structure - year selector" );
+ assert.ok( title.children( ":first" ).is( "select.ui-datepicker-month" ), "Structure - month selector" );
+ assert.ok( title.children( ":last" ).is( "select.ui-datepicker-year" ), "Structure - year selector" );
panel = dp.children( ":last" );
- ok( panel.is( "div.ui-datepicker-buttonpane" ), "Structure - button panel division" );
- equal( panel.children().length, 2, "Structure - button panel child count" );
- ok( panel.children( ":first" ).is( "button.ui-datepicker-current" ), "Structure - today button" );
- ok( panel.children( ":last" ).is( "button.ui-datepicker-close" ), "Structure - close button" );
+ assert.ok( panel.is( "div.ui-datepicker-buttonpane" ), "Structure - button panel division" );
+ assert.equal( panel.children().length, 2, "Structure - button panel child count" );
+ assert.ok( panel.children( ":first" ).is( "button.ui-datepicker-current" ), "Structure - today button" );
+ assert.ok( panel.children( ":last" ).is( "button.ui-datepicker-close" ), "Structure - close button" );
inp.datepicker( "hide" ).datepicker( "destroy" );
step3();
@@ -111,18 +113,18 @@ asyncTest( "baseStructure", function() {
// Multi-month 2
inp = testHelper.initNewInput( { numberOfMonths: 2 } );
testHelper.onFocus( inp, function() {
- ok( dp.is( ".ui-datepicker-multi" ), "Structure multi [2] - multi-month" );
- equal( dp.children().length, 3, "Structure multi [2] - child count" );
+ assert.ok( dp.is( ".ui-datepicker-multi" ), "Structure multi [2] - multi-month" );
+ assert.equal( dp.children().length, 3, "Structure multi [2] - child count" );
child = dp.children( ":first" );
- ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-first" ), "Structure multi [2] - first month division" );
+ assert.ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-first" ), "Structure multi [2] - first month division" );
child = dp.children( ":eq(1)" );
- ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-last" ), "Structure multi [2] - second month division" );
+ assert.ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-last" ), "Structure multi [2] - second month division" );
child = dp.children( ":eq(2)" );
- ok( child.is( "div.ui-datepicker-row-break" ), "Structure multi [2] - row break" );
- ok( dp.is( ".ui-datepicker-multi-2" ), "Structure multi [2] - multi-2" );
+ assert.ok( child.is( "div.ui-datepicker-row-break" ), "Structure multi [2] - row break" );
+ assert.ok( dp.is( ".ui-datepicker-multi-2" ), "Structure multi [2] - multi-2" );
inp.datepicker( "hide" ).datepicker( "destroy" );
step4();
@@ -134,8 +136,8 @@ asyncTest( "baseStructure", function() {
// Multi-month 3
inp = testHelper.initNewInput( { numberOfMonths: 3 } );
testHelper.onFocus( inp, function() {
- ok( dp.is( ".ui-datepicker-multi-3" ), "Structure multi [3] - multi-3" );
- ok( !dp.is( ".ui-datepicker-multi-2" ), "Structure multi [3] - Trac #6704" );
+ assert.ok( dp.is( ".ui-datepicker-multi-3" ), "Structure multi [3] - multi-3" );
+ assert.ok( !dp.is( ".ui-datepicker-multi-2" ), "Structure multi [3] - Trac #6704" );
inp.datepicker( "hide" ).datepicker( "destroy" );
step5();
@@ -147,26 +149,26 @@ asyncTest( "baseStructure", function() {
// Multi-month [2, 2]
inp = testHelper.initNewInput( { numberOfMonths: [ 2, 2 ] } );
testHelper.onFocus( inp, function() {
- ok( dp.is( ".ui-datepicker-multi" ), "Structure multi - multi-month" );
- equal( dp.children().length, 6, "Structure multi [2,2] - child count" );
+ assert.ok( dp.is( ".ui-datepicker-multi" ), "Structure multi - multi-month" );
+ assert.equal( dp.children().length, 6, "Structure multi [2,2] - child count" );
child = dp.children( ":first" );
- ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-first" ), "Structure multi [2,2] - first month division" );
+ assert.ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-first" ), "Structure multi [2,2] - first month division" );
child = dp.children( ":eq(1)" );
- ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-last" ), "Structure multi [2,2] - second month division" );
+ assert.ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-last" ), "Structure multi [2,2] - second month division" );
child = dp.children( ":eq(2)" );
- ok( child.is( "div.ui-datepicker-row-break" ), "Structure multi [2,2] - row break" );
+ assert.ok( child.is( "div.ui-datepicker-row-break" ), "Structure multi [2,2] - row break" );
child = dp.children( ":eq(3)" );
- ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-first" ), "Structure multi [2,2] - third month division" );
+ assert.ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-first" ), "Structure multi [2,2] - third month division" );
child = dp.children( ":eq(4)" );
- ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-last" ), "Structure multi [2,2] - fourth month division" );
+ assert.ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-last" ), "Structure multi [2,2] - fourth month division" );
child = dp.children( ":eq(5)" );
- ok( child.is( "div.ui-datepicker-row-break" ), "Structure multi [2,2] - row break" );
+ assert.ok( child.is( "div.ui-datepicker-row-break" ), "Structure multi [2,2] - row break" );
inp.datepicker( "hide" ).datepicker( "destroy" );
@@ -174,19 +176,19 @@ asyncTest( "baseStructure", function() {
inl = testHelper.init( "#inl" );
dp = inl.children();
- ok( dp.is( ".ui-datepicker-inline" ), "Structure inline - main div" );
- ok( !dp.is( ".ui-datepicker-rtl" ), "Structure inline - not right-to-left" );
- ok( !dp.is( ".ui-datepicker-multi" ), "Structure inline - not multi-month" );
- equal( dp.children().length, 2, "Structure inline - child count" );
+ assert.ok( dp.is( ".ui-datepicker-inline" ), "Structure inline - main div" );
+ assert.ok( !dp.is( ".ui-datepicker-rtl" ), "Structure inline - not right-to-left" );
+ assert.ok( !dp.is( ".ui-datepicker-multi" ), "Structure inline - not multi-month" );
+ assert.equal( dp.children().length, 2, "Structure inline - child count" );
header = dp.children( ":first" );
- ok( header.is( "div.ui-datepicker-header" ), "Structure inline - header division" );
- equal( header.children().length, 3, "Structure inline - header child count" );
+ assert.ok( header.is( "div.ui-datepicker-header" ), "Structure inline - header division" );
+ assert.equal( header.children().length, 3, "Structure inline - header child count" );
table = dp.children( ":eq(1)" );
- ok( table.is( "table.ui-datepicker-calendar" ), "Structure inline - month table" );
- ok( table.children( ":first" ).is( "thead" ), "Structure inline - month table thead" );
- ok( table.children( ":eq(1)" ).is( "tbody" ), "Structure inline - month table body" );
+ assert.ok( table.is( "table.ui-datepicker-calendar" ), "Structure inline - month table" );
+ assert.ok( table.children( ":first" ).is( "thead" ), "Structure inline - month table thead" );
+ assert.ok( table.children( ":eq(1)" ).is( "tbody" ), "Structure inline - month table body" );
inl.datepicker( "destroy" );
@@ -194,28 +196,29 @@ asyncTest( "baseStructure", function() {
inl = testHelper.init( "#inl", { numberOfMonths: 2 } );
dp = inl.children();
- ok( dp.is( ".ui-datepicker-inline" ) && dp.is( ".ui-datepicker-multi" ), "Structure inline multi - main div" );
- equal( dp.children().length, 3, "Structure inline multi - child count" );
+ assert.ok( dp.is( ".ui-datepicker-inline" ) && dp.is( ".ui-datepicker-multi" ), "Structure inline multi - main div" );
+ assert.equal( dp.children().length, 3, "Structure inline multi - child count" );
child = dp.children( ":first" );
- ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-first" ), "Structure inline multi - first month division" );
+ assert.ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-first" ), "Structure inline multi - first month division" );
child = dp.children( ":eq(1)" );
- ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-last" ), "Structure inline multi - second month division" );
+ assert.ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-last" ), "Structure inline multi - second month division" );
child = dp.children( ":eq(2)" );
- ok( child.is( "div.ui-datepicker-row-break" ), "Structure inline multi - row break" );
+ assert.ok( child.is( "div.ui-datepicker-row-break" ), "Structure inline multi - row break" );
inl.datepicker( "destroy" );
- start();
+ ready();
} );
}
step1();
} );
-asyncTest( "customStructure", function() {
- expect( 20 );
+QUnit.test( "customStructure", function( assert ) {
+ var ready = assert.async();
+ assert.expect( 20 );
var header, panel, title, thead,
inp = testHelper.initNewInput( $.datepicker.regional.he ),
dp = $( "#ui-datepicker-div" );
@@ -224,19 +227,19 @@ asyncTest( "customStructure", function() {
inp.datepicker( "option", "showButtonPanel", true );
testHelper.onFocus( inp, function() {
- ok( dp.is( ".ui-datepicker-rtl" ), "Structure RTL - right-to-left" );
+ assert.ok( dp.is( ".ui-datepicker-rtl" ), "Structure RTL - right-to-left" );
header = dp.children( ":first" );
- ok( header.is( "div.ui-datepicker-header" ), "Structure RTL - header division" );
- equal( header.children().length, 3, "Structure RTL - header child count" );
- ok( header.children( ":first" ).is( "a.ui-datepicker-next" ), "Structure RTL - prev link" );
- ok( header.children( ":eq(1)" ).is( "a.ui-datepicker-prev" ), "Structure RTL - next link" );
+ assert.ok( header.is( "div.ui-datepicker-header" ), "Structure RTL - header division" );
+ assert.equal( header.children().length, 3, "Structure RTL - header child count" );
+ assert.ok( header.children( ":first" ).is( "a.ui-datepicker-next" ), "Structure RTL - prev link" );
+ assert.ok( header.children( ":eq(1)" ).is( "a.ui-datepicker-prev" ), "Structure RTL - next link" );
panel = dp.children( ":last" );
- ok( panel.is( "div.ui-datepicker-buttonpane" ), "Structure RTL - button division" );
- equal( panel.children().length, 2, "Structure RTL - button panel child count" );
- ok( panel.children( ":first" ).is( "button.ui-datepicker-close" ), "Structure RTL - close button" );
- ok( panel.children( ":last" ).is( "button.ui-datepicker-current" ), "Structure RTL - today button" );
+ assert.ok( panel.is( "div.ui-datepicker-buttonpane" ), "Structure RTL - button division" );
+ assert.equal( panel.children().length, 2, "Structure RTL - button panel child count" );
+ assert.ok( panel.children( ":first" ).is( "button.ui-datepicker-close" ), "Structure RTL - close button" );
+ assert.ok( panel.children( ":last" ).is( "button.ui-datepicker-current" ), "Structure RTL - today button" );
inp.datepicker( "hide" ).datepicker( "destroy" );
step2();
@@ -254,9 +257,9 @@ asyncTest( "customStructure", function() {
testHelper.onFocus( inp, function() {
header = dp.children( ":first" );
- ok( header.is( "div.ui-datepicker-header" ), "Structure hide prev/next - header division" );
- equal( header.children().length, 1, "Structure hide prev/next - links child count" );
- ok( header.children( ":first" ).is( "div.ui-datepicker-title" ), "Structure hide prev/next - title division" );
+ assert.ok( header.is( "div.ui-datepicker-header" ), "Structure hide prev/next - header division" );
+ assert.equal( header.children().length, 1, "Structure hide prev/next - links child count" );
+ assert.ok( header.children( ":first" ).is( "div.ui-datepicker-title" ), "Structure hide prev/next - title division" );
inp.datepicker( "hide" ).datepicker( "destroy" );
step3();
@@ -269,9 +272,9 @@ asyncTest( "customStructure", function() {
testHelper.onFocus( inp, function() {
title = dp.children( ":first" ).children( ":last" );
- equal( title.children().length, 2, "Structure changeable month - title child count" );
- ok( title.children( ":first" ).is( "select.ui-datepicker-month" ), "Structure changeable month - month selector" );
- ok( title.children( ":last" ).is( "span.ui-datepicker-year" ), "Structure changeable month - read-only year" );
+ assert.equal( title.children().length, 2, "Structure changeable month - title child count" );
+ assert.ok( title.children( ":first" ).is( "select.ui-datepicker-month" ), "Structure changeable month - month selector" );
+ assert.ok( title.children( ":last" ).is( "span.ui-datepicker-year" ), "Structure changeable month - read-only year" );
inp.datepicker( "hide" ).datepicker( "destroy" );
step4();
@@ -284,9 +287,9 @@ asyncTest( "customStructure", function() {
testHelper.onFocus( inp, function() {
title = dp.children( ":first" ).children( ":last" );
- equal( title.children().length, 2, "Structure changeable year - title child count" );
- ok( title.children( ":first" ).is( "span.ui-datepicker-month" ), "Structure changeable year - read-only month" );
- ok( title.children( ":last" ).is( "select.ui-datepicker-year" ), "Structure changeable year - year selector" );
+ assert.equal( title.children().length, 2, "Structure changeable year - title child count" );
+ assert.ok( title.children( ":first" ).is( "span.ui-datepicker-month" ), "Structure changeable year - read-only month" );
+ assert.ok( title.children( ":last" ).is( "select.ui-datepicker-year" ), "Structure changeable year - year selector" );
inp.datepicker( "hide" ).datepicker( "destroy" );
step5();
@@ -299,11 +302,11 @@ asyncTest( "customStructure", function() {
testHelper.onFocus( inp, function() {
thead = dp.find( ".ui-datepicker-calendar thead tr" );
- equal( thead.children().length, 7, "Structure read-only first day - thead child count" );
- equal( thead.find( "a" ).length, 0, "Structure read-only first day - thead links count" );
+ assert.equal( thead.children().length, 7, "Structure read-only first day - thead child count" );
+ assert.equal( thead.find( "a" ).length, 0, "Structure read-only first day - thead links count" );
inp.datepicker( "hide" ).datepicker( "destroy" );
- start();
+ ready();
} );
}
@@ -313,35 +316,35 @@ asyncTest( "customStructure", function() {
setTimeout( step1 );
} );
-test( "keystrokes", function() {
- expect( 26 );
+QUnit.test( "keystrokes", function( assert ) {
+ assert.expect( 26 );
var inp = testHelper.init( "#inp" ),
date = new Date();
inp.val( "" ).datepicker( "show" ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date, "Keystroke enter" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Keystroke enter" );
inp.val( "02/04/2008" ).datepicker( "show" ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- testHelper.equalsDate( inp.datepicker( "getDate" ), new Date( 2008, 2 - 1, 4 ),
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2008, 2 - 1, 4 ),
"Keystroke enter - preset" );
inp.val( "02/04/2008" ).datepicker( "show" ).
simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.HOME } ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date, "Keystroke ctrl+home" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Keystroke ctrl+home" );
inp.val( "02/04/2008" ).datepicker( "show" ).
simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.END } );
- ok( inp.datepicker( "getDate" ) == null, "Keystroke ctrl+end" );
+ assert.ok( inp.datepicker( "getDate" ) == null, "Keystroke ctrl+end" );
inp.val( "" ).datepicker( "show" ).
simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
- ok( inp.datepicker( "getDate" ) == null, "Keystroke esc" );
+ assert.ok( inp.datepicker( "getDate" ) == null, "Keystroke esc" );
inp.val( "02/04/2008" ).datepicker( "show" ).
simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
- testHelper.equalsDate( inp.datepicker( "getDate" ), new Date( 2008, 2 - 1, 4 ),
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2008, 2 - 1, 4 ),
"Keystroke esc - preset" );
inp.val( "02/04/2008" ).datepicker( "show" ).
simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP } ).
simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
- testHelper.equalsDate( inp.datepicker( "getDate" ), new Date( 2008, 2 - 1, 4 ),
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2008, 2 - 1, 4 ),
"Keystroke esc - abandoned" );
// Moving by day or week
@@ -349,85 +352,85 @@ test( "keystrokes", function() {
simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.LEFT } ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
date.setDate( date.getDate() - 1 );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date, "Keystroke ctrl+left" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Keystroke ctrl+left" );
inp.val( "" ).datepicker( "show" ).
simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
date.setDate( date.getDate() + 1 );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date, "Keystroke left" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Keystroke left" );
inp.val( "" ).datepicker( "show" ).
simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.RIGHT } ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
date.setDate( date.getDate() + 1 );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date, "Keystroke ctrl+right" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Keystroke ctrl+right" );
inp.val( "" ).datepicker( "show" ).
simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
date.setDate( date.getDate() - 1 );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date, "Keystroke right" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Keystroke right" );
inp.val( "" ).datepicker( "show" ).
simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.UP } ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
date.setDate( date.getDate() - 7 );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date, "Keystroke ctrl+up" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Keystroke ctrl+up" );
inp.val( "" ).datepicker( "show" ).
simulate( "keydown", { keyCode: $.ui.keyCode.UP } ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
date.setDate( date.getDate() + 7 );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date, "Keystroke up" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Keystroke up" );
inp.val( "" ).datepicker( "show" ).
simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.DOWN } ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
date.setDate( date.getDate() + 7 );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date, "Keystroke ctrl+down" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Keystroke ctrl+down" );
inp.val( "" ).datepicker( "show" ).
simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
date.setDate( date.getDate() - 7 );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date, "Keystroke down" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Keystroke down" );
// Moving by month or year
inp.val( "02/04/2008" ).datepicker( "show" ).
simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- testHelper.equalsDate( inp.datepicker( "getDate" ), new Date( 2008, 1 - 1, 4 ),
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2008, 1 - 1, 4 ),
"Keystroke pgup" );
inp.val( "02/04/2008" ).datepicker( "show" ).
simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- testHelper.equalsDate( inp.datepicker( "getDate" ), new Date( 2008, 3 - 1, 4 ),
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2008, 3 - 1, 4 ),
"Keystroke pgdn" );
inp.val( "02/04/2008" ).datepicker( "show" ).
simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP } ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- testHelper.equalsDate( inp.datepicker( "getDate" ), new Date( 2007, 2 - 1, 4 ),
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2007, 2 - 1, 4 ),
"Keystroke ctrl+pgup" );
inp.val( "02/04/2008" ).datepicker( "show" ).
simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN } ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- testHelper.equalsDate( inp.datepicker( "getDate" ), new Date( 2009, 2 - 1, 4 ),
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2009, 2 - 1, 4 ),
"Keystroke ctrl+pgdn" );
// Check for moving to short months
inp.val( "03/31/2008" ).datepicker( "show" ).
simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- testHelper.equalsDate( inp.datepicker( "getDate" ), new Date( 2008, 2 - 1, 29 ),
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2008, 2 - 1, 29 ),
"Keystroke pgup - Feb" );
inp.val( "01/30/2008" ).datepicker( "show" ).
simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- testHelper.equalsDate( inp.datepicker( "getDate" ), new Date( 2008, 2 - 1, 29 ),
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2008, 2 - 1, 29 ),
"Keystroke pgdn - Feb" );
inp.val( "02/29/2008" ).datepicker( "show" ).
simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP } ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- testHelper.equalsDate( inp.datepicker( "getDate" ), new Date( 2007, 2 - 1, 28 ),
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2007, 2 - 1, 28 ),
"Keystroke ctrl+pgup - Feb" );
inp.val( "02/29/2008" ).datepicker( "show" ).
simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN } ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- testHelper.equalsDate( inp.datepicker( "getDate" ), new Date( 2009, 2 - 1, 28 ),
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2009, 2 - 1, 28 ),
"Keystroke ctrl+pgdn - Feb" );
// Goto current
@@ -436,7 +439,7 @@ test( "keystrokes", function() {
simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ).
simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.HOME } ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- testHelper.equalsDate( inp.datepicker( "getDate" ), new Date( 2008, 2 - 1, 4 ),
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2008, 2 - 1, 4 ),
"Keystroke ctrl+home" );
// Change steps
@@ -444,17 +447,17 @@ test( "keystrokes", function() {
datepicker( "hide" ).val( "02/04/2008" ).datepicker( "show" ).
simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- testHelper.equalsDate( inp.datepicker( "getDate" ), new Date( 2007, 12 - 1, 4 ),
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2007, 12 - 1, 4 ),
"Keystroke pgup step 2" );
inp.val( "02/04/2008" ).datepicker( "show" ).
simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- testHelper.equalsDate( inp.datepicker( "getDate" ), new Date( 2008, 4 - 1, 4 ),
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2008, 4 - 1, 4 ),
"Keystroke pgdn step 2" );
} );
-test( "mouse", function() {
- expect( 15 );
+QUnit.test( "mouse", function( assert ) {
+ assert.expect( 15 );
var inl,
inp = testHelper.init( "#inp" ),
dp = $( "#ui-datepicker-div" ),
@@ -462,23 +465,23 @@ test( "mouse", function() {
inp.val( "" ).datepicker( "show" );
$( ".ui-datepicker-calendar tbody a:contains(10)", dp ).simulate( "click", {} );
date.setDate( 10 );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date, "Mouse click" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Mouse click" );
inp.val( "02/04/2008" ).datepicker( "show" );
$( ".ui-datepicker-calendar tbody a:contains(12)", dp ).simulate( "click", {} );
- testHelper.equalsDate( inp.datepicker( "getDate" ), new Date( 2008, 2 - 1, 12 ),
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2008, 2 - 1, 12 ),
"Mouse click - preset" );
inp.val( "02/04/2008" ).datepicker( "show" );
inp.val( "" ).datepicker( "show" );
$( "button.ui-datepicker-close", dp ).simulate( "click", {} );
- ok( inp.datepicker( "getDate" ) == null, "Mouse click - close" );
+ assert.ok( inp.datepicker( "getDate" ) == null, "Mouse click - close" );
inp.val( "02/04/2008" ).datepicker( "show" );
$( "button.ui-datepicker-close", dp ).simulate( "click", {} );
- testHelper.equalsDate( inp.datepicker( "getDate" ), new Date( 2008, 2 - 1, 4 ),
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2008, 2 - 1, 4 ),
"Mouse click - close + preset" );
inp.val( "02/04/2008" ).datepicker( "show" );
$( "a.ui-datepicker-prev", dp ).simulate( "click", {} );
$( "button.ui-datepicker-close", dp ).simulate( "click", {} );
- testHelper.equalsDate( inp.datepicker( "getDate" ), new Date( 2008, 2 - 1, 4 ),
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2008, 2 - 1, 4 ),
"Mouse click - abandoned" );
// Current/previous/next
@@ -486,16 +489,16 @@ test( "mouse", function() {
$( ".ui-datepicker-current", dp ).simulate( "click", {} );
$( ".ui-datepicker-calendar tbody a:contains(14)", dp ).simulate( "click", {} );
date.setDate( 14 );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date, "Mouse click - current" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Mouse click - current" );
inp.val( "02/04/2008" ).datepicker( "show" );
$( ".ui-datepicker-prev", dp ).simulate( "click" );
$( ".ui-datepicker-calendar tbody a:contains(16)", dp ).simulate( "click" );
- testHelper.equalsDate( inp.datepicker( "getDate" ), new Date( 2008, 1 - 1, 16 ),
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2008, 1 - 1, 16 ),
"Mouse click - previous" );
inp.val( "02/04/2008" ).datepicker( "show" );
$( ".ui-datepicker-next", dp ).simulate( "click" );
$( ".ui-datepicker-calendar tbody a:contains(18)", dp ).simulate( "click" );
- testHelper.equalsDate( inp.datepicker( "getDate" ), new Date( 2008, 3 - 1, 18 ),
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2008, 3 - 1, 18 ),
"Mouse click - next" );
// Previous/next with minimum/maximum
@@ -503,12 +506,12 @@ test( "mouse", function() {
maxDate: new Date( 2008, 2 - 1, 26 ) } ).val( "02/04/2008" ).datepicker( "show" );
$( ".ui-datepicker-prev", dp ).simulate( "click" );
$( ".ui-datepicker-calendar tbody a:contains(16)", dp ).simulate( "click" );
- testHelper.equalsDate( inp.datepicker( "getDate" ), new Date( 2008, 2 - 1, 16 ),
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2008, 2 - 1, 16 ),
"Mouse click - previous + min/max" );
inp.val( "02/04/2008" ).datepicker( "show" );
$( ".ui-datepicker-next", dp ).simulate( "click" );
$( ".ui-datepicker-calendar tbody a:contains(18)", dp ).simulate( "click" );
- testHelper.equalsDate( inp.datepicker( "getDate" ), new Date( 2008, 2 - 1, 18 ),
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2008, 2 - 1, 18 ),
"Mouse click - next + min/max" );
// Inline
@@ -518,24 +521,24 @@ test( "mouse", function() {
inl.datepicker( "setDate", date );
$( ".ui-datepicker-calendar tbody a:contains(10)", dp ).simulate( "click", {} );
date.setDate( 10 );
- testHelper.equalsDate( inl.datepicker( "getDate" ), date, "Mouse click inline" );
+ testHelper.equalsDate( assert, inl.datepicker( "getDate" ), date, "Mouse click inline" );
inl.datepicker( "option", { showButtonPanel: true } ).datepicker( "setDate", new Date( 2008, 2 - 1, 4 ) );
$( ".ui-datepicker-calendar tbody a:contains(12)", dp ).simulate( "click", {} );
- testHelper.equalsDate( inl.datepicker( "getDate" ), new Date( 2008, 2 - 1, 12 ), "Mouse click inline - preset" );
+ testHelper.equalsDate( assert, inl.datepicker( "getDate" ), new Date( 2008, 2 - 1, 12 ), "Mouse click inline - preset" );
inl.datepicker( "option", { showButtonPanel: true } );
$( ".ui-datepicker-current", dp ).simulate( "click", {} );
$( ".ui-datepicker-calendar tbody a:contains(14)", dp ).simulate( "click", {} );
date.setDate( 14 );
- testHelper.equalsDate( inl.datepicker( "getDate" ), date, "Mouse click inline - current" );
+ testHelper.equalsDate( assert, inl.datepicker( "getDate" ), date, "Mouse click inline - current" );
inl.datepicker( "setDate", new Date( 2008, 2 - 1, 4 ) );
$( ".ui-datepicker-prev", dp ).simulate( "click" );
$( ".ui-datepicker-calendar tbody a:contains(16)", dp ).simulate( "click" );
- testHelper.equalsDate( inl.datepicker( "getDate" ), new Date( 2008, 1 - 1, 16 ),
+ testHelper.equalsDate( assert, inl.datepicker( "getDate" ), new Date( 2008, 1 - 1, 16 ),
"Mouse click inline - previous" );
inl.datepicker( "setDate", new Date( 2008, 2 - 1, 4 ) );
$( ".ui-datepicker-next", dp ).simulate( "click" );
$( ".ui-datepicker-calendar tbody a:contains(18)", dp ).simulate( "click" );
- testHelper.equalsDate( inl.datepicker( "getDate" ), new Date( 2008, 3 - 1, 18 ),
+ testHelper.equalsDate( assert, inl.datepicker( "getDate" ), new Date( 2008, 3 - 1, 18 ),
"Mouse click inline - next" );
} );
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" );
} );
diff --git a/tests/unit/datepicker/helper.js b/tests/unit/datepicker/helper.js
index 4712a08da..7fd149bf1 100644
--- a/tests/unit/datepicker/helper.js
+++ b/tests/unit/datepicker/helper.js
@@ -1,8 +1,9 @@
define( [
+ "qunit",
"jquery",
"lib/helper",
"ui/widgets/datepicker"
-], function( $, helper ) {
+], function( QUnit, $, helper ) {
return $.extend( helper, {
addMonths: function( date, offset ) {
@@ -12,14 +13,14 @@ return $.extend( helper, {
return date;
},
- equalsDate: function( d1, d2, message ) {
+ equalsDate: function( assert, d1, d2, message ) {
if ( !d1 || !d2 ) {
- ok( false, message + " - missing date" );
+ assert.ok( false, message + " - missing date" );
return;
}
d1 = new Date( d1.getFullYear(), d1.getMonth(), d1.getDate() );
d2 = new Date( d2.getFullYear(), d2.getMonth(), d2.getDate() );
- equal( d1.toString(), d2.toString(), message );
+ assert.equal( d1.toString(), d2.toString(), message );
},
init: function( id, options ) {
diff --git a/tests/unit/datepicker/methods.js b/tests/unit/datepicker/methods.js
index fcf8c2104..4fc0c84ec 100644
--- a/tests/unit/datepicker/methods.js
+++ b/tests/unit/datepicker/methods.js
@@ -1,132 +1,133 @@
define( [
+ "qunit",
"jquery",
"./helper",
"ui/widgets/datepicker"
-], function( $, testHelper ) {
+], function( QUnit, $, testHelper ) {
-module( "datepicker: methods" );
+QUnit.module( "datepicker: methods" );
-test( "destroy", function() {
- expect( 33 );
+QUnit.test( "destroy", function( assert ) {
+ assert.expect( 33 );
var inl,
inp = testHelper.init( "#inp" );
- ok( inp.is( ".hasDatepicker" ), "Default - marker class set" );
- ok( $.data( inp[ 0 ], testHelper.PROP_NAME ), "Default - instance present" );
- ok( inp.next().is( "#alt" ), "Default - button absent" );
+ assert.ok( inp.is( ".hasDatepicker" ), "Default - marker class set" );
+ assert.ok( $.data( inp[ 0 ], testHelper.PROP_NAME ), "Default - instance present" );
+ assert.ok( inp.next().is( "#alt" ), "Default - button absent" );
inp.datepicker( "destroy" );
inp = $( "#inp" );
- ok( !inp.is( ".hasDatepicker" ), "Default - marker class cleared" );
- ok( !$.data( inp[ 0 ], testHelper.PROP_NAME ), "Default - instance absent" );
- ok( inp.next().is( "#alt" ), "Default - button absent" );
+ assert.ok( !inp.is( ".hasDatepicker" ), "Default - marker class cleared" );
+ assert.ok( !$.data( inp[ 0 ], testHelper.PROP_NAME ), "Default - instance absent" );
+ assert.ok( inp.next().is( "#alt" ), "Default - button absent" );
// With button
inp = testHelper.init( "#inp", { showOn: "both" } );
- ok( inp.is( ".hasDatepicker" ), "Button - marker class set" );
- ok( $.data( inp[ 0 ], testHelper.PROP_NAME ), "Button - instance present" );
- ok( inp.next().text() === "...", "Button - button added" );
+ assert.ok( inp.is( ".hasDatepicker" ), "Button - marker class set" );
+ assert.ok( $.data( inp[ 0 ], testHelper.PROP_NAME ), "Button - instance present" );
+ assert.ok( inp.next().text() === "...", "Button - button added" );
inp.datepicker( "destroy" );
inp = $( "#inp" );
- ok( !inp.is( ".hasDatepicker" ), "Button - marker class cleared" );
- ok( !$.data( inp[ 0 ], testHelper.PROP_NAME ), "Button - instance absent" );
- ok( inp.next().is( "#alt" ), "Button - button removed" );
+ assert.ok( !inp.is( ".hasDatepicker" ), "Button - marker class cleared" );
+ assert.ok( !$.data( inp[ 0 ], testHelper.PROP_NAME ), "Button - instance absent" );
+ assert.ok( inp.next().is( "#alt" ), "Button - button removed" );
// With append text
inp = testHelper.init( "#inp", { appendText: "Testing" } );
- ok( inp.is( ".hasDatepicker" ), "Append - marker class set" );
- ok( $.data( inp[ 0 ], testHelper.PROP_NAME ), "Append - instance present" );
- ok( inp.next().text() === "Testing", "Append - append text added" );
+ assert.ok( inp.is( ".hasDatepicker" ), "Append - marker class set" );
+ assert.ok( $.data( inp[ 0 ], testHelper.PROP_NAME ), "Append - instance present" );
+ assert.ok( inp.next().text() === "Testing", "Append - append text added" );
inp.datepicker( "destroy" );
inp = $( "#inp" );
- ok( !inp.is( ".hasDatepicker" ), "Append - marker class cleared" );
- ok( !$.data( inp[ 0 ], testHelper.PROP_NAME ), "Append - instance absent" );
- ok( inp.next().is( "#alt" ), "Append - append text removed" );
+ assert.ok( !inp.is( ".hasDatepicker" ), "Append - marker class cleared" );
+ assert.ok( !$.data( inp[ 0 ], testHelper.PROP_NAME ), "Append - instance absent" );
+ assert.ok( inp.next().is( "#alt" ), "Append - append text removed" );
// With both
inp = testHelper.init( "#inp", { showOn: "both", buttonImageOnly: true,
buttonImage: "images/calendar.gif", appendText: "Testing" } );
- ok( inp.is( ".hasDatepicker" ), "Both - marker class set" );
- ok( $.data( inp[ 0 ], testHelper.PROP_NAME ), "Both - instance present" );
- ok( inp.next()[ 0 ].nodeName.toLowerCase() === "img", "Both - button added" );
- ok( inp.next().next().text() === "Testing", "Both - append text added" );
+ assert.ok( inp.is( ".hasDatepicker" ), "Both - marker class set" );
+ assert.ok( $.data( inp[ 0 ], testHelper.PROP_NAME ), "Both - instance present" );
+ assert.ok( inp.next()[ 0 ].nodeName.toLowerCase() === "img", "Both - button added" );
+ assert.ok( inp.next().next().text() === "Testing", "Both - append text added" );
inp.datepicker( "destroy" );
inp = $( "#inp" );
- ok( !inp.is( ".hasDatepicker" ), "Both - marker class cleared" );
- ok( !$.data( inp[ 0 ], testHelper.PROP_NAME ), "Both - instance absent" );
- ok( inp.next().is( "#alt" ), "Both - button and append text absent" );
+ assert.ok( !inp.is( ".hasDatepicker" ), "Both - marker class cleared" );
+ assert.ok( !$.data( inp[ 0 ], testHelper.PROP_NAME ), "Both - instance absent" );
+ assert.ok( inp.next().is( "#alt" ), "Both - button and append text absent" );
// Inline
inl = testHelper.init( "#inl" );
- ok( inl.is( ".hasDatepicker" ), "Inline - marker class set" );
- ok( inl.html() !== "", "Inline - datepicker present" );
- ok( $.data( inl[ 0 ], testHelper.PROP_NAME ), "Inline - instance present" );
- ok( inl.next().length === 0 || inl.next().is( "p" ), "Inline - button absent" );
+ assert.ok( inl.is( ".hasDatepicker" ), "Inline - marker class set" );
+ assert.ok( inl.html() !== "", "Inline - datepicker present" );
+ assert.ok( $.data( inl[ 0 ], testHelper.PROP_NAME ), "Inline - instance present" );
+ assert.ok( inl.next().length === 0 || inl.next().is( "p" ), "Inline - button absent" );
inl.datepicker( "destroy" );
inl = $( "#inl" );
- ok( !inl.is( ".hasDatepicker" ), "Inline - marker class cleared" );
- ok( inl.html() === "", "Inline - datepicker absent" );
- ok( !$.data( inl[ 0 ], testHelper.PROP_NAME ), "Inline - instance absent" );
- ok( inl.next().length === 0 || inl.next().is( "p" ), "Inline - button absent" );
+ assert.ok( !inl.is( ".hasDatepicker" ), "Inline - marker class cleared" );
+ assert.ok( inl.html() === "", "Inline - datepicker absent" );
+ assert.ok( !$.data( inl[ 0 ], testHelper.PROP_NAME ), "Inline - instance absent" );
+ assert.ok( inl.next().length === 0 || inl.next().is( "p" ), "Inline - button absent" );
} );
-test( "enableDisable", function() {
- expect( 33 );
+QUnit.test( "enableDisable", function( assert ) {
+ assert.expect( 33 );
var inl, dp,
inp = testHelper.init( "#inp" );
- ok( !inp.datepicker( "isDisabled" ), "Enable/disable - initially marked as enabled" );
- ok( !inp[ 0 ].disabled, "Enable/disable - field initially enabled" );
+ assert.ok( !inp.datepicker( "isDisabled" ), "Enable/disable - initially marked as enabled" );
+ assert.ok( !inp[ 0 ].disabled, "Enable/disable - field initially enabled" );
inp.datepicker( "disable" );
- ok( inp.datepicker( "isDisabled" ), "Enable/disable - now marked as disabled" );
- ok( inp[ 0 ].disabled, "Enable/disable - field now disabled" );
+ assert.ok( inp.datepicker( "isDisabled" ), "Enable/disable - now marked as disabled" );
+ assert.ok( inp[ 0 ].disabled, "Enable/disable - field now disabled" );
inp.datepicker( "enable" );
- ok( !inp.datepicker( "isDisabled" ), "Enable/disable - now marked as enabled" );
- ok( !inp[ 0 ].disabled, "Enable/disable - field now enabled" );
+ assert.ok( !inp.datepicker( "isDisabled" ), "Enable/disable - now marked as enabled" );
+ assert.ok( !inp[ 0 ].disabled, "Enable/disable - field now enabled" );
inp.datepicker( "destroy" );
// With a button
inp = testHelper.init( "#inp", { showOn: "button" } );
- ok( !inp.datepicker( "isDisabled" ), "Enable/disable button - initially marked as enabled" );
- ok( !inp[ 0 ].disabled, "Enable/disable button - field initially enabled" );
- ok( !inp.next( "button" )[ 0 ].disabled, "Enable/disable button - button initially enabled" );
+ assert.ok( !inp.datepicker( "isDisabled" ), "Enable/disable button - initially marked as enabled" );
+ assert.ok( !inp[ 0 ].disabled, "Enable/disable button - field initially enabled" );
+ assert.ok( !inp.next( "button" )[ 0 ].disabled, "Enable/disable button - button initially enabled" );
inp.datepicker( "disable" );
- ok( inp.datepicker( "isDisabled" ), "Enable/disable button - now marked as disabled" );
- ok( inp[ 0 ].disabled, "Enable/disable button - field now disabled" );
- ok( inp.next( "button" )[ 0 ].disabled, "Enable/disable button - button now disabled" );
+ assert.ok( inp.datepicker( "isDisabled" ), "Enable/disable button - now marked as disabled" );
+ assert.ok( inp[ 0 ].disabled, "Enable/disable button - field now disabled" );
+ assert.ok( inp.next( "button" )[ 0 ].disabled, "Enable/disable button - button now disabled" );
inp.datepicker( "enable" );
- ok( !inp.datepicker( "isDisabled" ), "Enable/disable button - now marked as enabled" );
- ok( !inp[ 0 ].disabled, "Enable/disable button - field now enabled" );
- ok( !inp.next( "button" )[ 0 ].disabled, "Enable/disable button - button now enabled" );
+ assert.ok( !inp.datepicker( "isDisabled" ), "Enable/disable button - now marked as enabled" );
+ assert.ok( !inp[ 0 ].disabled, "Enable/disable button - field now enabled" );
+ assert.ok( !inp.next( "button" )[ 0 ].disabled, "Enable/disable button - button now enabled" );
inp.datepicker( "destroy" );
// With an image button
inp = testHelper.init( "#inp", { showOn: "button", buttonImageOnly: true,
buttonImage: "images/calendar.gif" } );
- ok( !inp.datepicker( "isDisabled" ), "Enable/disable image - initially marked as enabled" );
- ok( !inp[ 0 ].disabled, "Enable/disable image - field initially enabled" );
- ok( parseFloat( inp.next( "img" ).css( "opacity" ) ) === 1, "Enable/disable image - image initially enabled" );
+ assert.ok( !inp.datepicker( "isDisabled" ), "Enable/disable image - initially marked as enabled" );
+ assert.ok( !inp[ 0 ].disabled, "Enable/disable image - field initially enabled" );
+ assert.ok( parseFloat( inp.next( "img" ).css( "opacity" ) ) === 1, "Enable/disable image - image initially enabled" );
inp.datepicker( "disable" );
- ok( inp.datepicker( "isDisabled" ), "Enable/disable image - now marked as disabled" );
- ok( inp[ 0 ].disabled, "Enable/disable image - field now disabled" );
- ok( parseFloat( inp.next( "img" ).css( "opacity" ) ) !== 1, "Enable/disable image - image now disabled" );
+ assert.ok( inp.datepicker( "isDisabled" ), "Enable/disable image - now marked as disabled" );
+ assert.ok( inp[ 0 ].disabled, "Enable/disable image - field now disabled" );
+ assert.ok( parseFloat( inp.next( "img" ).css( "opacity" ) ) !== 1, "Enable/disable image - image now disabled" );
inp.datepicker( "enable" );
- ok( !inp.datepicker( "isDisabled" ), "Enable/disable image - now marked as enabled" );
- ok( !inp[ 0 ].disabled, "Enable/disable image - field now enabled" );
- ok( parseFloat( inp.next( "img" ).css( "opacity" ) ) === 1, "Enable/disable image - image now enabled" );
+ assert.ok( !inp.datepicker( "isDisabled" ), "Enable/disable image - now marked as enabled" );
+ assert.ok( !inp[ 0 ].disabled, "Enable/disable image - field now enabled" );
+ assert.ok( parseFloat( inp.next( "img" ).css( "opacity" ) ) === 1, "Enable/disable image - image now enabled" );
inp.datepicker( "destroy" );
// Inline
inl = testHelper.init( "#inl", { changeYear: true } );
dp = $( ".ui-datepicker-inline", inl );
- ok( !inl.datepicker( "isDisabled" ), "Enable/disable inline - initially marked as enabled" );
- ok( !dp.children().is( ".ui-state-disabled" ), "Enable/disable inline - not visually disabled initially" );
- ok( !dp.find( "select" ).prop( "disabled" ), "Enable/disable inline - form element enabled initially" );
+ assert.ok( !inl.datepicker( "isDisabled" ), "Enable/disable inline - initially marked as enabled" );
+ assert.ok( !dp.children().is( ".ui-state-disabled" ), "Enable/disable inline - not visually disabled initially" );
+ assert.ok( !dp.find( "select" ).prop( "disabled" ), "Enable/disable inline - form element enabled initially" );
inl.datepicker( "disable" );
- ok( inl.datepicker( "isDisabled" ), "Enable/disable inline - now marked as disabled" );
- ok( dp.children().is( ".ui-state-disabled" ), "Enable/disable inline - visually disabled" );
- ok( dp.find( "select" ).prop( "disabled" ), "Enable/disable inline - form element disabled" );
+ assert.ok( inl.datepicker( "isDisabled" ), "Enable/disable inline - now marked as disabled" );
+ assert.ok( dp.children().is( ".ui-state-disabled" ), "Enable/disable inline - visually disabled" );
+ assert.ok( dp.find( "select" ).prop( "disabled" ), "Enable/disable inline - form element disabled" );
inl.datepicker( "enable" );
- ok( !inl.datepicker( "isDisabled" ), "Enable/disable inline - now marked as enabled" );
- ok( !dp.children().is( ".ui-state-disabled" ), "Enable/disable inline - not visiually disabled" );
- ok( !dp.find( "select" ).prop( "disabled" ), "Enable/disable inline - form element enabled" );
+ assert.ok( !inl.datepicker( "isDisabled" ), "Enable/disable inline - now marked as enabled" );
+ assert.ok( !dp.children().is( ".ui-state-disabled" ), "Enable/disable inline - not visiually disabled" );
+ assert.ok( !dp.find( "select" ).prop( "disabled" ), "Enable/disable inline - form element enabled" );
inl.datepicker( "destroy" );
} );
diff --git a/tests/unit/datepicker/options.js b/tests/unit/datepicker/options.js
index 38c877309..821852ed4 100644
--- a/tests/unit/datepicker/options.js
+++ b/tests/unit/datepicker/options.js
@@ -1,4 +1,5 @@
define( [
+ "qunit",
"jquery",
"./helper",
"ui/widgets/datepicker",
@@ -6,91 +7,91 @@ define( [
"ui/i18n/datepicker-he",
"ui/i18n/datepicker-zh-CN",
"ui/ie"
-], function( $, testHelper ) {
+], function( QUnit, $, testHelper ) {
-module( "datepicker: options" );
+QUnit.module( "datepicker: options" );
-test( "setDefaults", function() {
- expect( 3 );
+QUnit.test( "setDefaults", function( assert ) {
+ assert.expect( 3 );
testHelper.init( "#inp" );
- equal( $.datepicker._defaults.showOn, "focus", "Initial showOn" );
+ assert.equal( $.datepicker._defaults.showOn, "focus", "Initial showOn" );
$.datepicker.setDefaults( { showOn: "button" } );
- equal( $.datepicker._defaults.showOn, "button", "Change default showOn" );
+ assert.equal( $.datepicker._defaults.showOn, "button", "Change default showOn" );
$.datepicker.setDefaults( { showOn: "focus" } );
- equal( $.datepicker._defaults.showOn, "focus", "Restore showOn" );
+ assert.equal( $.datepicker._defaults.showOn, "focus", "Restore showOn" );
} );
-test( "option", function() {
- expect( 17 );
+QUnit.test( "option", function( assert ) {
+ assert.expect( 17 );
var inp = testHelper.init( "#inp" ),
inst = $.data( inp[ 0 ], testHelper.PROP_NAME );
// Set option
- equal( inst.settings.showOn, null, "Initial setting showOn" );
- equal( $.datepicker._get( inst, "showOn" ), "focus", "Initial instance showOn" );
- equal( $.datepicker._defaults.showOn, "focus", "Initial default showOn" );
+ assert.equal( inst.settings.showOn, null, "Initial setting showOn" );
+ assert.equal( $.datepicker._get( inst, "showOn" ), "focus", "Initial instance showOn" );
+ assert.equal( $.datepicker._defaults.showOn, "focus", "Initial default showOn" );
inp.datepicker( "option", "showOn", "button" );
- equal( inst.settings.showOn, "button", "Change setting showOn" );
- equal( $.datepicker._get( inst, "showOn" ), "button", "Change instance showOn" );
- equal( $.datepicker._defaults.showOn, "focus", "Retain default showOn" );
+ assert.equal( inst.settings.showOn, "button", "Change setting showOn" );
+ assert.equal( $.datepicker._get( inst, "showOn" ), "button", "Change instance showOn" );
+ assert.equal( $.datepicker._defaults.showOn, "focus", "Retain default showOn" );
inp.datepicker( "option", { showOn: "both" } );
- equal( inst.settings.showOn, "both", "Change setting showOn" );
- equal( $.datepicker._get( inst, "showOn" ), "both", "Change instance showOn" );
- equal( $.datepicker._defaults.showOn, "focus", "Retain default showOn" );
+ assert.equal( inst.settings.showOn, "both", "Change setting showOn" );
+ assert.equal( $.datepicker._get( inst, "showOn" ), "both", "Change instance showOn" );
+ assert.equal( $.datepicker._defaults.showOn, "focus", "Retain default showOn" );
inp.datepicker( "option", "showOn", undefined );
- equal( inst.settings.showOn, null, "Clear setting showOn" );
- equal( $.datepicker._get( inst, "showOn" ), "focus", "Restore instance showOn" );
- equal( $.datepicker._defaults.showOn, "focus", "Retain default showOn" );
+ assert.equal( inst.settings.showOn, null, "Clear setting showOn" );
+ assert.equal( $.datepicker._get( inst, "showOn" ), "focus", "Restore instance showOn" );
+ assert.equal( $.datepicker._defaults.showOn, "focus", "Retain default showOn" );
// Get option
inp = testHelper.init( "#inp" );
- equal( inp.datepicker( "option", "showOn" ), "focus", "Initial setting showOn" );
+ assert.equal( inp.datepicker( "option", "showOn" ), "focus", "Initial setting showOn" );
inp.datepicker( "option", "showOn", "button" );
- equal( inp.datepicker( "option", "showOn" ), "button", "Change instance showOn" );
+ assert.equal( inp.datepicker( "option", "showOn" ), "button", "Change instance showOn" );
inp.datepicker( "option", "showOn", undefined );
- equal( inp.datepicker( "option", "showOn" ), "focus", "Reset instance showOn" );
- deepEqual( inp.datepicker( "option", "all" ), { showAnim: "" }, "Get instance settings" );
- deepEqual( inp.datepicker( "option", "defaults" ), $.datepicker._defaults,
+ assert.equal( inp.datepicker( "option", "showOn" ), "focus", "Reset instance showOn" );
+ assert.deepEqual( inp.datepicker( "option", "all" ), { showAnim: "" }, "Get instance settings" );
+ assert.deepEqual( inp.datepicker( "option", "defaults" ), $.datepicker._defaults,
"Get default settings" );
} );
-test( "disabled", function() {
- expect( 8 );
+QUnit.test( "disabled", function( assert ) {
+ assert.expect( 8 );
var inp = testHelper.init( "#inp" );
- ok( !inp.datepicker( "isDisabled" ), "Initially marked as enabled" );
- ok( !inp[ 0 ].disabled, "Field initially enabled" );
+ assert.ok( !inp.datepicker( "isDisabled" ), "Initially marked as enabled" );
+ assert.ok( !inp[ 0 ].disabled, "Field initially enabled" );
inp.datepicker( "option", "disabled", true );
- ok( inp.datepicker( "isDisabled" ), "Marked as disabled" );
- ok( inp[ 0 ].disabled, "Field now disabled" );
+ assert.ok( inp.datepicker( "isDisabled" ), "Marked as disabled" );
+ assert.ok( inp[ 0 ].disabled, "Field now disabled" );
inp.datepicker( "option", "disabled", false );
- ok( !inp.datepicker( "isDisabled" ), "Marked as enabled" );
- ok( !inp[ 0 ].disabled, "Field now enabled" );
+ assert.ok( !inp.datepicker( "isDisabled" ), "Marked as enabled" );
+ assert.ok( !inp[ 0 ].disabled, "Field now enabled" );
inp.datepicker( "destroy" );
inp = testHelper.init( "#inp", { disabled: true } );
- ok( inp.datepicker( "isDisabled" ), "Initially marked as disabled" );
- ok( inp[ 0 ].disabled, "Field initially disabled" );
+ assert.ok( inp.datepicker( "isDisabled" ), "Initially marked as disabled" );
+ assert.ok( inp[ 0 ].disabled, "Field initially disabled" );
} );
-test( "change", function() {
- expect( 12 );
+QUnit.test( "change", function( assert ) {
+ assert.expect( 12 );
var inp = testHelper.init( "#inp" ),
inst = $.data( inp[ 0 ], testHelper.PROP_NAME );
- equal( inst.settings.showOn, null, "Initial setting showOn" );
- equal( $.datepicker._get( inst, "showOn" ), "focus", "Initial instance showOn" );
- equal( $.datepicker._defaults.showOn, "focus", "Initial default showOn" );
+ assert.equal( inst.settings.showOn, null, "Initial setting showOn" );
+ assert.equal( $.datepicker._get( inst, "showOn" ), "focus", "Initial instance showOn" );
+ assert.equal( $.datepicker._defaults.showOn, "focus", "Initial default showOn" );
inp.datepicker( "change", "showOn", "button" );
- equal( inst.settings.showOn, "button", "Change setting showOn" );
- equal( $.datepicker._get( inst, "showOn" ), "button", "Change instance showOn" );
- equal( $.datepicker._defaults.showOn, "focus", "Retain default showOn" );
+ assert.equal( inst.settings.showOn, "button", "Change setting showOn" );
+ assert.equal( $.datepicker._get( inst, "showOn" ), "button", "Change instance showOn" );
+ assert.equal( $.datepicker._defaults.showOn, "focus", "Retain default showOn" );
inp.datepicker( "change", { showOn: "both" } );
- equal( inst.settings.showOn, "both", "Change setting showOn" );
- equal( $.datepicker._get( inst, "showOn" ), "both", "Change instance showOn" );
- equal( $.datepicker._defaults.showOn, "focus", "Retain default showOn" );
+ assert.equal( inst.settings.showOn, "both", "Change setting showOn" );
+ assert.equal( $.datepicker._get( inst, "showOn" ), "both", "Change instance showOn" );
+ assert.equal( $.datepicker._defaults.showOn, "focus", "Retain default showOn" );
inp.datepicker( "change", "showOn", undefined );
- equal( inst.settings.showOn, null, "Clear setting showOn" );
- equal( $.datepicker._get( inst, "showOn" ), "focus", "Restore instance showOn" );
- equal( $.datepicker._defaults.showOn, "focus", "Retain default showOn" );
+ assert.equal( inst.settings.showOn, null, "Clear setting showOn" );
+ assert.equal( $.datepicker._get( inst, "showOn" ), "focus", "Restore instance showOn" );
+ assert.equal( $.datepicker._defaults.showOn, "focus", "Retain default showOn" );
} );
( function() {
@@ -102,26 +103,27 @@ test( "change", function() {
return;
}
- asyncTest( "invocation", function() {
+ QUnit.test( "invocation", function( assert ) {
+ var ready = assert.async();
var button, image,
isOldIE = $.ui.ie && ( !document.documentMode || document.documentMode < 9 ),
body = $( "body" );
- expect( isOldIE ? 25 : 29 );
+ assert.expect( isOldIE ? 25 : 29 );
function step0() {
var inp = testHelper.initNewInput(),
dp = $( "#ui-datepicker-div" );
button = inp.siblings( "button" );
- ok( button.length === 0, "Focus - button absent" );
+ assert.ok( button.length === 0, "Focus - button absent" );
image = inp.siblings( "img" );
- ok( image.length === 0, "Focus - image absent" );
+ assert.ok( image.length === 0, "Focus - image absent" );
testHelper.onFocus( inp, function() {
- ok( dp.is( ":visible" ), "Focus - rendered on focus" );
+ assert.ok( dp.is( ":visible" ), "Focus - rendered on focus" );
inp.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
- ok( !dp.is( ":visible" ), "Focus - hidden on exit" );
+ assert.ok( !dp.is( ":visible" ), "Focus - hidden on exit" );
step1();
} );
}
@@ -132,9 +134,9 @@ test( "change", function() {
dp = $( "#ui-datepicker-div" );
testHelper.onFocus( inp, function() {
- ok( dp.is( ":visible" ), "Focus - rendered on focus" );
+ assert.ok( dp.is( ":visible" ), "Focus - rendered on focus" );
body.simulate( "mousedown", {} );
- ok( !dp.is( ":visible" ), "Focus - hidden on external click" );
+ assert.ok( !dp.is( ":visible" ), "Focus - hidden on external click" );
inp.datepicker( "hide" ).datepicker( "destroy" );
step2();
@@ -148,19 +150,19 @@ test( "change", function() {
} ),
dp = $( "#ui-datepicker-div" );
- ok( !dp.is( ":visible" ), "Button - initially hidden" );
+ assert.ok( !dp.is( ":visible" ), "Button - initially hidden" );
button = inp.siblings( "button" );
image = inp.siblings( "img" );
- ok( button.length === 1, "Button - button present" );
- ok( image.length === 0, "Button - image absent" );
- equal( button.text(), "Popup", "Button - button text" );
+ assert.ok( button.length === 1, "Button - button present" );
+ assert.ok( image.length === 0, "Button - image absent" );
+ assert.equal( button.text(), "Popup", "Button - button text" );
testHelper.onFocus( inp, function() {
- ok( !dp.is( ":visible" ), "Button - not rendered on focus" );
+ assert.ok( !dp.is( ":visible" ), "Button - not rendered on focus" );
button.trigger( "click" );
- ok( dp.is( ":visible" ), "Button - rendered on button click" );
+ assert.ok( dp.is( ":visible" ), "Button - rendered on button click" );
button.trigger( "click" );
- ok( !dp.is( ":visible" ), "Button - hidden on second button click" );
+ assert.ok( !dp.is( ":visible" ), "Button - hidden on second button click" );
inp.datepicker( "hide" ).datepicker( "destroy" );
step3();
@@ -176,20 +178,20 @@ test( "change", function() {
} ),
dp = $( "#ui-datepicker-div" );
- ok( !dp.is( ":visible" ), "Image button - initially hidden" );
+ assert.ok( !dp.is( ":visible" ), "Image button - initially hidden" );
button = inp.siblings( "button" );
- ok( button.length === 0, "Image button - button absent" );
+ assert.ok( button.length === 0, "Image button - button absent" );
image = inp.siblings( "img" );
- ok( image.length === 1, "Image button - image present" );
- ok( /images\/calendar\.gif$/.test( image.attr( "src" ) ), "Image button - image source" );
- equal( image.attr( "title" ), "Cal", "Image button - image text" );
+ assert.ok( image.length === 1, "Image button - image present" );
+ assert.ok( /images\/calendar\.gif$/.test( image.attr( "src" ) ), "Image button - image source" );
+ assert.equal( image.attr( "title" ), "Cal", "Image button - image text" );
testHelper.onFocus( inp, function() {
- ok( !dp.is( ":visible" ), "Image button - not rendered on focus" );
+ assert.ok( !dp.is( ":visible" ), "Image button - not rendered on focus" );
image.trigger( "click" );
- ok( dp.is( ":visible" ), "Image button - rendered on image click" );
+ assert.ok( dp.is( ":visible" ), "Image button - rendered on image click" );
image.trigger( "click" );
- ok( !dp.is( ":visible" ), "Image button - hidden on second image click" );
+ assert.ok( !dp.is( ":visible" ), "Image button - hidden on second image click" );
inp.datepicker( "hide" ).datepicker( "destroy" );
step4();
@@ -203,30 +205,30 @@ test( "change", function() {
} ),
dp = $( "#ui-datepicker-div" );
- ok( !dp.is( ":visible" ), "Both - initially hidden" );
+ assert.ok( !dp.is( ":visible" ), "Both - initially hidden" );
button = inp.siblings( "button" );
- ok( button.length === 1, "Both - button present" );
+ assert.ok( button.length === 1, "Both - button present" );
image = inp.siblings( "img" );
- ok( image.length === 0, "Both - image absent" );
+ assert.ok( image.length === 0, "Both - image absent" );
image = button.children( "img" );
- ok( image.length === 1, "Both - button image present" );
+ assert.ok( image.length === 1, "Both - button image present" );
// TODO: This test occasionally fails to focus in IE8 in BrowserStack
if ( !isOldIE ) {
testHelper.onFocus( inp, function() {
- ok( dp.is( ":visible" ), "Both - rendered on focus" );
+ assert.ok( dp.is( ":visible" ), "Both - rendered on focus" );
body.simulate( "mousedown", {} );
- ok( !dp.is( ":visible" ), "Both - hidden on external click" );
+ assert.ok( !dp.is( ":visible" ), "Both - hidden on external click" );
button.trigger( "click" );
- ok( dp.is( ":visible" ), "Both - rendered on button click" );
+ assert.ok( dp.is( ":visible" ), "Both - rendered on button click" );
button.trigger( "click" );
- ok( !dp.is( ":visible" ), "Both - hidden on second button click" );
+ assert.ok( !dp.is( ":visible" ), "Both - hidden on second button click" );
inp.datepicker( "hide" ).datepicker( "destroy" );
- start();
+ ready();
} );
} else {
- start();
+ ready();
}
}
@@ -234,136 +236,136 @@ test( "change", function() {
} );
} )();
-test( "otherMonths", function() {
- expect( 8 );
+QUnit.test( "otherMonths", function( assert ) {
+ assert.expect( 8 );
var inp = testHelper.init( "#inp" ),
pop = $( "#ui-datepicker-div" );
inp.val( "06/01/2009" ).datepicker( "show" );
- equal( pop.find( "tbody" ).text(),
+ assert.equal( pop.find( "tbody" ).text(),
- // support: IE <9, jQuery <1.8
+ // Support: IE <9, jQuery <1.8
// In IE7/8 with jQuery <1.8, encoded spaces behave in strange ways
$( "<span>\u00a0123456789101112131415161718192021222324252627282930\u00a0\u00a0\u00a0\u00a0</span>" ).text(),
"Other months - none" );
- ok( pop.find( "td:last *" ).length === 0, "Other months - no content" );
+ assert.ok( pop.find( "td:last *" ).length === 0, "Other months - no content" );
inp.datepicker( "hide" ).datepicker( "option", "showOtherMonths", true ).datepicker( "show" );
- equal( pop.find( "tbody" ).text(), "311234567891011121314151617181920212223242526272829301234",
+ assert.equal( pop.find( "tbody" ).text(), "311234567891011121314151617181920212223242526272829301234",
"Other months - show" );
- ok( pop.find( "td:last span" ).length === 1, "Other months - span content" );
+ assert.ok( pop.find( "td:last span" ).length === 1, "Other months - span content" );
inp.datepicker( "hide" ).datepicker( "option", "selectOtherMonths", true ).datepicker( "show" );
- equal( pop.find( "tbody" ).text(), "311234567891011121314151617181920212223242526272829301234",
+ assert.equal( pop.find( "tbody" ).text(), "311234567891011121314151617181920212223242526272829301234",
"Other months - select" );
- ok( pop.find( "td:last a" ).length === 1, "Other months - link content" );
+ assert.ok( pop.find( "td:last a" ).length === 1, "Other months - link content" );
inp.datepicker( "hide" ).datepicker( "option", "showOtherMonths", false ).datepicker( "show" );
- equal( pop.find( "tbody" ).text(),
+ assert.equal( pop.find( "tbody" ).text(),
- // support: IE <9, jQuery <1.8
+ // Support: IE <9, jQuery <1.8
// In IE7/8 with jQuery <1.8, encoded spaces behave in strange ways
$( "<span>\u00a0123456789101112131415161718192021222324252627282930\u00a0\u00a0\u00a0\u00a0</span>" ).text(),
"Other months - none" );
- ok( pop.find( "td:last *" ).length === 0, "Other months - no content" );
+ assert.ok( pop.find( "td:last *" ).length === 0, "Other months - no content" );
} );
-test( "defaultDate", function() {
- expect( 16 );
+QUnit.test( "defaultDate", function( assert ) {
+ assert.expect( 16 );
var inp = testHelper.init( "#inp" ),
date = new Date();
inp.val( "" ).datepicker( "show" ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date, "Default date null" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Default date null" );
// Numeric values
inp.datepicker( "option", { defaultDate: -2 } ).
datepicker( "hide" ).val( "" ).datepicker( "show" ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
date.setDate( date.getDate() - 2 );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date, "Default date -2" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Default date -2" );
date = new Date();
inp.datepicker( "option", { defaultDate: 3 } ).
datepicker( "hide" ).val( "" ).datepicker( "show" ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
date.setDate( date.getDate() + 3 );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date, "Default date 3" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Default date 3" );
date = new Date();
inp.datepicker( "option", { defaultDate: 1 / "a" } ).
datepicker( "hide" ).val( "" ).datepicker( "show" ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date, "Default date NaN" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Default date NaN" );
// String offset values
inp.datepicker( "option", { defaultDate: "-1d" } ).
datepicker( "hide" ).val( "" ).datepicker( "show" ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
date.setDate( date.getDate() - 1 );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date, "Default date -1d" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Default date -1d" );
inp.datepicker( "option", { defaultDate: "+3D" } ).
datepicker( "hide" ).val( "" ).datepicker( "show" ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
date.setDate( date.getDate() + 4 );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date, "Default date +3D" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Default date +3D" );
inp.datepicker( "option", { defaultDate: " -2 w " } ).
datepicker( "hide" ).val( "" ).datepicker( "show" ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
date = new Date();
date.setDate( date.getDate() - 14 );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date, "Default date -2 w" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Default date -2 w" );
inp.datepicker( "option", { defaultDate: "+1 W" } ).
datepicker( "hide" ).val( "" ).datepicker( "show" ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
date.setDate( date.getDate() + 21 );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date, "Default date +1 W" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Default date +1 W" );
inp.datepicker( "option", { defaultDate: " -1 m " } ).
datepicker( "hide" ).val( "" ).datepicker( "show" ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
date = testHelper.addMonths( new Date(), -1 );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date, "Default date -1 m" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Default date -1 m" );
inp.datepicker( "option", { defaultDate: "+2M" } ).
datepicker( "hide" ).val( "" ).datepicker( "show" ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
date = testHelper.addMonths( new Date(), 2 );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date, "Default date +2M" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Default date +2M" );
inp.datepicker( "option", { defaultDate: "-2y" } ).
datepicker( "hide" ).val( "" ).datepicker( "show" ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
date = new Date();
date.setFullYear( date.getFullYear() - 2 );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date, "Default date -2y" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Default date -2y" );
inp.datepicker( "option", { defaultDate: "+1 Y " } ).
datepicker( "hide" ).val( "" ).datepicker( "show" ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
date.setFullYear( date.getFullYear() + 3 );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date, "Default date +1 Y" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Default date +1 Y" );
inp.datepicker( "option", { defaultDate: "+1M +10d" } ).
datepicker( "hide" ).val( "" ).datepicker( "show" ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
date = testHelper.addMonths( new Date(), 1 );
date.setDate( date.getDate() + 10 );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date, "Default date +1M +10d" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Default date +1M +10d" );
// String date values
inp.datepicker( "option", { defaultDate: "07/04/2007" } ).
datepicker( "hide" ).val( "" ).datepicker( "show" ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
date = new Date( 2007, 7 - 1, 4 );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date, "Default date 07/04/2007" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Default date 07/04/2007" );
inp.datepicker( "option", { dateFormat: "yy-mm-dd", defaultDate: "2007-04-02" } ).
datepicker( "hide" ).val( "" ).datepicker( "show" ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
date = new Date( 2007, 4 - 1, 2 );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date, "Default date 2007-04-02" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Default date 2007-04-02" );
// Date value
date = new Date( 2007, 1 - 1, 26 );
inp.datepicker( "option", { dateFormat: "mm/dd/yy", defaultDate: date } ).
datepicker( "hide" ).val( "" ).datepicker( "show" ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date, "Default date 01/26/2007" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Default date 01/26/2007" );
} );
-test( "miscellaneous", function() {
- expect( 19 );
+QUnit.test( "miscellaneous", function( assert ) {
+ assert.expect( 19 );
var curYear, longNames, shortNames, date,
dp = $( "#ui-datepicker-div" ),
inp = testHelper.init( "#inp" );
@@ -379,54 +381,54 @@ test( "miscellaneous", function() {
}
curYear = new Date().getFullYear();
inp.val( "02/04/2008" ).datepicker( "show" );
- equal( dp.find( ".ui-datepicker-year" ).text(), "2008", "Year range - read-only default" );
+ assert.equal( dp.find( ".ui-datepicker-year" ).text(), "2008", "Year range - read-only default" );
inp.datepicker( "hide" ).datepicker( "option", { changeYear: true } ).datepicker( "show" );
- equal( dp.find( ".ui-datepicker-year" ).text(), genRange( 2008 - 10, 21 ), "Year range - changeable default" );
+ assert.equal( dp.find( ".ui-datepicker-year" ).text(), genRange( 2008 - 10, 21 ), "Year range - changeable default" );
inp.datepicker( "hide" ).datepicker( "option", { yearRange: "c-6:c+2", changeYear: true } ).datepicker( "show" );
- equal( dp.find( ".ui-datepicker-year" ).text(), genRange( 2008 - 6, 9 ), "Year range - c-6:c+2" );
+ assert.equal( dp.find( ".ui-datepicker-year" ).text(), genRange( 2008 - 6, 9 ), "Year range - c-6:c+2" );
inp.datepicker( "hide" ).datepicker( "option", { yearRange: "2000:2010", changeYear: true } ).datepicker( "show" );
- equal( dp.find( ".ui-datepicker-year" ).text(), genRange( 2000, 11 ), "Year range - 2000:2010" );
+ assert.equal( dp.find( ".ui-datepicker-year" ).text(), genRange( 2000, 11 ), "Year range - 2000:2010" );
inp.datepicker( "hide" ).datepicker( "option", { yearRange: "-5:+3", changeYear: true } ).datepicker( "show" );
- equal( dp.find( ".ui-datepicker-year" ).text(), genRange( curYear - 5, 9 ), "Year range - -5:+3" );
+ assert.equal( dp.find( ".ui-datepicker-year" ).text(), genRange( curYear - 5, 9 ), "Year range - -5:+3" );
inp.datepicker( "hide" ).datepicker( "option", { yearRange: "2000:-5", changeYear: true } ).datepicker( "show" );
- equal( dp.find( ".ui-datepicker-year" ).text(), genRange( 2000, curYear - 2004 ), "Year range - 2000:-5" );
+ assert.equal( dp.find( ".ui-datepicker-year" ).text(), genRange( 2000, curYear - 2004 ), "Year range - 2000:-5" );
inp.datepicker( "hide" ).datepicker( "option", { yearRange: "", changeYear: true } ).datepicker( "show" );
- equal( dp.find( ".ui-datepicker-year" ).text(), genRange( curYear, 1 ), "Year range - -6:+2" );
+ assert.equal( dp.find( ".ui-datepicker-year" ).text(), genRange( curYear, 1 ), "Year range - -6:+2" );
// Navigation as date format
inp.datepicker( "option", { showButtonPanel: true } );
- equal( dp.find( ".ui-datepicker-prev" ).text(), "Prev", "Navigation prev - default" );
- equal( dp.find( ".ui-datepicker-current" ).text(), "Today", "Navigation current - default" );
- equal( dp.find( ".ui-datepicker-next" ).text(), "Next", "Navigation next - default" );
+ assert.equal( dp.find( ".ui-datepicker-prev" ).text(), "Prev", "Navigation prev - default" );
+ assert.equal( dp.find( ".ui-datepicker-current" ).text(), "Today", "Navigation current - default" );
+ assert.equal( dp.find( ".ui-datepicker-next" ).text(), "Next", "Navigation next - default" );
inp.datepicker( "hide" ).datepicker( "option", { navigationAsDateFormat: true, prevText: "< M", currentText: "MM", nextText: "M >" } ).
val( "02/04/2008" ).datepicker( "show" );
longNames = $.datepicker.regional[ "" ].monthNames;
shortNames = $.datepicker.regional[ "" ].monthNamesShort;
date = new Date();
- equal( dp.find( ".ui-datepicker-prev" ).text(), "< " + shortNames[ 0 ], "Navigation prev - as date format" );
- equal( dp.find( ".ui-datepicker-current" ).text(),
+ assert.equal( dp.find( ".ui-datepicker-prev" ).text(), "< " + shortNames[ 0 ], "Navigation prev - as date format" );
+ assert.equal( dp.find( ".ui-datepicker-current" ).text(),
longNames[ date.getMonth() ], "Navigation current - as date format" );
- equal( dp.find( ".ui-datepicker-next" ).text(),
+ assert.equal( dp.find( ".ui-datepicker-next" ).text(),
shortNames[ 2 ] + " >", "Navigation next - as date format" );
inp.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
- equal( dp.find( ".ui-datepicker-prev" ).text(),
+ assert.equal( dp.find( ".ui-datepicker-prev" ).text(),
"< " + shortNames[ 1 ], "Navigation prev - as date format + pgdn" );
- equal( dp.find( ".ui-datepicker-current" ).text(),
+ assert.equal( dp.find( ".ui-datepicker-current" ).text(),
longNames[ date.getMonth() ], "Navigation current - as date format + pgdn" );
- equal( dp.find( ".ui-datepicker-next" ).text(),
+ assert.equal( dp.find( ".ui-datepicker-next" ).text(),
shortNames[ 3 ] + " >", "Navigation next - as date format + pgdn" );
inp.datepicker( "hide" ).datepicker( "option", { gotoCurrent: true } ).
val( "02/04/2008" ).datepicker( "show" );
- equal( dp.find( ".ui-datepicker-prev" ).text(),
+ assert.equal( dp.find( ".ui-datepicker-prev" ).text(),
"< " + shortNames[ 0 ], "Navigation prev - as date format + goto current" );
- equal( dp.find( ".ui-datepicker-current" ).text(),
+ assert.equal( dp.find( ".ui-datepicker-current" ).text(),
longNames[ 1 ], "Navigation current - as date format + goto current" );
- equal( dp.find( ".ui-datepicker-next" ).text(),
+ assert.equal( dp.find( ".ui-datepicker-next" ).text(),
shortNames[ 2 ] + " >", "Navigation next - as date format + goto current" );
} );
-test( "minMax", function() {
- expect( 23 );
+QUnit.test( "minMax", function( assert ) {
+ assert.expect( 23 );
var date,
inp = testHelper.init( "#inp" ),
dp = $( "#ui-datepicker-div" ),
@@ -437,45 +439,45 @@ test( "minMax", function() {
inp.val( "06/04/2008" ).datepicker( "show" );
inp.simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP } ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- testHelper.equalsDate( inp.datepicker( "getDate" ), lastYear,
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), lastYear,
"Min/max - null, null - ctrl+pgup" );
inp.val( "06/04/2008" ).datepicker( "show" );
inp.simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN } ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- testHelper.equalsDate( inp.datepicker( "getDate" ), nextYear,
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), nextYear,
"Min/max - null, null - ctrl+pgdn" );
inp.datepicker( "option", { minDate: minDate } ).
datepicker( "hide" ).val( "06/04/2008" ).datepicker( "show" );
inp.simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP } ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- testHelper.equalsDate( inp.datepicker( "getDate" ), minDate,
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), minDate,
"Min/max - 02/29/2008, null - ctrl+pgup" );
inp.val( "06/04/2008" ).datepicker( "show" );
inp.simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN } ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- testHelper.equalsDate( inp.datepicker( "getDate" ), nextYear,
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), nextYear,
"Min/max - 02/29/2008, null - ctrl+pgdn" );
inp.datepicker( "option", { maxDate: maxDate } ).
datepicker( "hide" ).val( "06/04/2008" ).datepicker( "show" );
inp.simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP } ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- testHelper.equalsDate( inp.datepicker( "getDate" ), minDate,
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), minDate,
"Min/max - 02/29/2008, 12/07/2008 - ctrl+pgup" );
inp.val( "06/04/2008" ).datepicker( "show" );
inp.simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN } ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- testHelper.equalsDate( inp.datepicker( "getDate" ), maxDate,
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), maxDate,
"Min/max - 02/29/2008, 12/07/2008 - ctrl+pgdn" );
inp.datepicker( "option", { minDate: null } ).
datepicker( "hide" ).val( "06/04/2008" ).datepicker( "show" );
inp.simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP } ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- testHelper.equalsDate( inp.datepicker( "getDate" ), lastYear,
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), lastYear,
"Min/max - null, 12/07/2008 - ctrl+pgup" );
inp.val( "06/04/2008" ).datepicker( "show" );
inp.simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN } ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- testHelper.equalsDate( inp.datepicker( "getDate" ), maxDate,
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), maxDate,
"Min/max - null, 12/07/2008 - ctrl+pgdn" );
// Relative dates
@@ -485,114 +487,114 @@ test( "minMax", function() {
datepicker( "hide" ).val( "" ).datepicker( "show" );
inp.simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP } ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date,
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date,
"Min/max - -1w, +1 M +10 D - ctrl+pgup" );
date = testHelper.addMonths( new Date(), 1 );
date.setDate( date.getDate() + 10 );
inp.val( "" ).datepicker( "show" );
inp.simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN } ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date,
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date,
"Min/max - -1w, +1 M +10 D - ctrl+pgdn" );
// With existing date
inp = testHelper.init( "#inp" );
inp.val( "06/04/2008" ).datepicker( "option", { minDate: minDate } );
- testHelper.equalsDate( inp.datepicker( "getDate" ), new Date( 2008, 6 - 1, 4 ), "Min/max - setDate > min" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2008, 6 - 1, 4 ), "Min/max - setDate > min" );
inp.datepicker( "option", { minDate: null } ).val( "01/04/2008" ).datepicker( "option", { minDate: minDate } );
- testHelper.equalsDate( inp.datepicker( "getDate" ), minDate, "Min/max - setDate < min" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), minDate, "Min/max - setDate < min" );
inp.datepicker( "option", { minDate: null } ).val( "06/04/2008" ).datepicker( "option", { maxDate: maxDate } );
- testHelper.equalsDate( inp.datepicker( "getDate" ), new Date( 2008, 6 - 1, 4 ), "Min/max - setDate < max" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2008, 6 - 1, 4 ), "Min/max - setDate < max" );
inp.datepicker( "option", { maxDate: null } ).val( "01/04/2009" ).datepicker( "option", { maxDate: maxDate } );
- testHelper.equalsDate( inp.datepicker( "getDate" ), maxDate, "Min/max - setDate > max" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), maxDate, "Min/max - setDate > max" );
inp.datepicker( "option", { maxDate: null } ).val( "01/04/2008" ).datepicker( "option", { minDate: minDate, maxDate: maxDate } );
- testHelper.equalsDate( inp.datepicker( "getDate" ), minDate, "Min/max - setDate < min" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), minDate, "Min/max - setDate < min" );
inp.datepicker( "option", { maxDate: null } ).val( "06/04/2008" ).datepicker( "option", { minDate: minDate, maxDate: maxDate } );
- testHelper.equalsDate( inp.datepicker( "getDate" ), new Date( 2008, 6 - 1, 4 ), "Min/max - setDate > min, < max" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2008, 6 - 1, 4 ), "Min/max - setDate > min, < max" );
inp.datepicker( "option", { maxDate: null } ).val( "01/04/2009" ).datepicker( "option", { minDate: minDate, maxDate: maxDate } );
- testHelper.equalsDate( inp.datepicker( "getDate" ), maxDate, "Min/max - setDate > max" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), maxDate, "Min/max - setDate > max" );
inp.datepicker( "option", { yearRange: "-0:+1" } ).val( "01/01/" + new Date().getFullYear() );
- ok( dp.find( ".ui-datepicker-prev" ).hasClass( "ui-state-disabled" ), "Year Range Test - previous button disabled at 1/1/minYear" );
+ assert.ok( dp.find( ".ui-datepicker-prev" ).hasClass( "ui-state-disabled" ), "Year Range Test - previous button disabled at 1/1/minYear" );
inp.datepicker( "setDate", "12/30/" + new Date().getFullYear() );
- ok( dp.find( ".ui-datepicker-next" ).hasClass( "ui-state-disabled" ), "Year Range Test - next button disabled at 12/30/maxYear" );
+ assert.ok( dp.find( ".ui-datepicker-next" ).hasClass( "ui-state-disabled" ), "Year Range Test - next button disabled at 12/30/maxYear" );
inp.val( "" ).datepicker( "option", {
minDate: new Date( 1900, 0, 1 ),
maxDate: "-7Y",
yearRange: "1900:-7"
} );
- ok( dp.find( ".ui-datepicker-next" ).hasClass( "ui-state-disabled" ), "Year Range Test - relative - next button disabled" );
- ok( !dp.find( ".ui-datepicker-prev" ).hasClass( "ui-state-disabled" ), "Year Range Test - relative - prev button enabled" );
+ assert.ok( dp.find( ".ui-datepicker-next" ).hasClass( "ui-state-disabled" ), "Year Range Test - relative - next button disabled" );
+ assert.ok( !dp.find( ".ui-datepicker-prev" ).hasClass( "ui-state-disabled" ), "Year Range Test - relative - prev button enabled" );
inp.val( "" ).datepicker( "option", {
minDate: new Date( 1900, 0, 1 ),
maxDate: "1/25/2007",
yearRange: "1900:2007"
} );
- ok( dp.find( ".ui-datepicker-next" ).hasClass( "ui-state-disabled" ), "Year Range Test - absolute - next button disabled" );
- ok( !dp.find( ".ui-datepicker-prev" ).hasClass( "ui-state-disabled" ), "Year Range Test - absolute - prev button enabled" );
+ assert.ok( dp.find( ".ui-datepicker-next" ).hasClass( "ui-state-disabled" ), "Year Range Test - absolute - next button disabled" );
+ assert.ok( !dp.find( ".ui-datepicker-prev" ).hasClass( "ui-state-disabled" ), "Year Range Test - absolute - prev button enabled" );
} );
-test( "setDate", function() {
- expect( 24 );
+QUnit.test( "setDate", function( assert ) {
+ assert.expect( 24 );
var inl, alt, minDate, maxDate, dateAndTimeToSet, dateAndTimeClone,
inp = testHelper.init( "#inp" ),
date1 = new Date( 2008, 6 - 1, 4 ),
date2 = new Date();
- ok( inp.datepicker( "getDate" ) == null, "Set date - default" );
+ assert.ok( inp.datepicker( "getDate" ) == null, "Set date - default" );
inp.datepicker( "setDate", date1 );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date1, "Set date - 2008-06-04" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date1, "Set date - 2008-06-04" );
date1 = new Date();
date1.setDate( date1.getDate() + 7 );
inp.datepicker( "setDate", +7 );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date1, "Set date - +7" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date1, "Set date - +7" );
date2.setFullYear( date2.getFullYear() + 2 );
inp.datepicker( "setDate", "+2y" );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date2, "Set date - +2y" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date2, "Set date - +2y" );
inp.datepicker( "setDate", date1, date2 );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date1, "Set date - two dates" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date1, "Set date - two dates" );
inp.datepicker( "setDate" );
- ok( inp.datepicker( "getDate" ) == null, "Set date - null" );
+ assert.ok( inp.datepicker( "getDate" ) == null, "Set date - null" );
// Relative to current date
date1 = new Date();
date1.setDate( date1.getDate() + 7 );
inp.datepicker( "setDate", "c +7" );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date1, "Set date - c +7" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date1, "Set date - c +7" );
date1.setDate( date1.getDate() + 7 );
inp.datepicker( "setDate", "c+7" );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date1, "Set date - c+7" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date1, "Set date - c+7" );
date1.setDate( date1.getDate() - 21 );
inp.datepicker( "setDate", "c -3 w" );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date1, "Set date - c -3 w" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date1, "Set date - c -3 w" );
// Inline
inl = testHelper.init( "#inl" );
date1 = new Date( 2008, 6 - 1, 4 );
date2 = new Date();
- testHelper.equalsDate( inl.datepicker( "getDate" ), date2, "Set date inline - default" );
+ testHelper.equalsDate( assert, inl.datepicker( "getDate" ), date2, "Set date inline - default" );
inl.datepicker( "setDate", date1 );
- testHelper.equalsDate( inl.datepicker( "getDate" ), date1, "Set date inline - 2008-06-04" );
+ testHelper.equalsDate( assert, inl.datepicker( "getDate" ), date1, "Set date inline - 2008-06-04" );
date1 = new Date();
date1.setDate( date1.getDate() + 7 );
inl.datepicker( "setDate", +7 );
- testHelper.equalsDate( inl.datepicker( "getDate" ), date1, "Set date inline - +7" );
+ testHelper.equalsDate( assert, inl.datepicker( "getDate" ), date1, "Set date inline - +7" );
date2.setFullYear( date2.getFullYear() + 2 );
inl.datepicker( "setDate", "+2y" );
- testHelper.equalsDate( inl.datepicker( "getDate" ), date2, "Set date inline - +2y" );
+ testHelper.equalsDate( assert, inl.datepicker( "getDate" ), date2, "Set date inline - +2y" );
inl.datepicker( "setDate", date1, date2 );
- testHelper.equalsDate( inl.datepicker( "getDate" ), date1, "Set date inline - two dates" );
+ testHelper.equalsDate( assert, inl.datepicker( "getDate" ), date1, "Set date inline - two dates" );
inl.datepicker( "setDate" );
- ok( inl.datepicker( "getDate" ) == null, "Set date inline - null" );
+ assert.ok( inl.datepicker( "getDate" ) == null, "Set date inline - null" );
// Alternate field
alt = $( "#alt" );
inp.datepicker( "option", { altField: "#alt", altFormat: "yy-mm-dd" } );
date1 = new Date( 2008, 6 - 1, 4 );
inp.datepicker( "setDate", date1 );
- equal( inp.val(), "06/04/2008", "Set date alternate - 06/04/2008" );
- equal( alt.val(), "2008-06-04", "Set date alternate - 2008-06-04" );
+ assert.equal( inp.val(), "06/04/2008", "Set date alternate - 06/04/2008" );
+ assert.equal( alt.val(), "2008-06-04", "Set date alternate - 2008-06-04" );
// With minimum/maximum
inp = testHelper.init( "#inp" );
@@ -601,25 +603,25 @@ test( "setDate", function() {
minDate = new Date( 2008, 2 - 1, 29 );
maxDate = new Date( 2008, 3 - 1, 28 );
inp.val( "" ).datepicker( "option", { minDate: minDate } ).datepicker( "setDate", date2 );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date2, "Set date min/max - setDate > min" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date2, "Set date min/max - setDate > min" );
inp.datepicker( "setDate", date1 );
- testHelper.equalsDate( inp.datepicker( "getDate" ), minDate, "Set date min/max - setDate < min" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), minDate, "Set date min/max - setDate < min" );
inp.val( "" ).datepicker( "option", { maxDate: maxDate, minDate: null } ).datepicker( "setDate", date1 );
- testHelper.equalsDate( inp.datepicker( "getDate" ), date1, "Set date min/max - setDate < max" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date1, "Set date min/max - setDate < max" );
inp.datepicker( "setDate", date2 );
- testHelper.equalsDate( inp.datepicker( "getDate" ), maxDate, "Set date min/max - setDate > max" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), maxDate, "Set date min/max - setDate > max" );
inp.val( "" ).datepicker( "option", { minDate: minDate } ).datepicker( "setDate", date1 );
- testHelper.equalsDate( inp.datepicker( "getDate" ), minDate, "Set date min/max - setDate < min" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), minDate, "Set date min/max - setDate < min" );
inp.datepicker( "setDate", date2 );
- testHelper.equalsDate( inp.datepicker( "getDate" ), maxDate, "Set date min/max - setDate > max" );
+ testHelper.equalsDate( assert, inp.datepicker( "getDate" ), maxDate, "Set date min/max - setDate > max" );
dateAndTimeToSet = new Date( 2008, 3 - 1, 28, 1, 11, 0 );
dateAndTimeClone = new Date( 2008, 3 - 1, 28, 1, 11, 0 );
inp.datepicker( "setDate", dateAndTimeToSet );
- equal( dateAndTimeToSet.getTime(), dateAndTimeClone.getTime(), "Date object passed should not be changed by setDate" );
+ assert.equal( dateAndTimeToSet.getTime(), dateAndTimeClone.getTime(), "Date object passed should not be changed by setDate" );
} );
-test( "altField", function() {
- expect( 10 );
+QUnit.test( "altField", function( assert ) {
+ assert.expect( 10 );
var inp = testHelper.init( "#inp" ),
alt = $( "#alt" );
@@ -627,164 +629,164 @@ test( "altField", function() {
alt.val( "" );
inp.val( "06/04/2008" ).datepicker( "show" );
inp.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- equal( inp.val(), "06/04/2008", "Alt field - dp - enter" );
- equal( alt.val(), "", "Alt field - alt not set" );
+ assert.equal( inp.val(), "06/04/2008", "Alt field - dp - enter" );
+ assert.equal( alt.val(), "", "Alt field - alt not set" );
// Alternate field set
alt.val( "" );
inp.datepicker( "option", { altField: "#alt", altFormat: "yy-mm-dd" } ).
val( "06/04/2008" ).datepicker( "show" );
inp.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- equal( inp.val(), "06/04/2008", "Alt field - dp - enter" );
- equal( alt.val(), "2008-06-04", "Alt field - alt - enter" );
+ assert.equal( inp.val(), "06/04/2008", "Alt field - dp - enter" );
+ assert.equal( alt.val(), "2008-06-04", "Alt field - alt - enter" );
// Move from initial date
alt.val( "" );
inp.val( "06/04/2008" ).datepicker( "show" );
inp.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ).
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- equal( inp.val(), "07/04/2008", "Alt field - dp - pgdn" );
- equal( alt.val(), "2008-07-04", "Alt field - alt - pgdn" );
+ assert.equal( inp.val(), "07/04/2008", "Alt field - dp - pgdn" );
+ assert.equal( alt.val(), "2008-07-04", "Alt field - alt - pgdn" );
// Alternate field set - closed
alt.val( "" );
inp.val( "06/04/2008" ).datepicker( "show" );
inp.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ).
simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
- equal( inp.val(), "06/04/2008", "Alt field - dp - pgdn/esc" );
- equal( alt.val(), "", "Alt field - alt - pgdn/esc" );
+ assert.equal( inp.val(), "06/04/2008", "Alt field - dp - pgdn/esc" );
+ assert.equal( alt.val(), "", "Alt field - alt - pgdn/esc" );
// Clear date and alternate
alt.val( "" );
inp.val( "06/04/2008" ).datepicker( "show" );
inp.simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.END } );
- equal( inp.val(), "", "Alt field - dp - ctrl+end" );
- equal( alt.val(), "", "Alt field - alt - ctrl+end" );
+ assert.equal( inp.val(), "", "Alt field - dp - ctrl+end" );
+ assert.equal( alt.val(), "", "Alt field - alt - ctrl+end" );
} );
-test( "autoSize", function() {
- expect( 15 );
+QUnit.test( "autoSize", function( assert ) {
+ assert.expect( 15 );
var inp = testHelper.init( "#inp" );
- equal( inp.prop( "size" ), 20, "Auto size - default" );
+ assert.equal( inp.prop( "size" ), 20, "Auto size - default" );
inp.datepicker( "option", "autoSize", true );
- equal( inp.prop( "size" ), 10, "Auto size - mm/dd/yy" );
+ assert.equal( inp.prop( "size" ), 10, "Auto size - mm/dd/yy" );
inp.datepicker( "option", "dateFormat", "m/d/yy" );
- equal( inp.prop( "size" ), 10, "Auto size - m/d/yy" );
+ assert.equal( inp.prop( "size" ), 10, "Auto size - m/d/yy" );
inp.datepicker( "option", "dateFormat", "D M d yy" );
- equal( inp.prop( "size" ), 15, "Auto size - D M d yy" );
+ assert.equal( inp.prop( "size" ), 15, "Auto size - D M d yy" );
inp.datepicker( "option", "dateFormat", "DD, MM dd, yy" );
- equal( inp.prop( "size" ), 29, "Auto size - DD, MM dd, yy" );
+ assert.equal( inp.prop( "size" ), 29, "Auto size - DD, MM dd, yy" );
// French
inp.datepicker( "option", $.extend( { autoSize: false }, $.datepicker.regional.fr ) );
- equal( inp.prop( "size" ), 29, "Auto size - fr - default" );
+ assert.equal( inp.prop( "size" ), 29, "Auto size - fr - default" );
inp.datepicker( "option", "autoSize", true );
- equal( inp.prop( "size" ), 10, "Auto size - fr - dd/mm/yy" );
+ assert.equal( inp.prop( "size" ), 10, "Auto size - fr - dd/mm/yy" );
inp.datepicker( "option", "dateFormat", "m/d/yy" );
- equal( inp.prop( "size" ), 10, "Auto size - fr - m/d/yy" );
+ assert.equal( inp.prop( "size" ), 10, "Auto size - fr - m/d/yy" );
inp.datepicker( "option", "dateFormat", "D M d yy" );
- equal( inp.prop( "size" ), 18, "Auto size - fr - D M d yy" );
+ assert.equal( inp.prop( "size" ), 18, "Auto size - fr - D M d yy" );
inp.datepicker( "option", "dateFormat", "DD, MM dd, yy" );
- equal( inp.prop( "size" ), 28, "Auto size - fr - DD, MM dd, yy" );
+ assert.equal( inp.prop( "size" ), 28, "Auto size - fr - DD, MM dd, yy" );
// Hebrew
inp.datepicker( "option", $.extend( { autoSize: false }, $.datepicker.regional.he ) );
- equal( inp.prop( "size" ), 28, "Auto size - he - default" );
+ assert.equal( inp.prop( "size" ), 28, "Auto size - he - default" );
inp.datepicker( "option", "autoSize", true );
- equal( inp.prop( "size" ), 10, "Auto size - he - dd/mm/yy" );
+ assert.equal( inp.prop( "size" ), 10, "Auto size - he - dd/mm/yy" );
inp.datepicker( "option", "dateFormat", "m/d/yy" );
- equal( inp.prop( "size" ), 10, "Auto size - he - m/d/yy" );
+ assert.equal( inp.prop( "size" ), 10, "Auto size - he - m/d/yy" );
inp.datepicker( "option", "dateFormat", "D M d yy" );
- equal( inp.prop( "size" ), 16, "Auto size - he - D M d yy" );
+ assert.equal( inp.prop( "size" ), 16, "Auto size - he - D M d yy" );
inp.datepicker( "option", "dateFormat", "DD, MM dd, yy" );
- equal( inp.prop( "size" ), 23, "Auto size - he - DD, MM dd, yy" );
+ assert.equal( inp.prop( "size" ), 23, "Auto size - he - DD, MM dd, yy" );
} );
-test( "daylightSaving", function() {
- expect( 25 );
+QUnit.test( "daylightSaving", function( assert ) {
+ assert.expect( 25 );
var inp = testHelper.init( "#inp" ),
dp = $( "#ui-datepicker-div" );
- ok( true, "Daylight saving - " + new Date() );
+ assert.ok( true, "Daylight saving - " + new Date() );
// Australia, Sydney - AM change, southern hemisphere
inp.val( "04/01/2008" ).datepicker( "show" );
$( ".ui-datepicker-calendar td:eq(6) a", dp ).simulate( "click" );
- equal( inp.val(), "04/05/2008", "Daylight saving - Australia 04/05/2008" );
+ assert.equal( inp.val(), "04/05/2008", "Daylight saving - Australia 04/05/2008" );
inp.val( "04/01/2008" ).datepicker( "show" );
$( ".ui-datepicker-calendar td:eq(7) a", dp ).simulate( "click" );
- equal( inp.val(), "04/06/2008", "Daylight saving - Australia 04/06/2008" );
+ assert.equal( inp.val(), "04/06/2008", "Daylight saving - Australia 04/06/2008" );
inp.val( "04/01/2008" ).datepicker( "show" );
$( ".ui-datepicker-calendar td:eq(8) a", dp ).simulate( "click" );
- equal( inp.val(), "04/07/2008", "Daylight saving - Australia 04/07/2008" );
+ assert.equal( inp.val(), "04/07/2008", "Daylight saving - Australia 04/07/2008" );
inp.val( "10/01/2008" ).datepicker( "show" );
$( ".ui-datepicker-calendar td:eq(6) a", dp ).simulate( "click" );
- equal( inp.val(), "10/04/2008", "Daylight saving - Australia 10/04/2008" );
+ assert.equal( inp.val(), "10/04/2008", "Daylight saving - Australia 10/04/2008" );
inp.val( "10/01/2008" ).datepicker( "show" );
$( ".ui-datepicker-calendar td:eq(7) a", dp ).simulate( "click" );
- equal( inp.val(), "10/05/2008", "Daylight saving - Australia 10/05/2008" );
+ assert.equal( inp.val(), "10/05/2008", "Daylight saving - Australia 10/05/2008" );
inp.val( "10/01/2008" ).datepicker( "show" );
$( ".ui-datepicker-calendar td:eq(8) a", dp ).simulate( "click" );
- equal( inp.val(), "10/06/2008", "Daylight saving - Australia 10/06/2008" );
+ assert.equal( inp.val(), "10/06/2008", "Daylight saving - Australia 10/06/2008" );
// Brasil, Brasilia - midnight change, southern hemisphere
inp.val( "02/01/2008" ).datepicker( "show" );
$( ".ui-datepicker-calendar td:eq(20) a", dp ).simulate( "click" );
- equal( inp.val(), "02/16/2008", "Daylight saving - Brasil 02/16/2008" );
+ assert.equal( inp.val(), "02/16/2008", "Daylight saving - Brasil 02/16/2008" );
inp.val( "02/01/2008" ).datepicker( "show" );
$( ".ui-datepicker-calendar td:eq(21) a", dp ).simulate( "click" );
- equal( inp.val(), "02/17/2008", "Daylight saving - Brasil 02/17/2008" );
+ assert.equal( inp.val(), "02/17/2008", "Daylight saving - Brasil 02/17/2008" );
inp.val( "02/01/2008" ).datepicker( "show" );
$( ".ui-datepicker-calendar td:eq(22) a", dp ).simulate( "click" );
- equal( inp.val(), "02/18/2008", "Daylight saving - Brasil 02/18/2008" );
+ assert.equal( inp.val(), "02/18/2008", "Daylight saving - Brasil 02/18/2008" );
inp.val( "10/01/2008" ).datepicker( "show" );
$( ".ui-datepicker-calendar td:eq(13) a", dp ).simulate( "click" );
- equal( inp.val(), "10/11/2008", "Daylight saving - Brasil 10/11/2008" );
+ assert.equal( inp.val(), "10/11/2008", "Daylight saving - Brasil 10/11/2008" );
inp.val( "10/01/2008" ).datepicker( "show" );
$( ".ui-datepicker-calendar td:eq(14) a", dp ).simulate( "click" );
- equal( inp.val(), "10/12/2008", "Daylight saving - Brasil 10/12/2008" );
+ assert.equal( inp.val(), "10/12/2008", "Daylight saving - Brasil 10/12/2008" );
inp.val( "10/01/2008" ).datepicker( "show" );
$( ".ui-datepicker-calendar td:eq(15) a", dp ).simulate( "click" );
- equal( inp.val(), "10/13/2008", "Daylight saving - Brasil 10/13/2008" );
+ assert.equal( inp.val(), "10/13/2008", "Daylight saving - Brasil 10/13/2008" );
// Lebanon, Beirut - midnight change, northern hemisphere
inp.val( "03/01/2008" ).datepicker( "show" );
$( ".ui-datepicker-calendar td:eq(34) a", dp ).simulate( "click" );
- equal( inp.val(), "03/29/2008", "Daylight saving - Lebanon 03/29/2008" );
+ assert.equal( inp.val(), "03/29/2008", "Daylight saving - Lebanon 03/29/2008" );
inp.val( "03/01/2008" ).datepicker( "show" );
$( ".ui-datepicker-calendar td:eq(35) a", dp ).simulate( "click" );
- equal( inp.val(), "03/30/2008", "Daylight saving - Lebanon 03/30/2008" );
+ assert.equal( inp.val(), "03/30/2008", "Daylight saving - Lebanon 03/30/2008" );
inp.val( "03/01/2008" ).datepicker( "show" );
$( ".ui-datepicker-calendar td:eq(36) a", dp ).simulate( "click" );
- equal( inp.val(), "03/31/2008", "Daylight saving - Lebanon 03/31/2008" );
+ assert.equal( inp.val(), "03/31/2008", "Daylight saving - Lebanon 03/31/2008" );
inp.val( "10/01/2008" ).datepicker( "show" );
$( ".ui-datepicker-calendar td:eq(27) a", dp ).simulate( "click" );
- equal( inp.val(), "10/25/2008", "Daylight saving - Lebanon 10/25/2008" );
+ assert.equal( inp.val(), "10/25/2008", "Daylight saving - Lebanon 10/25/2008" );
inp.val( "10/01/2008" ).datepicker( "show" );
$( ".ui-datepicker-calendar td:eq(28) a", dp ).simulate( "click" );
- equal( inp.val(), "10/26/2008", "Daylight saving - Lebanon 10/26/2008" );
+ assert.equal( inp.val(), "10/26/2008", "Daylight saving - Lebanon 10/26/2008" );
inp.val( "10/01/2008" ).datepicker( "show" );
$( ".ui-datepicker-calendar td:eq(29) a", dp ).simulate( "click" );
- equal( inp.val(), "10/27/2008", "Daylight saving - Lebanon 10/27/2008" );
+ assert.equal( inp.val(), "10/27/2008", "Daylight saving - Lebanon 10/27/2008" );
// US, Eastern - AM change, northern hemisphere
inp.val( "03/01/2008" ).datepicker( "show" );
$( ".ui-datepicker-calendar td:eq(13) a", dp ).simulate( "click" );
- equal( inp.val(), "03/08/2008", "Daylight saving - US 03/08/2008" );
+ assert.equal( inp.val(), "03/08/2008", "Daylight saving - US 03/08/2008" );
inp.val( "03/01/2008" ).datepicker( "show" );
$( ".ui-datepicker-calendar td:eq(14) a", dp ).simulate( "click" );
- equal( inp.val(), "03/09/2008", "Daylight saving - US 03/09/2008" );
+ assert.equal( inp.val(), "03/09/2008", "Daylight saving - US 03/09/2008" );
inp.val( "03/01/2008" ).datepicker( "show" );
$( ".ui-datepicker-calendar td:eq(15) a", dp ).simulate( "click" );
- equal( inp.val(), "03/10/2008", "Daylight saving - US 03/10/2008" );
+ assert.equal( inp.val(), "03/10/2008", "Daylight saving - US 03/10/2008" );
inp.val( "11/01/2008" ).datepicker( "show" );
$( ".ui-datepicker-calendar td:eq(6) a", dp ).simulate( "click" );
- equal( inp.val(), "11/01/2008", "Daylight saving - US 11/01/2008" );
+ assert.equal( inp.val(), "11/01/2008", "Daylight saving - US 11/01/2008" );
inp.val( "11/01/2008" ).datepicker( "show" );
$( ".ui-datepicker-calendar td:eq(7) a", dp ).simulate( "click" );
- equal( inp.val(), "11/02/2008", "Daylight saving - US 11/02/2008" );
+ assert.equal( inp.val(), "11/02/2008", "Daylight saving - US 11/02/2008" );
inp.val( "11/01/2008" ).datepicker( "show" );
$( ".ui-datepicker-calendar td:eq(8) a", dp ).simulate( "click" );
- equal( inp.val(), "11/03/2008", "Daylight saving - US 11/03/2008" );
+ assert.equal( inp.val(), "11/03/2008", "Daylight saving - US 11/03/2008" );
} );
var beforeShowThis = null,
@@ -808,40 +810,40 @@ function beforeDay( date ) {
( date.getDate() % 3 === 0 ? "Divisble by 3" : "" ) ];
}
-test( "callbacks", function() {
- expect( 13 );
+QUnit.test( "callbacks", function( assert ) {
+ assert.expect( 13 );
// Before show
var dp, day20, day21,
inp = testHelper.init( "#inp", { beforeShow: beforeAll } ),
inst = $.data( inp[ 0 ], "datepicker" );
- equal( $.datepicker._get( inst, "currentText" ), "Today", "Before show - initial" );
+ assert.equal( $.datepicker._get( inst, "currentText" ), "Today", "Before show - initial" );
inp.val( "02/04/2008" ).datepicker( "show" );
- equal( $.datepicker._get( inst, "currentText" ), "Current", "Before show - changed" );
- ok( beforeShowThis.id === inp[ 0 ].id, "Before show - this OK" );
- ok( beforeShowInput.id === inp[ 0 ].id, "Before show - input OK" );
- deepEqual( beforeShowInst, inst, "Before show - inst OK" );
+ assert.equal( $.datepicker._get( inst, "currentText" ), "Current", "Before show - changed" );
+ assert.ok( beforeShowThis.id === inp[ 0 ].id, "Before show - this OK" );
+ assert.ok( beforeShowInput.id === inp[ 0 ].id, "Before show - input OK" );
+ assert.deepEqual( beforeShowInst, inst, "Before show - inst OK" );
inp.datepicker( "hide" ).datepicker( "destroy" );
// Before show day
inp = testHelper.init( "#inp", { beforeShowDay: beforeDay } );
dp = $( "#ui-datepicker-div" );
inp.val( "02/04/2008" ).datepicker( "show" );
- ok( beforeShowDayThis.id === inp[ 0 ].id, "Before show day - this OK" );
- ok( beforeShowDayOK, "Before show day - dates OK" );
+ assert.ok( beforeShowDayThis.id === inp[ 0 ].id, "Before show day - this OK" );
+ assert.ok( beforeShowDayOK, "Before show day - dates OK" );
day20 = dp.find( ".ui-datepicker-calendar td:contains('20')" );
day21 = dp.find( ".ui-datepicker-calendar td:contains('21')" );
- ok( !day20.is( ".ui-datepicker-unselectable" ), "Before show day - unselectable 20" );
- ok( day21.is( ".ui-datepicker-unselectable" ), "Before show day - unselectable 21" );
- ok( day20.is( ".day10" ), "Before show day - CSS 20" );
- ok( !day21.is( ".day10" ), "Before show day - CSS 21" );
- ok( !day20.attr( "title" ), "Before show day - title 20" );
- ok( day21.attr( "title" ) === "Divisble by 3", "Before show day - title 21" );
+ assert.ok( !day20.is( ".ui-datepicker-unselectable" ), "Before show day - unselectable 20" );
+ assert.ok( day21.is( ".ui-datepicker-unselectable" ), "Before show day - unselectable 21" );
+ assert.ok( day20.is( ".day10" ), "Before show day - CSS 20" );
+ assert.ok( !day21.is( ".day10" ), "Before show day - CSS 21" );
+ assert.ok( !day20.attr( "title" ), "Before show day - title 20" );
+ assert.ok( day21.attr( "title" ) === "Divisble by 3", "Before show day - title 21" );
inp.datepicker( "hide" ).datepicker( "destroy" );
} );
-test( "beforeShowDay - tooltips with quotes", function() {
- expect( 1 );
+QUnit.test( "beforeShowDay - tooltips with quotes", function( assert ) {
+ assert.expect( 1 );
var inp, dp;
inp = testHelper.init( "#inp", {
beforeShowDay: function() {
@@ -851,154 +853,154 @@ test( "beforeShowDay - tooltips with quotes", function() {
dp = $( "#ui-datepicker-div" );
inp.datepicker( "show" );
- equal( dp.find( ".ui-datepicker-calendar td:contains('9')" ).attr( "title" ), "'" );
+ assert.equal( dp.find( ".ui-datepicker-calendar td:contains('9')" ).attr( "title" ), "'" );
inp.datepicker( "hide" ).datepicker( "destroy" );
} );
-test( "localisation", function() {
- expect( 24 );
+QUnit.test( "localisation", function( assert ) {
+ assert.expect( 24 );
var dp, month, day, date,
inp = testHelper.init( "#inp", $.datepicker.regional.fr );
inp.datepicker( "option", { dateFormat: "DD, d MM yy", showButtonPanel:true, changeMonth:true, changeYear:true } ).val( "" ).datepicker( "show" );
dp = $( "#ui-datepicker-div" );
- equal( $( ".ui-datepicker-close", dp ).text(), "Fermer", "Localisation - close" );
+ assert.equal( $( ".ui-datepicker-close", dp ).text(), "Fermer", "Localisation - close" );
$( ".ui-datepicker-close", dp ).simulate( "mouseover" );
- equal( $( ".ui-datepicker-prev", dp ).text(), "Précédent", "Localisation - previous" );
- equal( $( ".ui-datepicker-current", dp ).text(), "Aujourd'hui", "Localisation - current" );
- equal( $( ".ui-datepicker-next", dp ).text(), "Suivant", "Localisation - next" );
+ assert.equal( $( ".ui-datepicker-prev", dp ).text(), "Précédent", "Localisation - previous" );
+ assert.equal( $( ".ui-datepicker-current", dp ).text(), "Aujourd'hui", "Localisation - current" );
+ assert.equal( $( ".ui-datepicker-next", dp ).text(), "Suivant", "Localisation - next" );
month = 0;
$( ".ui-datepicker-month option", dp ).each( function() {
- equal( $( this ).text(), $.datepicker.regional.fr.monthNamesShort[ month ],
+ assert.equal( $( this ).text(), $.datepicker.regional.fr.monthNamesShort[ month ],
"Localisation - month " + month );
month++;
} );
day = 1;
$( ".ui-datepicker-calendar th", dp ).each( function() {
- equal( $( this ).text(), $.datepicker.regional.fr.dayNamesMin[ day ],
+ assert.equal( $( this ).text(), $.datepicker.regional.fr.dayNamesMin[ day ],
"Localisation - day " + day );
day = ( day + 1 ) % 7;
} );
inp.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
date = new Date();
- equal( inp.val(), $.datepicker.regional.fr.dayNames[ date.getDay() ] + ", " +
+ assert.equal( inp.val(), $.datepicker.regional.fr.dayNames[ date.getDay() ] + ", " +
date.getDate() + " " + $.datepicker.regional.fr.monthNames[ date.getMonth() ] +
" " + date.getFullYear(), "Localisation - formatting" );
} );
-test( "noWeekends", function() {
- expect( 31 );
+QUnit.test( "noWeekends", function( assert ) {
+ assert.expect( 31 );
var i, date;
for ( i = 1; i <= 31; i++ ) {
date = new Date( 2001, 1 - 1, i );
- deepEqual( $.datepicker.noWeekends( date ), [ ( i + 1 ) % 7 >= 2, "" ],
+ assert.deepEqual( $.datepicker.noWeekends( date ), [ ( i + 1 ) % 7 >= 2, "" ],
"No weekends " + date );
}
} );
-test( "iso8601Week", function() {
- expect( 12 );
+QUnit.test( "iso8601Week", function( assert ) {
+ assert.expect( 12 );
var date = new Date( 2000, 12 - 1, 31 );
- equal( $.datepicker.iso8601Week( date ), 52, "ISO 8601 week " + date );
+ assert.equal( $.datepicker.iso8601Week( date ), 52, "ISO 8601 week " + date );
date = new Date( 2001, 1 - 1, 1 );
- equal( $.datepicker.iso8601Week( date ), 1, "ISO 8601 week " + date );
+ assert.equal( $.datepicker.iso8601Week( date ), 1, "ISO 8601 week " + date );
date = new Date( 2001, 1 - 1, 7 );
- equal( $.datepicker.iso8601Week( date ), 1, "ISO 8601 week " + date );
+ assert.equal( $.datepicker.iso8601Week( date ), 1, "ISO 8601 week " + date );
date = new Date( 2001, 1 - 1, 8 );
- equal( $.datepicker.iso8601Week( date ), 2, "ISO 8601 week " + date );
+ assert.equal( $.datepicker.iso8601Week( date ), 2, "ISO 8601 week " + date );
date = new Date( 2003, 12 - 1, 28 );
- equal( $.datepicker.iso8601Week( date ), 52, "ISO 8601 week " + date );
+ assert.equal( $.datepicker.iso8601Week( date ), 52, "ISO 8601 week " + date );
date = new Date( 2003, 12 - 1, 29 );
- equal( $.datepicker.iso8601Week( date ), 1, "ISO 8601 week " + date );
+ assert.equal( $.datepicker.iso8601Week( date ), 1, "ISO 8601 week " + date );
date = new Date( 2004, 1 - 1, 4 );
- equal( $.datepicker.iso8601Week( date ), 1, "ISO 8601 week " + date );
+ assert.equal( $.datepicker.iso8601Week( date ), 1, "ISO 8601 week " + date );
date = new Date( 2004, 1 - 1, 5 );
- equal( $.datepicker.iso8601Week( date ), 2, "ISO 8601 week " + date );
+ assert.equal( $.datepicker.iso8601Week( date ), 2, "ISO 8601 week " + date );
date = new Date( 2009, 12 - 1, 28 );
- equal( $.datepicker.iso8601Week( date ), 53, "ISO 8601 week " + date );
+ assert.equal( $.datepicker.iso8601Week( date ), 53, "ISO 8601 week " + date );
date = new Date( 2010, 1 - 1, 3 );
- equal( $.datepicker.iso8601Week( date ), 53, "ISO 8601 week " + date );
+ assert.equal( $.datepicker.iso8601Week( date ), 53, "ISO 8601 week " + date );
date = new Date( 2010, 1 - 1, 4 );
- equal( $.datepicker.iso8601Week( date ), 1, "ISO 8601 week " + date );
+ assert.equal( $.datepicker.iso8601Week( date ), 1, "ISO 8601 week " + date );
date = new Date( 2010, 1 - 1, 10 );
- equal( $.datepicker.iso8601Week( date ), 1, "ISO 8601 week " + date );
+ assert.equal( $.datepicker.iso8601Week( date ), 1, "ISO 8601 week " + date );
} );
-test( "parseDate", function() {
- expect( 26 );
+QUnit.test( "parseDate", function( assert ) {
+ assert.expect( 26 );
testHelper.init( "#inp" );
var currentYear, gmtDate, fr, settings, zh;
- ok( $.datepicker.parseDate( "d m y", "" ) == null, "Parse date empty" );
- testHelper.equalsDate( $.datepicker.parseDate( "d m y", "3 2 01" ),
+ assert.ok( $.datepicker.parseDate( "d m y", "" ) == null, "Parse date empty" );
+ testHelper.equalsDate( assert, $.datepicker.parseDate( "d m y", "3 2 01" ),
new Date( 2001, 2 - 1, 3 ), "Parse date d m y" );
- testHelper.equalsDate( $.datepicker.parseDate( "dd mm yy", "03 02 2001" ),
+ testHelper.equalsDate( assert, $.datepicker.parseDate( "dd mm yy", "03 02 2001" ),
new Date( 2001, 2 - 1, 3 ), "Parse date dd mm yy" );
- testHelper.equalsDate( $.datepicker.parseDate( "d m y", "13 12 01" ),
+ testHelper.equalsDate( assert, $.datepicker.parseDate( "d m y", "13 12 01" ),
new Date( 2001, 12 - 1, 13 ), "Parse date d m y" );
- testHelper.equalsDate( $.datepicker.parseDate( "dd mm yy", "13 12 2001" ),
+ testHelper.equalsDate( assert, $.datepicker.parseDate( "dd mm yy", "13 12 2001" ),
new Date( 2001, 12 - 1, 13 ), "Parse date dd mm yy" );
- testHelper.equalsDate( $.datepicker.parseDate( "y-o", "01-34" ),
+ testHelper.equalsDate( assert, $.datepicker.parseDate( "y-o", "01-34" ),
new Date( 2001, 2 - 1, 3 ), "Parse date y-o" );
- testHelper.equalsDate( $.datepicker.parseDate( "yy-oo", "2001-347" ),
+ testHelper.equalsDate( assert, $.datepicker.parseDate( "yy-oo", "2001-347" ),
new Date( 2001, 12 - 1, 13 ), "Parse date yy-oo" );
- testHelper.equalsDate( $.datepicker.parseDate( "oo yy", "348 2004" ),
+ testHelper.equalsDate( assert, $.datepicker.parseDate( "oo yy", "348 2004" ),
new Date( 2004, 12 - 1, 13 ), "Parse date oo yy" );
- testHelper.equalsDate( $.datepicker.parseDate( "D d M y", "Sat 3 Feb 01" ),
+ testHelper.equalsDate( assert, $.datepicker.parseDate( "D d M y", "Sat 3 Feb 01" ),
new Date( 2001, 2 - 1, 3 ), "Parse date D d M y" );
- testHelper.equalsDate( $.datepicker.parseDate( "d MM DD yy", "3 February Saturday 2001" ),
+ testHelper.equalsDate( assert, $.datepicker.parseDate( "d MM DD yy", "3 February Saturday 2001" ),
new Date( 2001, 2 - 1, 3 ), "Parse date dd MM DD yy" );
- testHelper.equalsDate( $.datepicker.parseDate( "DD, MM d, yy", "Saturday, February 3, 2001" ),
+ testHelper.equalsDate( assert, $.datepicker.parseDate( "DD, MM d, yy", "Saturday, February 3, 2001" ),
new Date( 2001, 2 - 1, 3 ), "Parse date DD, MM d, yy" );
- testHelper.equalsDate( $.datepicker.parseDate( "'day' d 'of' MM (''DD''), yy",
+ testHelper.equalsDate( assert, $.datepicker.parseDate( "'day' d 'of' MM (''DD''), yy",
"day 3 of February ('Saturday'), 2001" ), new Date( 2001, 2 - 1, 3 ),
"Parse date 'day' d 'of' MM (''DD''), yy" );
currentYear = new Date().getFullYear();
- testHelper.equalsDate( $.datepicker.parseDate( "y-m-d", ( currentYear - 2000 ) + "-02-03" ),
+ testHelper.equalsDate( assert, $.datepicker.parseDate( "y-m-d", ( currentYear - 2000 ) + "-02-03" ),
new Date( currentYear, 2 - 1, 3 ), "Parse date y-m-d - default cutuff" );
- testHelper.equalsDate( $.datepicker.parseDate( "y-m-d", ( currentYear - 2000 + 10 ) + "-02-03" ),
+ testHelper.equalsDate( assert, $.datepicker.parseDate( "y-m-d", ( currentYear - 2000 + 10 ) + "-02-03" ),
new Date( currentYear + 10, 2 - 1, 3 ), "Parse date y-m-d - default cutuff" );
- testHelper.equalsDate( $.datepicker.parseDate( "y-m-d", ( currentYear - 2000 + 11 ) + "-02-03" ),
+ testHelper.equalsDate( assert, $.datepicker.parseDate( "y-m-d", ( currentYear - 2000 + 11 ) + "-02-03" ),
new Date( currentYear - 89, 2 - 1, 3 ), "Parse date y-m-d - default cutuff" );
- testHelper.equalsDate( $.datepicker.parseDate( "y-m-d", "80-02-03", { shortYearCutoff: 80 } ),
+ testHelper.equalsDate( assert, $.datepicker.parseDate( "y-m-d", "80-02-03", { shortYearCutoff: 80 } ),
new Date( 2080, 2 - 1, 3 ), "Parse date y-m-d - cutoff 80" );
- testHelper.equalsDate( $.datepicker.parseDate( "y-m-d", "81-02-03", { shortYearCutoff: 80 } ),
+ testHelper.equalsDate( assert, $.datepicker.parseDate( "y-m-d", "81-02-03", { shortYearCutoff: 80 } ),
new Date( 1981, 2 - 1, 3 ), "Parse date y-m-d - cutoff 80" );
- testHelper.equalsDate( $.datepicker.parseDate( "y-m-d", ( currentYear - 2000 + 60 ) + "-02-03", { shortYearCutoff: "+60" } ),
+ testHelper.equalsDate( assert, $.datepicker.parseDate( "y-m-d", ( currentYear - 2000 + 60 ) + "-02-03", { shortYearCutoff: "+60" } ),
new Date( currentYear + 60, 2 - 1, 3 ), "Parse date y-m-d - cutoff +60" );
- testHelper.equalsDate( $.datepicker.parseDate( "y-m-d", ( currentYear - 2000 + 61 ) + "-02-03", { shortYearCutoff: "+60" } ),
+ testHelper.equalsDate( assert, $.datepicker.parseDate( "y-m-d", ( currentYear - 2000 + 61 ) + "-02-03", { shortYearCutoff: "+60" } ),
new Date( currentYear - 39, 2 - 1, 3 ), "Parse date y-m-d - cutoff +60" );
gmtDate = new Date( 2001, 2 - 1, 3 );
gmtDate.setMinutes( gmtDate.getMinutes() - gmtDate.getTimezoneOffset() );
- testHelper.equalsDate( $.datepicker.parseDate( "@", "981158400000" ), gmtDate, "Parse date @" );
- testHelper.equalsDate( $.datepicker.parseDate( "!", "631167552000000000" ), gmtDate, "Parse date !" );
+ testHelper.equalsDate( assert, $.datepicker.parseDate( "@", "981158400000" ), gmtDate, "Parse date @" );
+ testHelper.equalsDate( assert, $.datepicker.parseDate( "!", "631167552000000000" ), gmtDate, "Parse date !" );
fr = $.datepicker.regional.fr;
settings = { dayNamesShort: fr.dayNamesShort, dayNames: fr.dayNames,
monthNamesShort: fr.monthNamesShort, monthNames: fr.monthNames };
- testHelper.equalsDate( $.datepicker.parseDate( "D d M y", "Lun. 9 avr. 01", settings ),
+ testHelper.equalsDate( assert, $.datepicker.parseDate( "D d M y", "Lun. 9 avr. 01", settings ),
new Date( 2001, 4 - 1, 9 ), "Parse date D M y with settings" );
- testHelper.equalsDate( $.datepicker.parseDate( "d MM DD yy", "9 Avril Lundi 2001", settings ),
+ testHelper.equalsDate( assert, $.datepicker.parseDate( "d MM DD yy", "9 Avril Lundi 2001", settings ),
new Date( 2001, 4 - 1, 9 ), "Parse date d MM DD yy with settings" );
- testHelper.equalsDate( $.datepicker.parseDate( "DD, MM d, yy", "Lundi, Avril 9, 2001", settings ),
+ testHelper.equalsDate( assert, $.datepicker.parseDate( "DD, MM d, yy", "Lundi, Avril 9, 2001", settings ),
new Date( 2001, 4 - 1, 9 ), "Parse date DD, MM d, yy with settings" );
- testHelper.equalsDate( $.datepicker.parseDate( "'jour' d 'de' MM (''DD''), yy", "jour 9 de Avril ('Lundi'), 2001", settings ),
+ testHelper.equalsDate( assert, $.datepicker.parseDate( "'jour' d 'de' MM (''DD''), yy", "jour 9 de Avril ('Lundi'), 2001", settings ),
new Date( 2001, 4 - 1, 9 ), "Parse date 'jour' d 'de' MM (''DD''), yy with settings" );
zh = $.datepicker.regional[ "zh-CN" ];
- testHelper.equalsDate( $.datepicker.parseDate( "yy M d", "2011 十一月 22", zh ),
+ testHelper.equalsDate( assert, $.datepicker.parseDate( "yy M d", "2011 十一月 22", zh ),
new Date( 2011, 11 - 1, 22 ), "Parse date yy M d with zh-CN" );
} );
-test( "parseDateErrors", function() {
- expect( 18 );
+QUnit.test( "parseDateErrors", function( assert ) {
+ assert.expect( 18 );
testHelper.init( "#inp" );
var fr, settings;
function expectError( expr, value, error ) {
try {
expr();
- ok( false, "Parsed error " + value );
+ assert.ok( false, "Parsed error " + value );
}
catch ( e ) {
- equal( e, error, "Parsed error " + value );
+ assert.equal( e, error, "Parsed error " + value );
}
}
expectError( function() { $.datepicker.parseDate( null, "Sat 2 01" ); },
@@ -1043,65 +1045,65 @@ test( "parseDateErrors", function() {
"Lun. 9 Apr 01 - D d M y", "Unknown name at position 7" );
} );
-test( "Ticket #7244: date parser does not fail when too many numbers are passed into the date function", function() {
- expect( 4 );
+QUnit.test( "Ticket #7244: date parser does not fail when too many numbers are passed into the date function", function( assert ) {
+ assert.expect( 4 );
var date;
try {
date = $.datepicker.parseDate( "dd/mm/yy", "18/04/19881" );
- ok( false, "Did not properly detect an invalid date" );
+ assert.ok( false, "Did not properly detect an invalid date" );
}catch ( e ) {
- ok( "invalid date detected" );
+ assert.ok( "invalid date detected" );
}
try {
date = $.datepicker.parseDate( "dd/mm/yy", "18/04/1988 @ 2:43 pm" );
- equal( date.getDate(), 18 );
- equal( date.getMonth(), 3 );
- equal( date.getFullYear(), 1988 );
+ assert.equal( date.getDate(), 18 );
+ assert.equal( date.getMonth(), 3 );
+ assert.equal( date.getFullYear(), 1988 );
} catch ( e ) {
- ok( false, "Did not properly parse date with extra text separated by whitespace" );
+ assert.ok( false, "Did not properly parse date with extra text separated by whitespace" );
}
} );
-test( "formatDate", function() {
- expect( 16 );
+QUnit.test( "formatDate", function( assert ) {
+ assert.expect( 16 );
testHelper.init( "#inp" );
var gmtDate, fr, settings;
- equal( $.datepicker.formatDate( "d m y", new Date( 2001, 2 - 1, 3 ) ),
+ assert.equal( $.datepicker.formatDate( "d m y", new Date( 2001, 2 - 1, 3 ) ),
"3 2 01", "Format date d m y" );
- equal( $.datepicker.formatDate( "dd mm yy", new Date( 2001, 2 - 1, 3 ) ),
+ assert.equal( $.datepicker.formatDate( "dd mm yy", new Date( 2001, 2 - 1, 3 ) ),
"03 02 2001", "Format date dd mm yy" );
- equal( $.datepicker.formatDate( "d m y", new Date( 2001, 12 - 1, 13 ) ),
+ assert.equal( $.datepicker.formatDate( "d m y", new Date( 2001, 12 - 1, 13 ) ),
"13 12 01", "Format date d m y" );
- equal( $.datepicker.formatDate( "dd mm yy", new Date( 2001, 12 - 1, 13 ) ),
+ assert.equal( $.datepicker.formatDate( "dd mm yy", new Date( 2001, 12 - 1, 13 ) ),
"13 12 2001", "Format date dd mm yy" );
- equal( $.datepicker.formatDate( "yy-o", new Date( 2001, 2 - 1, 3 ) ),
+ assert.equal( $.datepicker.formatDate( "yy-o", new Date( 2001, 2 - 1, 3 ) ),
"2001-34", "Format date yy-o" );
- equal( $.datepicker.formatDate( "yy-oo", new Date( 2001, 2 - 1, 3 ) ),
+ assert.equal( $.datepicker.formatDate( "yy-oo", new Date( 2001, 2 - 1, 3 ) ),
"2001-034", "Format date yy-oo" );
- equal( $.datepicker.formatDate( "D M y", new Date( 2001, 2 - 1, 3 ) ),
+ assert.equal( $.datepicker.formatDate( "D M y", new Date( 2001, 2 - 1, 3 ) ),
"Sat Feb 01", "Format date D M y" );
- equal( $.datepicker.formatDate( "DD MM yy", new Date( 2001, 2 - 1, 3 ) ),
+ assert.equal( $.datepicker.formatDate( "DD MM yy", new Date( 2001, 2 - 1, 3 ) ),
"Saturday February 2001", "Format date DD MM yy" );
- equal( $.datepicker.formatDate( "DD, MM d, yy", new Date( 2001, 2 - 1, 3 ) ),
+ assert.equal( $.datepicker.formatDate( "DD, MM d, yy", new Date( 2001, 2 - 1, 3 ) ),
"Saturday, February 3, 2001", "Format date DD, MM d, yy" );
- equal( $.datepicker.formatDate( "'day' d 'of' MM (''DD''), yy",
+ assert.equal( $.datepicker.formatDate( "'day' d 'of' MM (''DD''), yy",
new Date( 2001, 2 - 1, 3 ) ), "day 3 of February ('Saturday'), 2001",
"Format date 'day' d 'of' MM ('DD'), yy" );
gmtDate = new Date( 2001, 2 - 1, 3 );
gmtDate.setMinutes( gmtDate.getMinutes() - gmtDate.getTimezoneOffset() );
- equal( $.datepicker.formatDate( "@", gmtDate ), "981158400000", "Format date @" );
- equal( $.datepicker.formatDate( "!", gmtDate ), "631167552000000000", "Format date !" );
+ assert.equal( $.datepicker.formatDate( "@", gmtDate ), "981158400000", "Format date @" );
+ assert.equal( $.datepicker.formatDate( "!", gmtDate ), "631167552000000000", "Format date !" );
fr = $.datepicker.regional.fr;
settings = { dayNamesShort: fr.dayNamesShort, dayNames: fr.dayNames,
monthNamesShort: fr.monthNamesShort, monthNames: fr.monthNames };
- equal( $.datepicker.formatDate( "D M y", new Date( 2001, 4 - 1, 9 ), settings ),
+ assert.equal( $.datepicker.formatDate( "D M y", new Date( 2001, 4 - 1, 9 ), settings ),
"lun. avr. 01", "Format date D M y with settings" );
- equal( $.datepicker.formatDate( "DD MM yy", new Date( 2001, 4 - 1, 9 ), settings ),
+ assert.equal( $.datepicker.formatDate( "DD MM yy", new Date( 2001, 4 - 1, 9 ), settings ),
"lundi avril 2001", "Format date DD MM yy with settings" );
- equal( $.datepicker.formatDate( "DD, MM d, yy", new Date( 2001, 4 - 1, 9 ), settings ),
+ assert.equal( $.datepicker.formatDate( "DD, MM d, yy", new Date( 2001, 4 - 1, 9 ), settings ),
"lundi, avril 9, 2001", "Format date DD, MM d, yy with settings" );
- equal( $.datepicker.formatDate( "'jour' d 'de' MM (''DD''), yy",
+ assert.equal( $.datepicker.formatDate( "'jour' d 'de' MM (''DD''), yy",
new Date( 2001, 4 - 1, 9 ), settings ), "jour 9 de avril ('lundi'), 2001",
"Format date 'jour' d 'de' MM (''DD''), yy with settings" );
} );
@@ -1113,8 +1115,8 @@ test( "formatDate", function() {
// equal(time, "089");
// });
-test( "Ticket 7602: Stop datepicker from appearing with beforeShow event handler", function() {
- expect( 3 );
+QUnit.test( "Ticket 7602: Stop datepicker from appearing with beforeShow event handler", function( assert ) {
+ assert.expect( 3 );
var inp, dp;
@@ -1124,7 +1126,7 @@ test( "Ticket 7602: Stop datepicker from appearing with beforeShow event handler
} );
dp = $( "#ui-datepicker-div" );
inp.datepicker( "show" );
- equal( dp.css( "display" ), "block", "beforeShow returns nothing" );
+ assert.equal( dp.css( "display" ), "block", "beforeShow returns nothing" );
inp.datepicker( "hide" ).datepicker( "destroy" );
inp = testHelper.init( "#inp", {
@@ -1134,7 +1136,7 @@ test( "Ticket 7602: Stop datepicker from appearing with beforeShow event handler
} );
dp = $( "#ui-datepicker-div" );
inp.datepicker( "show" );
- equal( dp.css( "display" ), "block", "beforeShow returns true" );
+ assert.equal( dp.css( "display" ), "block", "beforeShow returns true" );
inp.datepicker( "hide" );
inp.datepicker( "destroy" );
@@ -1145,7 +1147,7 @@ test( "Ticket 7602: Stop datepicker from appearing with beforeShow event handler
} );
dp = $( "#ui-datepicker-div" );
inp.datepicker( "show" );
- equal( dp.css( "display" ), "none", "beforeShow returns false" );
+ assert.equal( dp.css( "display" ), "none", "beforeShow returns false" );
inp.datepicker( "destroy" );
} );