From: Alexander Schmitz Date: Fri, 30 Jan 2015 14:53:26 +0000 (-0500) Subject: Accordion: Use new has/lacksClasses assertions for all class checks X-Git-Tag: 1.12.0-beta.1~400 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=66001a2f2880bb3c62d941f60ee9ddb90aef1965;p=jquery-ui.git Accordion: Use new has/lacksClasses assertions for all class checks --- diff --git a/tests/unit/accordion/accordion_core.js b/tests/unit/accordion/accordion_core.js index ea5959e9a..155cad7c8 100644 --- a/tests/unit/accordion/accordion_core.js +++ b/tests/unit/accordion/accordion_core.js @@ -6,7 +6,6 @@ var setupTeardown = TestHelpers.accordion.setupTeardown, 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(), @@ -114,7 +113,7 @@ test( "accessibility", function () { }); -asyncTest( "keyboard support", function() { +asyncTest( "keyboard support", function( assert ) { expect( 13 ); var element = $( "#list1" ).accordion(), headers = element.find( ".ui-accordion-header" ), @@ -125,7 +124,7 @@ asyncTest( "keyboard support", function() { 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 ); } @@ -134,43 +133,44 @@ asyncTest( "keyboard support", function() { // 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 ); } @@ -188,13 +188,14 @@ asyncTest( "keyboard support", function() { } 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(); } }); diff --git a/tests/unit/accordion/accordion_methods.js b/tests/unit/accordion/accordion_methods.js index 1e809b310..b59926332 100644 --- a/tests/unit/accordion/accordion_methods.js +++ b/tests/unit/accordion/accordion_methods.js @@ -13,15 +13,16 @@ test( "destroy", function() { }); }); -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" ); diff --git a/tests/unit/accordion/accordion_options.js b/tests/unit/accordion/accordion_options.js index 214753e40..689c6face 100644 --- a/tests/unit/accordion/accordion_options.js +++ b/tests/unit/accordion/accordion_options.js @@ -349,13 +349,13 @@ test( "{ header: default }", function() { 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 ); @@ -449,15 +449,15 @@ test( "{ icons: false }", function() { 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 ) );