module( "accordion: core", setupTeardown() );
$.each( { div: "#list1", ul: "#navigation", dl: "#accordion-dl" }, function( type, selector ) {
-
test( "markup structure: " + type, function( assert ) {
expect( 10 );
var element = $( selector ).accordion(),
});
-asyncTest( "keyboard support", function() {
+asyncTest( "keyboard support", function( assert ) {
expect( 13 );
var element = $( "#list1" ).accordion(),
headers = element.find( ".ui-accordion-header" ),
setTimeout( step1 );
function step1() {
- ok( headers.eq( 0 ).is( ".ui-state-focus" ), "first header has focus" );
+ assert.hasClasses( headers.eq( 0 ), "ui-state-focus", "first header has focus" );
headers.eq( 0 ).simulate( "keydown", { keyCode: keyCode.DOWN } );
setTimeout( step2 );
}
// All of the setTimeouts() from keydowns aren't necessary with newer jQuery.
// Only the explicit focus simulations require them.
function step2() {
- ok( headers.eq( 1 ).is( ".ui-state-focus" ), "DOWN moves focus to next header" );
+ assert.hasClasses( headers.eq( 1 ), "ui-state-focus", "DOWN moves focus to next header" );
headers.eq( 1 ).simulate( "keydown", { keyCode: keyCode.RIGHT } );
setTimeout( step3 );
}
function step3() {
- ok( headers.eq( 2 ).is( ".ui-state-focus" ), "RIGHT moves focus to next header" );
+ assert.hasClasses( headers.eq( 2 ), "ui-state-focus", "RIGHT moves focus to next header" );
headers.eq( 2 ).simulate( "keydown", { keyCode: keyCode.DOWN } );
setTimeout( step4 );
}
function step4() {
- ok( headers.eq( 0 ).is( ".ui-state-focus" ), "DOWN wraps focus to first header" );
+ assert.hasClasses( headers.eq( 0 ), "ui-state-focus", "DOWN wraps focus to first header" );
headers.eq( 0 ).simulate( "keydown", { keyCode: keyCode.UP } );
setTimeout( step5 );
}
function step5() {
- ok( headers.eq( 2 ).is( ".ui-state-focus" ), "UP wraps focus to last header" );
+ assert.hasClasses( headers.eq( 2 ), "ui-state-focus", "UP wraps focus to last header" );
headers.eq( 2 ).simulate( "keydown", { keyCode: keyCode.LEFT } );
setTimeout( step6 );
}
function step6() {
- ok( headers.eq( 1 ).is( ".ui-state-focus" ), "LEFT moves focus to previous header" );
+ assert.hasClasses( headers.eq( 1 ),
+ "ui-state-focus", "LEFT moves focus to previous header" );
headers.eq( 1 ).simulate( "keydown", { keyCode: keyCode.HOME } );
setTimeout( step7 );
}
function step7() {
- ok( headers.eq( 0 ).is( ".ui-state-focus" ), "HOME moves focus to first header" );
+ assert.hasClasses( headers.eq( 0 ), "ui-state-focus", "HOME moves focus to first header" );
headers.eq( 0 ).simulate( "keydown", { keyCode: keyCode.END } );
setTimeout( step8 );
}
function step8() {
- ok( headers.eq( 2 ).is( ".ui-state-focus" ), "END moves focus to last header" );
+ assert.hasClasses( headers.eq( 2 ), "ui-state-focus", "END moves focus to last header" );
headers.eq( 2 ).simulate( "keydown", { keyCode: keyCode.ENTER } );
setTimeout( step9 );
}
}
function step11() {
- ok( !headers.eq( 1 ).is( ".ui-state-focus" ), "header loses focus when focusing inside the panel" );
+ assert.lacksClasses( headers.eq( 1 ), "ui-state-focus",
+ "header loses focus when focusing inside the panel" );
anchor.simulate( "keydown", { keyCode: keyCode.UP, ctrlKey: true } );
setTimeout( step12 );
}
function step12() {
- ok( headers.eq( 1 ).is( ".ui-state-focus" ), "CTRL+UP moves focus to header" );
+ assert.hasClasses( headers.eq( 1 ), "ui-state-focus", "CTRL+UP moves focus to header" );
start();
}
});
});
});
-test( "enable/disable", function() {
+test( "enable/disable", function( assert ) {
expect( 7 );
var element = $( "#list1" ).accordion();
state( element, 1, 0, 0 );
element.accordion( "disable" );
- ok( element.hasClass( "ui-state-disabled" ), "element gets ui-state-disabled" );
+ assert.hasClasses( element, "ui-state-disabled" );
+
equal( element.attr( "aria-disabled" ), "true", "element gets aria-disabled" );
- ok( element.hasClass( "ui-accordion-disabled" ), "element gets ui-accordion-disabled" );
+ assert.hasClasses( element, "ui-accordion-disabled" );
// event does nothing
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "click" );
state( $( "#navigation" ).accordion(), 1, 0, 0);
});
-test( "{ header: custom }", function() {
+test( "{ header: custom }", function( assert ) {
expect( 6 );
var element = $( "#navigationWrapper" ).accordion({
header: "h2"
});
element.find( "h2" ).each(function() {
- ok( $( this ).hasClass( "ui-accordion-header" ) );
+ assert.hasClasses( this, "ui-accordion-header" );
});
equal( element.find( ".ui-accordion-header" ).length, 3 );
state( element, 1, 0, 0 );
icons( false );
});
-test( "{ icons: hash }", function() {
+test( "{ icons: hash }", function( assert ) {
expect( 3 );
var element = $( "#list1" ).accordion({
icons: { activeHeader: "a1", header: "h1" }
});
- ok( element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ).hasClass( "a1" ) );
+ assert.hasClasses( element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ), "a1" );
element.accordion( "option", "icons", { activeHeader: "a2", header: "h2" } );
- ok( !element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ).hasClass( "a1" ) );
- ok( element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ).hasClass( "a2" ) );
+ assert.lacksClasses( element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ), "a1");
+ assert.hasClasses( element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ), "a2" );
});
}( jQuery ) );