aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/datepicker/methods.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/datepicker/methods.js')
-rw-r--r--tests/unit/datepicker/methods.js83
1 files changed, 42 insertions, 41 deletions
diff --git a/tests/unit/datepicker/methods.js b/tests/unit/datepicker/methods.js
index 161af1946..47aae7209 100644
--- a/tests/unit/datepicker/methods.js
+++ b/tests/unit/datepicker/methods.js
@@ -1,114 +1,115 @@
define( [
+ "qunit",
"jquery",
"ui/widgets/datepicker"
-], function( $ ) {
+], function( QUnit, $ ) {
-module( "datepicker: methods", {
- setup: function() {
+QUnit.module( "datepicker: methods", {
+ beforeEach: function() {
this.element = $( "#datepicker" ).datepicker( { show: false, hide: false } );
this.widget = this.element.datepicker( "widget" );
},
- teardown: function() {
+ afterEach: function() {
this.element.datepicker( "destroy" ).val( "" );
}
} );
-test( "destroy", function( assert ) {
+QUnit.test( "destroy", function( assert ) {
assert.expect( 3 );
var input = $( "<input>" ).appendTo( "#qunit-fixture" );
assert.domEqual( input, function() {
input.datepicker();
- ok( input.attr( "aria-owns" ), "aria-owns attribute added" );
- ok( input.attr( "aria-haspopup" ), "aria-haspopup attribute added" );
+ assert.ok( input.attr( "aria-owns" ), "aria-owns attribute added" );
+ assert.ok( input.attr( "aria-haspopup" ), "aria-haspopup attribute added" );
input.datepicker( "destroy" );
} );
} );
-test( "enable / disable", function( assert ) {
+QUnit.test( "enable / disable", function( assert ) {
assert.expect( 10 );
this.element.datepicker( "disable" );
- ok( this.element.datepicker( "option", "disabled" ), "disabled option is set" );
- ok( this.widget.hasClass( "ui-datepicker-disabled" ), "has disabled widget class name" );
- ok( this.element.hasClass( "ui-state-disabled" ), "has disabled state class name" );
- equal( this.element.attr( "aria-disabled" ), "true", "has ARIA disabled" );
- equal( this.element.attr( "disabled" ), "disabled", "input disabled" );
+ assert.ok( this.element.datepicker( "option", "disabled" ), "disabled option is set" );
+ assert.ok( this.widget.hasClass( "ui-datepicker-disabled" ), "has disabled widget class name" );
+ assert.ok( this.element.hasClass( "ui-state-disabled" ), "has disabled state class name" );
+ assert.equal( this.element.attr( "aria-disabled" ), "true", "has ARIA disabled" );
+ assert.equal( this.element.attr( "disabled" ), "disabled", "input disabled" );
this.element.datepicker( "enable" );
- ok( !this.element.datepicker( "option", "disabled" ), "enabled after enable() call" );
- ok( !this.widget.hasClass( "ui-datepicker-disabled" ), "no longer has disabled widget class name" );
- ok( !this.element.hasClass( "ui-state-disabled" ), "no longer has disabled state class name" );
- equal( this.element.attr( "aria-disabled" ), "false", "no longer has ARIA disabled" );
- equal( this.element.attr( "disabled" ), undefined, "input no longer disabled" );
+ assert.ok( !this.element.datepicker( "option", "disabled" ), "enabled after enable() call" );
+ assert.ok( !this.widget.hasClass( "ui-datepicker-disabled" ), "no longer has disabled widget class name" );
+ assert.ok( !this.element.hasClass( "ui-state-disabled" ), "no longer has disabled state class name" );
+ assert.equal( this.element.attr( "aria-disabled" ), "false", "no longer has ARIA disabled" );
+ assert.equal( this.element.attr( "disabled" ), undefined, "input no longer disabled" );
} );
-test( "widget", function( assert ) {
+QUnit.test( "widget", function( assert ) {
assert.expect( 1 );
- deepEqual( $( "body > .ui-front" )[ 0 ], this.widget[ 0 ] );
+ assert.deepEqual( $( "body > .ui-front" )[ 0 ], this.widget[ 0 ] );
this.widget.remove();
} );
-test( "open / close", function( assert ) {
+QUnit.test( "open / close", function( assert ) {
assert.expect( 7 );
- ok( this.widget.is( ":hidden" ), "calendar hidden on init" );
+ assert.ok( this.widget.is( ":hidden" ), "calendar hidden on init" );
this.element.datepicker( "open" );
- ok( this.widget.is( ":visible" ), "open: calendar visible" );
- equal( this.widget.attr( "aria-hidden" ), "false", "open: calendar aria-hidden" );
- equal( this.widget.attr( "aria-expanded" ), "true", "close: calendar aria-expanded" );
+ assert.ok( this.widget.is( ":visible" ), "open: calendar visible" );
+ assert.equal( this.widget.attr( "aria-hidden" ), "false", "open: calendar aria-hidden" );
+ assert.equal( this.widget.attr( "aria-expanded" ), "true", "close: calendar aria-expanded" );
this.element.datepicker( "close" );
- ok( !this.widget.is( ":visible" ), "close: calendar hidden" );
- equal( this.widget.attr( "aria-hidden" ), "true", "close: calendar aria-hidden" );
- equal( this.widget.attr( "aria-expanded" ), "false", "close: calendar aria-expanded" );
+ assert.ok( !this.widget.is( ":visible" ), "close: calendar hidden" );
+ assert.equal( this.widget.attr( "aria-hidden" ), "true", "close: calendar aria-hidden" );
+ assert.equal( this.widget.attr( "aria-expanded" ), "false", "close: calendar aria-expanded" );
} );
-test( "value", function( assert ) {
+QUnit.test( "value", function( assert ) {
assert.expect( 4 );
this.element.datepicker( "value", "1/1/14" );
- equal( this.element.val(), "1/1/14", "input's value set" );
+ assert.equal( this.element.val(), "1/1/14", "input's value set" );
this.element.datepicker( "open" );
- ok(
+ assert.ok(
this.widget.find( "button[data-ui-calendar-timestamp]" ).eq( 0 ).hasClass( "ui-state-active" ),
"first day marked as selected"
);
- equal( this.element.datepicker( "value" ), "1/1/14", "getter" );
+ assert.equal( this.element.datepicker( "value" ), "1/1/14", "getter" );
this.element.val( "abc" );
- strictEqual( this.element.datepicker( "value" ), null, "Invalid values should return null." );
+ assert.strictEqual( this.element.datepicker( "value" ), null, "Invalid values should return null." );
} );
-test( "valueAsDate", function( assert ) {
+QUnit.test( "valueAsDate", function( assert ) {
assert.expect( 5 );
- strictEqual( this.element.datepicker( "valueAsDate" ), null, "Default" );
+ assert.strictEqual( this.element.datepicker( "valueAsDate" ), null, "Default" );
this.element.datepicker( "valueAsDate", new Date( 2014, 0, 1 ) );
- equal( this.element.val(), "1/1/14", "Input's value set" );
- ok(
+ assert.equal( this.element.val(), "1/1/14", "Input's value set" );
+ assert.ok(
this.widget.find( "button[data-ui-calendar-timestamp]" ).eq( 0 ).hasClass( "ui-state-active" ),
"First day marked as selected"
);
assert.dateEqual( this.element.datepicker( "valueAsDate" ), new Date( 2014, 0, 1 ), "Getter" );
this.element.val( "a/b/c" );
- equal( this.element.datepicker( "valueAsDate" ), null, "Invalid dates return null" );
+ assert.equal( this.element.datepicker( "valueAsDate" ), null, "Invalid dates return null" );
} );
-test( "isValid", function( assert ) {
+QUnit.test( "isValid", function( assert ) {
assert.expect( 2 );
this.element.val( "1/1/14" );
- ok( this.element.datepicker( "isValid" ) );
+ assert.ok( this.element.datepicker( "isValid" ) );
this.element.val( "1/1/abc" );
- ok( !this.element.datepicker( "isValid" ) );
+ assert.ok( !this.element.datepicker( "isValid" ) );
} );
} );