mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Accordion tests: Don't use deprecated assertion methods.
This commit is contained in:
parent
3e0d3c9225
commit
ba9bd20c0d
@ -25,7 +25,7 @@
|
||||
var actual = accordion.find( ".ui-accordion-content" ).map(function() {
|
||||
return $( this ).css( "display" ) === "none" ? 0 : 1;
|
||||
}).get();
|
||||
same( actual, expected );
|
||||
deepEqual( actual, expected );
|
||||
}
|
||||
function equalHeights( accordion, min, max ) {
|
||||
var sizes = [];
|
||||
@ -34,8 +34,8 @@
|
||||
});
|
||||
ok( sizes[ 0 ] >= min && sizes[ 0 ] <= max,
|
||||
"must be within " + min + " and " + max + ", was " + sizes[ 0 ] );
|
||||
same( sizes[ 0 ], sizes[ 1 ] );
|
||||
same( sizes[ 0 ], sizes[ 2 ] );
|
||||
deepEqual( sizes[ 0 ], sizes[ 1 ] );
|
||||
deepEqual( sizes[ 0 ], sizes[ 2 ] );
|
||||
}
|
||||
function accordionSetupTeardown() {
|
||||
var animated = $.ui.accordion.prototype.options.animated;
|
||||
|
@ -10,7 +10,7 @@ $.each( { div: "#list1", ul: "#navigation", dl: "#accordion-dl" }, function( typ
|
||||
".ui-accordion-header elements exist, correct number" );
|
||||
equal( element.find( ".ui-accordion-content" ).length, 3,
|
||||
".ui-accordion-content elements exist, correct number" );
|
||||
same( element.find( ".ui-accordion-header" ).next().get(),
|
||||
deepEqual( element.find( ".ui-accordion-header" ).next().get(),
|
||||
element.find( ".ui-accordion-content" ).get(),
|
||||
"content panels come immediately after headers" );
|
||||
});
|
||||
@ -26,7 +26,7 @@ test( "ui-accordion-heading class added to headers anchor", function() {
|
||||
expect( 1 );
|
||||
var element = $( "#list1" ).accordion();
|
||||
var anchors = element.find( ".ui-accordion-heading" );
|
||||
equals( anchors.length, 3 );
|
||||
equal( anchors.length, 3 );
|
||||
});
|
||||
|
||||
test( "accessibility", function () {
|
||||
@ -34,20 +34,20 @@ test( "accessibility", function () {
|
||||
var element = $( "#list1" ).accordion().accordion( "option", "active", 1 );
|
||||
var headers = element.find( ".ui-accordion-header" );
|
||||
|
||||
equals( headers.eq( 1 ).attr( "tabindex" ), 0, "active header should have tabindex=0" );
|
||||
equals( headers.eq( 0 ).attr( "tabindex" ), -1, "inactive header should have tabindex=-1" );
|
||||
equals( element.attr( "role" ), "tablist", "main role" );
|
||||
equals( headers.attr( "role" ), "tab", "tab roles" );
|
||||
equals( headers.next().attr( "role" ), "tabpanel", "tabpanel roles" );
|
||||
equals( headers.eq( 1 ).attr( "aria-expanded" ), "true", "active tab has aria-expanded" );
|
||||
equals( headers.eq( 0 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded" );
|
||||
equals( headers.eq( 1 ).attr( "aria-selected" ), "true", "active tab has aria-selected" );
|
||||
equals( headers.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected" );
|
||||
equal( headers.eq( 1 ).attr( "tabindex" ), 0, "active header should have tabindex=0" );
|
||||
equal( headers.eq( 0 ).attr( "tabindex" ), -1, "inactive header should have tabindex=-1" );
|
||||
equal( element.attr( "role" ), "tablist", "main role" );
|
||||
equal( headers.attr( "role" ), "tab", "tab roles" );
|
||||
equal( headers.next().attr( "role" ), "tabpanel", "tabpanel roles" );
|
||||
equal( headers.eq( 1 ).attr( "aria-expanded" ), "true", "active tab has aria-expanded" );
|
||||
equal( headers.eq( 0 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded" );
|
||||
equal( headers.eq( 1 ).attr( "aria-selected" ), "true", "active tab has aria-selected" );
|
||||
equal( headers.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected" );
|
||||
element.accordion( "option", "active", 0 );
|
||||
equals( headers.eq( 0 ).attr( "aria-expanded" ), "true", "newly active tab has aria-expanded" );
|
||||
equals( headers.eq( 1 ).attr( "aria-expanded" ), "false", "newly inactive tab has aria-expanded" );
|
||||
equals( headers.eq( 0 ).attr( "aria-selected" ), "true", "active tab has aria-selected" );
|
||||
equals( headers.eq( 1 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected" );
|
||||
equal( headers.eq( 0 ).attr( "aria-expanded" ), "true", "newly active tab has aria-expanded" );
|
||||
equal( headers.eq( 1 ).attr( "aria-expanded" ), "false", "newly inactive tab has aria-expanded" );
|
||||
equal( headers.eq( 0 ).attr( "aria-selected" ), "true", "active tab has aria-selected" );
|
||||
equal( headers.eq( 1 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected" );
|
||||
});
|
||||
|
||||
}( jQuery ) );
|
||||
|
@ -22,7 +22,7 @@
|
||||
var actual = accordion.find( ".ui-accordion-content" ).map(function() {
|
||||
return $( this ).css( "display" ) === "none" ? 0 : 1;
|
||||
}).get();
|
||||
same( actual, expected );
|
||||
deepEqual( actual, expected );
|
||||
}
|
||||
function equalHeights( accordion, min, max ) {
|
||||
var sizes = [];
|
||||
@ -31,8 +31,8 @@
|
||||
});
|
||||
ok( sizes[ 0 ] >= min && sizes[ 0 ] <= max,
|
||||
"must be within " + min + " and " + max + ", was " + sizes[ 0 ] );
|
||||
same( sizes[ 0 ], sizes[ 1 ] );
|
||||
same( sizes[ 0 ], sizes[ 2 ] );
|
||||
deepEqual( sizes[ 0 ], sizes[ 1 ] );
|
||||
deepEqual( sizes[ 0 ], sizes[ 2 ] );
|
||||
}
|
||||
function accordionSetupTeardown() {
|
||||
var animated = $.ui.accordion.prototype.options.animated;
|
||||
|
@ -237,11 +237,11 @@ test( "changestart", function() {
|
||||
var content = element.find( ".ui-accordion-content" );
|
||||
|
||||
element.one( "accordionchangestart", function( event, ui ) {
|
||||
equals( ui.oldHeader.size(), 0 );
|
||||
equals( ui.oldContent.size(), 0 );
|
||||
equals( ui.newHeader.size(), 1 );
|
||||
equal( ui.oldHeader.size(), 0 );
|
||||
equal( ui.oldContent.size(), 0 );
|
||||
equal( ui.newHeader.size(), 1 );
|
||||
strictEqual( ui.newHeader[ 0 ], headers[ 0 ] );
|
||||
equals( ui.newContent.size(), 1 );
|
||||
equal( ui.newContent.size(), 1 );
|
||||
strictEqual( ui.newContent[ 0 ], content[ 0 ] );
|
||||
accordion_state( element, 0, 0, 0 );
|
||||
});
|
||||
@ -249,13 +249,13 @@ test( "changestart", function() {
|
||||
accordion_state( element, 1, 0, 0 );
|
||||
|
||||
element.one( "accordionchangestart", function( event, ui ) {
|
||||
equals( ui.oldHeader.size(), 1 );
|
||||
equal( ui.oldHeader.size(), 1 );
|
||||
strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] );
|
||||
equals( ui.oldContent.size(), 1 );
|
||||
equal( ui.oldContent.size(), 1 );
|
||||
strictEqual( ui.oldContent[ 0 ], content[ 0 ] );
|
||||
equals( ui.newHeader.size(), 1 );
|
||||
equal( ui.newHeader.size(), 1 );
|
||||
strictEqual( ui.newHeader[ 0 ], headers[ 1 ] );
|
||||
equals( ui.newContent.size(), 1 );
|
||||
equal( ui.newContent.size(), 1 );
|
||||
strictEqual( ui.newContent[ 0 ], content[ 1 ] );
|
||||
accordion_state( element, 1, 0, 0 );
|
||||
});
|
||||
@ -263,12 +263,12 @@ test( "changestart", function() {
|
||||
accordion_state( element, 0, 1, 0 );
|
||||
|
||||
element.one( "accordionchangestart", function( event, ui ) {
|
||||
equals( ui.oldHeader.size(), 1 );
|
||||
equal( ui.oldHeader.size(), 1 );
|
||||
strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] );
|
||||
equals( ui.oldContent.size(), 1 );
|
||||
equal( ui.oldContent.size(), 1 );
|
||||
strictEqual( ui.oldContent[ 0 ], content[ 1 ] );
|
||||
equals( ui.newHeader.size(), 0 );
|
||||
equals( ui.newContent.size(), 0 );
|
||||
equal( ui.newHeader.size(), 0 );
|
||||
equal( ui.newContent.size(), 0 );
|
||||
accordion_state( element, 0, 1, 0 );
|
||||
});
|
||||
element.accordion( "option", "active", false );
|
||||
@ -285,34 +285,34 @@ test( "change", function() {
|
||||
var content = element.find( ".ui-accordion-content" );
|
||||
|
||||
element.one( "accordionchange", function( event, ui ) {
|
||||
equals( ui.oldHeader.size(), 0 );
|
||||
equals( ui.oldContent.size(), 0 );
|
||||
equals( ui.newHeader.size(), 1 );
|
||||
equal( ui.oldHeader.size(), 0 );
|
||||
equal( ui.oldContent.size(), 0 );
|
||||
equal( ui.newHeader.size(), 1 );
|
||||
strictEqual( ui.newHeader[ 0 ], headers[ 0 ] );
|
||||
equals( ui.newContent.size(), 1 );
|
||||
equal( ui.newContent.size(), 1 );
|
||||
strictEqual( ui.newContent[ 0 ], content[ 0 ] );
|
||||
});
|
||||
element.accordion( "option", "active", 0 );
|
||||
|
||||
element.one( "accordionchange", function( event, ui ) {
|
||||
equals( ui.oldHeader.size(), 1 );
|
||||
equal( ui.oldHeader.size(), 1 );
|
||||
strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] );
|
||||
equals( ui.oldContent.size(), 1 );
|
||||
equal( ui.oldContent.size(), 1 );
|
||||
strictEqual( ui.oldContent[ 0 ], content[ 0 ] );
|
||||
equals( ui.newHeader.size(), 1 );
|
||||
equal( ui.newHeader.size(), 1 );
|
||||
strictEqual( ui.newHeader[ 0 ], headers[ 1 ] );
|
||||
equals( ui.newContent.size(), 1 );
|
||||
equal( ui.newContent.size(), 1 );
|
||||
strictEqual( ui.newContent[ 0 ], content[ 1 ] );
|
||||
});
|
||||
headers.eq( 1 ).click();
|
||||
|
||||
element.one( "accordionchange", function( event, ui ) {
|
||||
equals( ui.oldHeader.size(), 1 );
|
||||
equal( ui.oldHeader.size(), 1 );
|
||||
strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] );
|
||||
equals( ui.oldContent.size(), 1 );
|
||||
equal( ui.oldContent.size(), 1 );
|
||||
strictEqual( ui.oldContent[ 0 ], content[ 1 ] );
|
||||
equals( ui.newHeader.size(), 0 );
|
||||
equals( ui.newContent.size(), 0 );
|
||||
equal( ui.newHeader.size(), 0 );
|
||||
equal( ui.newContent.size(), 0 );
|
||||
});
|
||||
element.accordion( "option", "active", false );
|
||||
});
|
||||
|
@ -13,11 +13,11 @@ test( "beforeActivate", function() {
|
||||
|
||||
element.one( "accordionbeforeactivate", function( event, ui ) {
|
||||
ok( !( "originalEvent" in event ) );
|
||||
equals( ui.oldHeader.size(), 0 );
|
||||
equals( ui.oldContent.size(), 0 );
|
||||
equals( ui.newHeader.size(), 1 );
|
||||
equal( ui.oldHeader.size(), 0 );
|
||||
equal( ui.oldContent.size(), 0 );
|
||||
equal( ui.newHeader.size(), 1 );
|
||||
strictEqual( ui.newHeader[ 0 ], headers[ 0 ] );
|
||||
equals( ui.newContent.size(), 1 );
|
||||
equal( ui.newContent.size(), 1 );
|
||||
strictEqual( ui.newContent[ 0 ], content[ 0 ] );
|
||||
accordion_state( element, 0, 0, 0 );
|
||||
});
|
||||
@ -25,14 +25,14 @@ test( "beforeActivate", function() {
|
||||
accordion_state( element, 1, 0, 0 );
|
||||
|
||||
element.one( "accordionbeforeactivate", function( event, ui ) {
|
||||
equals( event.originalEvent.type, "click" );
|
||||
equals( ui.oldHeader.size(), 1 );
|
||||
equal( event.originalEvent.type, "click" );
|
||||
equal( ui.oldHeader.size(), 1 );
|
||||
strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] );
|
||||
equals( ui.oldContent.size(), 1 );
|
||||
equal( ui.oldContent.size(), 1 );
|
||||
strictEqual( ui.oldContent[ 0 ], content[ 0 ] );
|
||||
equals( ui.newHeader.size(), 1 );
|
||||
equal( ui.newHeader.size(), 1 );
|
||||
strictEqual( ui.newHeader[ 0 ], headers[ 1 ] );
|
||||
equals( ui.newContent.size(), 1 );
|
||||
equal( ui.newContent.size(), 1 );
|
||||
strictEqual( ui.newContent[ 0 ], content[ 1 ] );
|
||||
accordion_state( element, 1, 0, 0 );
|
||||
});
|
||||
@ -41,12 +41,12 @@ test( "beforeActivate", function() {
|
||||
|
||||
element.one( "accordionbeforeactivate", function( event, ui ) {
|
||||
ok( !( "originalEvent" in event ) );
|
||||
equals( ui.oldHeader.size(), 1 );
|
||||
equal( ui.oldHeader.size(), 1 );
|
||||
strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] );
|
||||
equals( ui.oldContent.size(), 1 );
|
||||
equal( ui.oldContent.size(), 1 );
|
||||
strictEqual( ui.oldContent[ 0 ], content[ 1 ] );
|
||||
equals( ui.newHeader.size(), 0 );
|
||||
equals( ui.newContent.size(), 0 );
|
||||
equal( ui.newHeader.size(), 0 );
|
||||
equal( ui.newContent.size(), 0 );
|
||||
accordion_state( element, 0, 1, 0 );
|
||||
});
|
||||
element.accordion( "option", "active", false );
|
||||
@ -54,11 +54,11 @@ test( "beforeActivate", function() {
|
||||
|
||||
element.one( "accordionbeforeactivate", function( event, ui ) {
|
||||
ok( !( "originalEvent" in event ) );
|
||||
equals( ui.oldHeader.size(), 0 );
|
||||
equals( ui.oldContent.size(), 0 );
|
||||
equals( ui.newHeader.size(), 1 );
|
||||
equal( ui.oldHeader.size(), 0 );
|
||||
equal( ui.oldContent.size(), 0 );
|
||||
equal( ui.newHeader.size(), 1 );
|
||||
strictEqual( ui.newHeader[ 0 ], headers[ 2 ] );
|
||||
equals( ui.newContent.size(), 1 );
|
||||
equal( ui.newContent.size(), 1 );
|
||||
strictEqual( ui.newContent[ 0 ], content[ 2 ] );
|
||||
event.preventDefault();
|
||||
accordion_state( element, 0, 0, 0 );
|
||||
@ -77,34 +77,34 @@ test( "activate", function() {
|
||||
var content = element.find( ".ui-accordion-content" );
|
||||
|
||||
element.one( "accordionactivate", function( event, ui ) {
|
||||
equals( ui.oldHeader.size(), 0 );
|
||||
equals( ui.oldContent.size(), 0 );
|
||||
equals( ui.newHeader.size(), 1 );
|
||||
equal( ui.oldHeader.size(), 0 );
|
||||
equal( ui.oldContent.size(), 0 );
|
||||
equal( ui.newHeader.size(), 1 );
|
||||
strictEqual( ui.newHeader[ 0 ], headers[ 0 ] );
|
||||
equals( ui.newContent.size(), 1 );
|
||||
equal( ui.newContent.size(), 1 );
|
||||
strictEqual( ui.newContent[ 0 ], content[ 0 ] );
|
||||
});
|
||||
element.accordion( "option", "active", 0 );
|
||||
|
||||
element.one( "accordionactivate", function( event, ui ) {
|
||||
equals( ui.oldHeader.size(), 1 );
|
||||
equal( ui.oldHeader.size(), 1 );
|
||||
strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] );
|
||||
equals( ui.oldContent.size(), 1 );
|
||||
equal( ui.oldContent.size(), 1 );
|
||||
strictEqual( ui.oldContent[ 0 ], content[ 0 ] );
|
||||
equals( ui.newHeader.size(), 1 );
|
||||
equal( ui.newHeader.size(), 1 );
|
||||
strictEqual( ui.newHeader[ 0 ], headers[ 1 ] );
|
||||
equals( ui.newContent.size(), 1 );
|
||||
equal( ui.newContent.size(), 1 );
|
||||
strictEqual( ui.newContent[ 0 ], content[ 1 ] );
|
||||
});
|
||||
headers.eq( 1 ).click();
|
||||
|
||||
element.one( "accordionactivate", function( event, ui ) {
|
||||
equals( ui.oldHeader.size(), 1 );
|
||||
equal( ui.oldHeader.size(), 1 );
|
||||
strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] );
|
||||
equals( ui.oldContent.size(), 1 );
|
||||
equal( ui.oldContent.size(), 1 );
|
||||
strictEqual( ui.oldContent[ 0 ], content[ 1 ] );
|
||||
equals( ui.newHeader.size(), 0 );
|
||||
equals( ui.newContent.size(), 0 );
|
||||
equal( ui.newHeader.size(), 0 );
|
||||
equal( ui.newContent.size(), 0 );
|
||||
});
|
||||
element.accordion( "option", "active", false );
|
||||
|
||||
|
@ -4,7 +4,7 @@ module( "accordion: options", accordionSetupTeardown() );
|
||||
|
||||
test( "{ active: default }", function() {
|
||||
var element = $( "#list1" ).accordion();
|
||||
equals( element.accordion( "option", "active" ), 0 );
|
||||
equal( element.accordion( "option", "active" ), 0 );
|
||||
accordion_state( element, 1, 0, 0 );
|
||||
});
|
||||
|
||||
@ -14,12 +14,12 @@ test( "{ active: false }", function() {
|
||||
collapsible: true
|
||||
});
|
||||
accordion_state( element, 0, 0, 0 );
|
||||
equals( element.find( ".ui-accordion-header.ui-state-active" ).size(), 0, "no headers selected" );
|
||||
equals( element.accordion( "option", "active" ), false );
|
||||
equal( element.find( ".ui-accordion-header.ui-state-active" ).size(), 0, "no headers selected" );
|
||||
equal( element.accordion( "option", "active" ), false );
|
||||
|
||||
element.accordion( "option", "collapsible", false );
|
||||
accordion_state( element, 1, 0, 0 );
|
||||
equals( element.accordion( "option", "active" ), 0 );
|
||||
equal( element.accordion( "option", "active" ), 0 );
|
||||
|
||||
element.accordion( "destroy" );
|
||||
element.accordion({
|
||||
@ -33,19 +33,19 @@ test( "{ active: Number }", function() {
|
||||
var element = $( "#list1" ).accordion({
|
||||
active: 2
|
||||
});
|
||||
equals( element.accordion( "option", "active" ), 2 );
|
||||
equal( element.accordion( "option", "active" ), 2 );
|
||||
accordion_state( element, 0, 0, 1 );
|
||||
|
||||
element.accordion( "option", "active", 0 );
|
||||
equals( element.accordion( "option", "active" ), 0 );
|
||||
equal( element.accordion( "option", "active" ), 0 );
|
||||
accordion_state( element, 1, 0, 0 );
|
||||
|
||||
element.find( ".ui-accordion-header" ).eq( 1 ).click();
|
||||
equals( element.accordion( "option", "active" ), 1 );
|
||||
equal( element.accordion( "option", "active" ), 1 );
|
||||
accordion_state( element, 0, 1, 0 );
|
||||
|
||||
element.accordion( "option", "active", 10 );
|
||||
equals( element.accordion( "option", "active" ), 1 );
|
||||
equal( element.accordion( "option", "active" ), 1 );
|
||||
accordion_state( element, 0, 1, 0 );
|
||||
});
|
||||
|
||||
@ -54,19 +54,19 @@ if ( $.uiBackCompat === false ) {
|
||||
var element = $( "#list1" ).accordion({
|
||||
active: -1
|
||||
});
|
||||
equals( element.accordion( "option", "active" ), 2 );
|
||||
equal( element.accordion( "option", "active" ), 2 );
|
||||
accordion_state( element, 0, 0, 1 );
|
||||
|
||||
element.accordion( "option", "active", -2 );
|
||||
equals( element.accordion( "option", "active" ), 1 );
|
||||
equal( element.accordion( "option", "active" ), 1 );
|
||||
accordion_state( element, 0, 1, 0 );
|
||||
|
||||
element.accordion( "option", "active", -10 );
|
||||
equals( element.accordion( "option", "active" ), 1 );
|
||||
equal( element.accordion( "option", "active" ), 1 );
|
||||
accordion_state( element, 0, 1, 0 );
|
||||
|
||||
element.accordion( "option", "active", -3 );
|
||||
equals( element.accordion( "option", "active" ), 0 );
|
||||
equal( element.accordion( "option", "active" ), 0 );
|
||||
accordion_state( element, 1, 0, 0 );
|
||||
});
|
||||
}
|
||||
@ -101,7 +101,7 @@ test( "{ collapsible: true }", function() {
|
||||
accordion_state( element, 0, 1, 0 );
|
||||
|
||||
element.find( ".ui-accordion-header" ).eq( 1 ).click();
|
||||
equals( element.accordion( "option", "active" ), false );
|
||||
equal( element.accordion( "option", "active" ), false );
|
||||
accordion_state( element, 0, 0, 0 );
|
||||
});
|
||||
|
||||
@ -238,8 +238,8 @@ test( "{ heightStyle: 'fill' } with multiple siblings", function() {
|
||||
test( "{ icons: false }", function() {
|
||||
var element = $( "#list1" );
|
||||
function icons( on ) {
|
||||
same( element.find( "span.ui-icon").length, on ? 3 : 0 );
|
||||
same( element.hasClass( "ui-accordion-icons" ), on );
|
||||
deepEqual( element.find( "span.ui-icon").length, on ? 3 : 0 );
|
||||
deepEqual( element.hasClass( "ui-accordion-icons" ), on );
|
||||
}
|
||||
element.accordion();
|
||||
icons( true );
|
||||
|
Loading…
Reference in New Issue
Block a user