define( [
+ "qunit",
"jquery",
"./helper",
"ui/widgets/tabs"
-], function( $, testHelper ) {
+], function( QUnit, $, testHelper ) {
var state = testHelper.state;
-module( "tabs: core" );
+QUnit.module( "tabs: core" );
-test( "markup structure", function( assert ) {
- expect( 20 );
+QUnit.test( "markup structure", function( assert ) {
+ assert.expect( 20 );
var element = $( "#tabs1" ).tabs(),
tabList = element.find( "ul, ol" ),
tabs = tabList.find( "li" ),
assert.hasClasses( element, "ui-tabs ui-widget ui-widget-content" );
assert.lacksClasses( element, "ui-tabs-collapsible" );
assert.hasClasses( tabList, "ui-tabs-nav ui-widget-header" );
- equal( tabList.length, 1, "The widget contains exactly one tab list" );
+ assert.equal( tabList.length, 1, "The widget contains exactly one tab list" );
assert.hasClasses( tabs[ 0 ], "ui-tabs-tab" );
assert.hasClasses( tabs[ 1 ], "ui-tabs-tab" );
assert.hasClasses( tabs[ 2 ], "ui-tabs-tab" );
assert.hasClasses( tabs[ 1 ], "ui-tab" );
assert.hasClasses( tabs[ 2 ], "ui-tab" );
- equal( tabs.length, 3, "There are exactly three tabs" );
+ assert.equal( tabs.length, 3, "There are exactly three tabs" );
assert.hasClasses( anchors[ 0 ], "ui-tabs-anchor" );
assert.hasClasses( anchors[ 1 ], "ui-tabs-anchor" );
assert.hasClasses( anchors[ 2 ], "ui-tabs-anchor" );
- equal( anchors.length, 3, "There are exactly 3 anchors" );
+ assert.equal( anchors.length, 3, "There are exactly 3 anchors" );
assert.hasClasses( active, "ui-tabs-active" );
assert.hasClasses( panels[ 0 ], "ui-tabs-panel ui-widget-content" );
assert.hasClasses( panels[ 1 ], "ui-tabs-panel ui-widget-content" );
assert.hasClasses( panels[ 2 ], "ui-tabs-panel ui-widget-content" );
- equal( panels.length, 3, "There are exactly 3 tab panels" );
+ assert.equal( panels.length, 3, "There are exactly 3 tab panels" );
} );
$.each( {
"multiple lists, ol first": "#tabs5",
"empty list": "#tabs6"
}, function( type, selector ) {
- test( "markup structure: " + type, function( assert ) {
- expect( 2 );
+ QUnit.test( "markup structure: " + type, function( assert ) {
+ assert.expect( 2 );
var element = $( selector ).tabs();
assert.hasClasses( element, "ui-tabs" );
assert.hasClasses( $( selector + "-list" ), "ui-tabs-nav" );
} );
// #5893 - Sublist in the tab list are considered as tab
-test( "nested list", function() {
- expect( 1 );
+QUnit.test( "nested list", function( assert ) {
+ assert.expect( 1 );
var element = $( "#tabs6" ).tabs();
- equal( element.tabs( "instance" ).anchors.length, 2, "should contain 2 tab" );
+ assert.equal( element.tabs( "instance" ).anchors.length, 2, "should contain 2 tab" );
} );
-test( "disconnected from DOM", function() {
- expect( 2 );
+QUnit.test( "disconnected from DOM", function( assert ) {
+ assert.expect( 2 );
var element = $( "#tabs1" ).remove().tabs();
- equal( element.find( ".ui-tabs-nav" ).length, 1, "should initialize nav" );
- equal( element.find( ".ui-tabs-panel" ).length, 3, "should initialize panels" );
+ assert.equal( element.find( ".ui-tabs-nav" ).length, 1, "should initialize nav" );
+ assert.equal( element.find( ".ui-tabs-panel" ).length, 3, "should initialize panels" );
} );
-test( "non-tab list items", function() {
- expect( 2 );
+QUnit.test( "non-tab list items", function( assert ) {
+ assert.expect( 2 );
var element = $( "#tabs9" ).tabs();
- equal( element.tabs( "option", "active" ), 0, "defaults to first tab" );
- equal( element.find( ".ui-tabs-nav li.ui-state-active" ).index(), 1,
+ assert.equal( element.tabs( "option", "active" ), 0, "defaults to first tab" );
+ assert.equal( element.find( ".ui-tabs-nav li.ui-state-active" ).index(), 1,
"first actual tab is active" );
} );
-test( "aria-controls", function() {
- expect( 7 );
+QUnit.test( "aria-controls", function( assert ) {
+ assert.expect( 7 );
var element = $( "#tabs1" ).tabs(),
tabs = element.find( ".ui-tabs-nav li" );
tabs.each( function() {
var tab = $( this ),
anchor = tab.find( ".ui-tabs-anchor" );
- equal( anchor.prop( "hash" ).substring( 1 ), tab.attr( "aria-controls" ) );
+ assert.equal( anchor.prop( "hash" ).substring( 1 ), tab.attr( "aria-controls" ) );
} );
element = $( "#tabs2" ).tabs();
tabs = element.find( ".ui-tabs-nav li" );
- equal( tabs.eq( 0 ).attr( "aria-controls" ), "colon:test" );
- equal( tabs.eq( 1 ).attr( "aria-controls" ), "inline-style" );
- ok( /^ui-id-\d+$/.test( tabs.eq( 2 ).attr( "aria-controls" ) ), "generated id" );
- equal( tabs.eq( 3 ).attr( "aria-controls" ), "custom-id" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-controls" ), "colon:test" );
+ assert.equal( tabs.eq( 1 ).attr( "aria-controls" ), "inline-style" );
+ assert.ok( /^ui-id-\d+$/.test( tabs.eq( 2 ).attr( "aria-controls" ) ), "generated id" );
+ assert.equal( tabs.eq( 3 ).attr( "aria-controls" ), "custom-id" );
} );
-test( "accessibility", function() {
- expect( 49 );
+QUnit.test( "accessibility", function( assert ) {
+ assert.expect( 49 );
var element = $( "#tabs1" ).tabs( {
active: 1,
disabled: [ 2 ]
anchors = tabs.find( ".ui-tabs-anchor" ),
panels = element.find( ".ui-tabs-panel" );
- equal( element.find( ".ui-tabs-nav" ).attr( "role" ), "tablist", "tablist role" );
+ assert.equal( element.find( ".ui-tabs-nav" ).attr( "role" ), "tablist", "tablist role" );
tabs.each( function( index ) {
var tab = tabs.eq( index ),
anchor = anchors.eq( index ),
anchorId = anchor.attr( "id" ),
panel = panels.eq( index );
- equal( tab.attr( "role" ), "tab", "tab " + index + " role" );
- equal( tab.attr( "aria-labelledby" ), anchorId, "tab " + index + " aria-labelledby" );
- equal( anchor.attr( "role" ), "presentation", "anchor " + index + " role" );
- equal( anchor.attr( "tabindex" ), -1, "anchor " + index + " tabindex" );
- equal( panel.attr( "role" ), "tabpanel", "panel " + index + " role" );
- equal( panel.attr( "aria-labelledby" ), anchorId, "panel " + index + " aria-labelledby" );
+ assert.equal( tab.attr( "role" ), "tab", "tab " + index + " role" );
+ assert.equal( tab.attr( "aria-labelledby" ), anchorId, "tab " + index + " aria-labelledby" );
+ assert.equal( anchor.attr( "role" ), "presentation", "anchor " + index + " role" );
+ assert.equal( anchor.attr( "tabindex" ), -1, "anchor " + index + " tabindex" );
+ assert.equal( panel.attr( "role" ), "tabpanel", "panel " + index + " role" );
+ assert.equal( panel.attr( "aria-labelledby" ), anchorId, "panel " + index + " aria-labelledby" );
} );
- equal( tabs.eq( 1 ).attr( "aria-selected" ), "true", "active tab has aria-selected=true" );
- equal( tabs.eq( 1 ).attr( "tabindex" ), 0, "active tab has tabindex=0" );
- equal( tabs.eq( 1 ).attr( "aria-disabled" ), null, "enabled tab does not have aria-disabled" );
- equal( tabs.eq( 1 ).attr( "aria-expanded" ), "true", "active tab has aria-expanded=true" );
- equal( panels.eq( 1 ).attr( "aria-hidden" ), "false", "active panel has aria-hidden=false" );
- equal( tabs.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
- equal( tabs.eq( 0 ).attr( "tabindex" ), -1, "inactive tab has tabindex=-1" );
- equal( tabs.eq( 0 ).attr( "aria-disabled" ), null, "enabled tab does not have aria-disabled" );
- equal( tabs.eq( 0 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded=false" );
- equal( panels.eq( 0 ).attr( "aria-hidden" ), "true", "inactive panel has aria-hidden=true" );
- equal( tabs.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
- equal( tabs.eq( 2 ).attr( "tabindex" ), -1, "inactive tab has tabindex=-1" );
- equal( tabs.eq( 2 ).attr( "aria-disabled" ), "true", "disabled tab has aria-disabled=true" );
- equal( tabs.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded=false" );
- equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "inactive panel has aria-hidden=true" );
+ assert.equal( tabs.eq( 1 ).attr( "aria-selected" ), "true", "active tab has aria-selected=true" );
+ assert.equal( tabs.eq( 1 ).attr( "tabindex" ), 0, "active tab has tabindex=0" );
+ assert.equal( tabs.eq( 1 ).attr( "aria-disabled" ), null, "enabled tab does not have aria-disabled" );
+ assert.equal( tabs.eq( 1 ).attr( "aria-expanded" ), "true", "active tab has aria-expanded=true" );
+ assert.equal( panels.eq( 1 ).attr( "aria-hidden" ), "false", "active panel has aria-hidden=false" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
+ assert.equal( tabs.eq( 0 ).attr( "tabindex" ), -1, "inactive tab has tabindex=-1" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-disabled" ), null, "enabled tab does not have aria-disabled" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded=false" );
+ assert.equal( panels.eq( 0 ).attr( "aria-hidden" ), "true", "inactive panel has aria-hidden=true" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
+ assert.equal( tabs.eq( 2 ).attr( "tabindex" ), -1, "inactive tab has tabindex=-1" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-disabled" ), "true", "disabled tab has aria-disabled=true" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded=false" );
+ assert.equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "inactive panel has aria-hidden=true" );
element.tabs( "option", "active", 0 );
- equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "active tab has aria-selected=true" );
- equal( tabs.eq( 0 ).attr( "tabindex" ), 0, "active tab has tabindex=0" );
- equal( tabs.eq( 0 ).attr( "aria-disabled" ), null, "enabled tab does not have aria-disabled" );
- equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "active tab has aria-expanded=true" );
- equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "active panel has aria-hidden=false" );
- equal( tabs.eq( 1 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
- equal( tabs.eq( 1 ).attr( "tabindex" ), -1, "inactive tab has tabindex=-1" );
- equal( tabs.eq( 1 ).attr( "aria-disabled" ), null, "enabled tab does not have aria-disabled" );
- equal( tabs.eq( 1 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded=false" );
- equal( panels.eq( 1 ).attr( "aria-hidden" ), "true", "inactive panel has aria-hidden=true" );
- equal( tabs.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
- equal( tabs.eq( 2 ).attr( "tabindex" ), -1, "inactive tab has tabindex=-1" );
- equal( tabs.eq( 2 ).attr( "aria-disabled" ), "true", "disabled tab has aria-disabled=true" );
- equal( tabs.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded=false" );
- equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "inactive panel has aria-hidden=true" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "active tab has aria-selected=true" );
+ assert.equal( tabs.eq( 0 ).attr( "tabindex" ), 0, "active tab has tabindex=0" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-disabled" ), null, "enabled tab does not have aria-disabled" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "active tab has aria-expanded=true" );
+ assert.equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "active panel has aria-hidden=false" );
+ assert.equal( tabs.eq( 1 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
+ assert.equal( tabs.eq( 1 ).attr( "tabindex" ), -1, "inactive tab has tabindex=-1" );
+ assert.equal( tabs.eq( 1 ).attr( "aria-disabled" ), null, "enabled tab does not have aria-disabled" );
+ assert.equal( tabs.eq( 1 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded=false" );
+ assert.equal( panels.eq( 1 ).attr( "aria-hidden" ), "true", "inactive panel has aria-hidden=true" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
+ assert.equal( tabs.eq( 2 ).attr( "tabindex" ), -1, "inactive tab has tabindex=-1" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-disabled" ), "true", "disabled tab has aria-disabled=true" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded=false" );
+ assert.equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "inactive panel has aria-hidden=true" );
} );
-asyncTest( "accessibility - ajax", function( assert ) {
- expect( 6 );
+QUnit.test( "accessibility - ajax", function( assert ) {
+ var ready = assert.async();
+ assert.expect( 6 );
var element = $( "#tabs2" ).tabs(),
tab = element.find( ".ui-tabs-nav li" ).eq( 3 ),
panel = $( "#custom-id" );
- equal( panel.attr( "aria-live" ), "polite", "remote panel has aria-live" );
- equal( panel.attr( "aria-busy" ), null, "does not have aria-busy on init" );
+ assert.equal( panel.attr( "aria-live" ), "polite", "remote panel has aria-live" );
+ assert.equal( panel.attr( "aria-busy" ), null, "does not have aria-busy on init" );
element.tabs( "option", "active", 3 );
assert.hasClasses( tab, "ui-tabs-loading" );
- equal( panel.attr( "aria-busy" ), "true", "panel has aria-busy during load" );
+ assert.equal( panel.attr( "aria-busy" ), "true", "panel has aria-busy during load" );
element.one( "tabsload", function() {
setTimeout( function() {
- equal( panel.attr( "aria-busy" ), null, "panel does not have aria-busy after load" );
+ assert.equal( panel.attr( "aria-busy" ), null, "panel does not have aria-busy after load" );
assert.lacksClasses( tab, "ui-tabs-loading" );
- start();
+ ready();
}, 1 );
} );
} );
-asyncTest( "keyboard support - LEFT, RIGHT, UP, DOWN, HOME, END, SPACE, ENTER", function( assert ) {
- expect( 92 );
+QUnit.test( "keyboard support - LEFT, RIGHT, UP, DOWN, HOME, END, SPACE, ENTER", function( assert ) {
+ var ready = assert.async();
+ assert.expect( 92 );
var element = $( "#tabs1" ).tabs( {
collapsible: true
} ),
element.tabs( "instance" ).delay = 1;
- equal( tabs.filter( ".ui-state-focus" ).length, 0, "no tabs focused on init" );
+ assert.equal( tabs.filter( ".ui-state-focus" ).length, 0, "no tabs focused on init" );
tabs.eq( 0 ).simulate( "focus" );
// Down, right, down (wrap), up (wrap)
function step1() {
assert.hasClasses( tabs.eq( 0 ), "ui-state-focus", "first tab has focus" );
- equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
- ok( panels.eq( 0 ).is( ":visible" ), "first panel is visible" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
+ assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel is visible" );
tabs.eq( 0 ).simulate( "keydown", { keyCode: keyCode.DOWN } );
assert.hasClasses( tabs.eq( 1 ), "ui-state-focus", "DOWN moves focus to next tab" );
assert.lacksClasses( tabs.eq( 0 ), "ui-state-focus", "first tab is no longer focused" );
- equal( tabs.eq( 1 ).attr( "aria-selected" ), "true", "second tab has aria-selected=true" );
- equal( tabs.eq( 0 ).attr( "aria-selected" ), "false", "first tab has aria-selected=false" );
- ok( panels.eq( 1 ).is( ":hidden" ), "second panel is still hidden" );
- equal( tabs.eq( 1 ).attr( "aria-expanded" ), "false", "second tab has aria-expanded=false" );
- equal( panels.eq( 1 ).attr( "aria-hidden" ), "true", "second panel has aria-hidden=true" );
- ok( panels.eq( 0 ).is( ":visible" ), "first panel is still visible" );
- equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
- equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
+ assert.equal( tabs.eq( 1 ).attr( "aria-selected" ), "true", "second tab has aria-selected=true" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-selected" ), "false", "first tab has aria-selected=false" );
+ assert.ok( panels.eq( 1 ).is( ":hidden" ), "second panel is still hidden" );
+ assert.equal( tabs.eq( 1 ).attr( "aria-expanded" ), "false", "second tab has aria-expanded=false" );
+ assert.equal( panels.eq( 1 ).attr( "aria-hidden" ), "true", "second panel has aria-hidden=true" );
+ assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel is still visible" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
+ assert.equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
tabs.eq( 1 ).simulate( "keydown", { keyCode: keyCode.RIGHT } );
assert.hasClasses( tabs.eq( 2 ), "ui-state-focus", "RIGHT moves focus to next tab" );
- equal( tabs.eq( 2 ).attr( "aria-selected" ), "true", "third tab has aria-selected=true" );
- equal( tabs.eq( 1 ).attr( "aria-selected" ), "false", "second tab has aria-selected=false" );
- ok( panels.eq( 2 ).is( ":hidden" ), "third panel is still hidden" );
- equal( tabs.eq( 2 ).attr( "aria-expanded" ), "false", "third tab has aria-expanded=false" );
- equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
- ok( panels.eq( 0 ).is( ":visible" ), "first panel is still visible" );
- equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
- equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-selected" ), "true", "third tab has aria-selected=true" );
+ assert.equal( tabs.eq( 1 ).attr( "aria-selected" ), "false", "second tab has aria-selected=false" );
+ assert.ok( panels.eq( 2 ).is( ":hidden" ), "third panel is still hidden" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-expanded" ), "false", "third tab has aria-expanded=false" );
+ assert.equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
+ assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel is still visible" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
+ assert.equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
tabs.eq( 2 ).simulate( "keydown", { keyCode: keyCode.DOWN } );
assert.hasClasses( tabs.eq( 0 ), "ui-state-focus", "DOWN wraps focus to first tab" );
- equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
- equal( tabs.eq( 2 ).attr( "aria-selected" ), "false", "third tab has aria-selected=false" );
- ok( panels.eq( 0 ).is( ":visible" ), "first panel is still visible" );
- equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
- equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-selected" ), "false", "third tab has aria-selected=false" );
+ assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel is still visible" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
+ assert.equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
tabs.eq( 0 ).simulate( "keydown", { keyCode: keyCode.UP } );
assert.hasClasses( tabs.eq( 2 ), "ui-state-focus", "UP wraps focus to last tab" );
- equal( tabs.eq( 2 ).attr( "aria-selected" ), "true", "third tab has aria-selected=true" );
- equal( tabs.eq( 0 ).attr( "aria-selected" ), "false", "first tab has aria-selected=false" );
- ok( panels.eq( 2 ).is( ":hidden" ), "third panel is still hidden" );
- equal( tabs.eq( 2 ).attr( "aria-expanded" ), "false", "third tab has aria-expanded=false" );
- equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
- ok( panels.eq( 0 ).is( ":visible" ), "first panel is still visible" );
- equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
- equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-selected" ), "true", "third tab has aria-selected=true" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-selected" ), "false", "first tab has aria-selected=false" );
+ assert.ok( panels.eq( 2 ).is( ":hidden" ), "third panel is still hidden" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-expanded" ), "false", "third tab has aria-expanded=false" );
+ assert.equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
+ assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel is still visible" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
+ assert.equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
setTimeout( step2, 25 );
}
// Left, home, space
function step2() {
- equal( tabs.eq( 2 ).attr( "aria-selected" ), "true", "third tab has aria-selected=true" );
- equal( tabs.eq( 0 ).attr( "aria-selected" ), "false", "first tab has aria-selected=false" );
- ok( panels.eq( 2 ).is( ":visible" ), "third panel is visible" );
- equal( tabs.eq( 2 ).attr( "aria-expanded" ), "true", "third tab has aria-expanded=true" );
- equal( panels.eq( 2 ).attr( "aria-hidden" ), "false", "third panel has aria-hidden=false" );
- ok( panels.eq( 0 ).is( ":hidden" ), "first panel is hidden" );
- equal( tabs.eq( 0 ).attr( "aria-expanded" ), "false", "first tab has aria-expanded=false" );
- equal( panels.eq( 0 ).attr( "aria-hidden" ), "true", "first panel has aria-hidden=true" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-selected" ), "true", "third tab has aria-selected=true" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-selected" ), "false", "first tab has aria-selected=false" );
+ assert.ok( panels.eq( 2 ).is( ":visible" ), "third panel is visible" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-expanded" ), "true", "third tab has aria-expanded=true" );
+ assert.equal( panels.eq( 2 ).attr( "aria-hidden" ), "false", "third panel has aria-hidden=false" );
+ assert.ok( panels.eq( 0 ).is( ":hidden" ), "first panel is hidden" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-expanded" ), "false", "first tab has aria-expanded=false" );
+ assert.equal( panels.eq( 0 ).attr( "aria-hidden" ), "true", "first panel has aria-hidden=true" );
tabs.eq( 2 ).simulate( "keydown", { keyCode: keyCode.LEFT } );
assert.hasClasses( tabs.eq( 1 ), "ui-state-focus", "LEFT moves focus to previous tab" );
- equal( tabs.eq( 1 ).attr( "aria-selected" ), "true", "second tab has aria-selected=true" );
- equal( tabs.eq( 2 ).attr( "aria-selected" ), "false", "third tab has aria-selected=false" );
- ok( panels.eq( 1 ).is( ":hidden" ), "second panel is still hidden" );
- equal( tabs.eq( 1 ).attr( "aria-expanded" ), "false", "second tab has aria-expanded=false" );
- equal( panels.eq( 1 ).attr( "aria-hidden" ), "true", "second panel has aria-hidden=true" );
- ok( panels.eq( 2 ).is( ":visible" ), "third panel is still visible" );
- equal( tabs.eq( 2 ).attr( "aria-expanded" ), "true", "third tab has aria-expanded=true" );
- equal( panels.eq( 2 ).attr( "aria-hidden" ), "false", "third panel has aria-hidden=false" );
+ assert.equal( tabs.eq( 1 ).attr( "aria-selected" ), "true", "second tab has aria-selected=true" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-selected" ), "false", "third tab has aria-selected=false" );
+ assert.ok( panels.eq( 1 ).is( ":hidden" ), "second panel is still hidden" );
+ assert.equal( tabs.eq( 1 ).attr( "aria-expanded" ), "false", "second tab has aria-expanded=false" );
+ assert.equal( panels.eq( 1 ).attr( "aria-hidden" ), "true", "second panel has aria-hidden=true" );
+ assert.ok( panels.eq( 2 ).is( ":visible" ), "third panel is still visible" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-expanded" ), "true", "third tab has aria-expanded=true" );
+ assert.equal( panels.eq( 2 ).attr( "aria-hidden" ), "false", "third panel has aria-hidden=false" );
tabs.eq( 1 ).simulate( "keydown", { keyCode: keyCode.HOME } );
assert.hasClasses( tabs.eq( 0 ), "ui-state-focus", "HOME moves focus to first tab" );
- equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
- equal( tabs.eq( 1 ).attr( "aria-selected" ), "false", "second tab has aria-selected=false" );
- ok( panels.eq( 0 ).is( ":hidden" ), "first panel is still hidden" );
- equal( tabs.eq( 0 ).attr( "aria-expanded" ), "false", "first tab has aria-expanded=false" );
- equal( panels.eq( 0 ).attr( "aria-hidden" ), "true", "first panel has aria-hidden=true" );
- ok( panels.eq( 2 ).is( ":visible" ), "third panel is still visible" );
- equal( tabs.eq( 2 ).attr( "aria-expanded" ), "true", "third tab has aria-expanded=true" );
- equal( panels.eq( 2 ).attr( "aria-hidden" ), "false", "third panel has aria-hidden=false" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
+ assert.equal( tabs.eq( 1 ).attr( "aria-selected" ), "false", "second tab has aria-selected=false" );
+ assert.ok( panels.eq( 0 ).is( ":hidden" ), "first panel is still hidden" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-expanded" ), "false", "first tab has aria-expanded=false" );
+ assert.equal( panels.eq( 0 ).attr( "aria-hidden" ), "true", "first panel has aria-hidden=true" );
+ assert.ok( panels.eq( 2 ).is( ":visible" ), "third panel is still visible" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-expanded" ), "true", "third tab has aria-expanded=true" );
+ assert.equal( panels.eq( 2 ).attr( "aria-hidden" ), "false", "third panel has aria-hidden=false" );
// SPACE activates, cancels delay
tabs.eq( 0 ).simulate( "keydown", { keyCode: keyCode.SPACE } );
// End, enter
function step3() {
- equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
- equal( tabs.eq( 2 ).attr( "aria-selected" ), "false", "third tab has aria-selected=false" );
- ok( panels.eq( 0 ).is( ":visible" ), "first panel is visible" );
- equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tabs has aria-expanded=true" );
- equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
- ok( panels.eq( 2 ).is( ":hidden" ), "third panel is hidden" );
- equal( tabs.eq( 2 ).attr( "aria-expanded" ), "false", "third tab has aria-expanded=false" );
- equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-selected" ), "false", "third tab has aria-selected=false" );
+ assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel is visible" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tabs has aria-expanded=true" );
+ assert.equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
+ assert.ok( panels.eq( 2 ).is( ":hidden" ), "third panel is hidden" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-expanded" ), "false", "third tab has aria-expanded=false" );
+ assert.equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
tabs.eq( 0 ).simulate( "keydown", { keyCode: keyCode.END } );
assert.hasClasses( tabs.eq( 2 ), "ui-state-focus", "END moves focus to last tab" );
- equal( tabs.eq( 2 ).attr( "aria-selected" ), "true", "third tab has aria-selected=true" );
- equal( tabs.eq( 0 ).attr( "aria-selected" ), "false", "first tab has aria-selected=false" );
- ok( panels.eq( 2 ).is( ":hidden" ), "third panel is still hidden" );
- equal( tabs.eq( 2 ).attr( "aria-expanded" ), "false", "third tab has aria-expanded=false" );
- equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
- ok( panels.eq( 0 ).is( ":visible" ), "first panel is still visible" );
- equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tabs has aria-expanded=true" );
- equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-selected" ), "true", "third tab has aria-selected=true" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-selected" ), "false", "first tab has aria-selected=false" );
+ assert.ok( panels.eq( 2 ).is( ":hidden" ), "third panel is still hidden" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-expanded" ), "false", "third tab has aria-expanded=false" );
+ assert.equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
+ assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel is still visible" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tabs has aria-expanded=true" );
+ assert.equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
// ENTER activates, cancels delay
tabs.eq( 0 ).simulate( "keydown", { keyCode: keyCode.ENTER } );
// Enter (collapse)
function step4() {
- equal( tabs.eq( 2 ).attr( "aria-selected" ), "true", "third tab has aria-selected=true" );
- ok( panels.eq( 2 ).is( ":visible" ), "third panel is visible" );
- equal( tabs.eq( 2 ).attr( "aria-expanded" ), "true", "third tab has aria-expanded=true" );
- equal( panels.eq( 2 ).attr( "aria-hidden" ), "false", "third panel has aria-hidden=false" );
- ok( panels.eq( 0 ).is( ":hidden" ), "first panel is hidden" );
- equal( tabs.eq( 0 ).attr( "aria-expanded" ), "false", "first tab has aria-expanded=false" );
- equal( panels.eq( 0 ).attr( "aria-hidden" ), "true", "first panel has aria-hidden=true" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-selected" ), "true", "third tab has aria-selected=true" );
+ assert.ok( panels.eq( 2 ).is( ":visible" ), "third panel is visible" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-expanded" ), "true", "third tab has aria-expanded=true" );
+ assert.equal( panels.eq( 2 ).attr( "aria-hidden" ), "false", "third panel has aria-hidden=false" );
+ assert.ok( panels.eq( 0 ).is( ":hidden" ), "first panel is hidden" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-expanded" ), "false", "first tab has aria-expanded=false" );
+ assert.equal( panels.eq( 0 ).attr( "aria-hidden" ), "true", "first panel has aria-hidden=true" );
// ENTER collapses if active
tabs.eq( 2 ).simulate( "keydown", { keyCode: keyCode.ENTER } );
- equal( tabs.eq( 2 ).attr( "aria-selected" ), "false", "third tab has aria-selected=false" );
- ok( panels.eq( 2 ).is( ":hidden" ), "third panel is hidden" );
- equal( tabs.eq( 2 ).attr( "aria-expanded" ), "false", "third tab has aria-expanded=false" );
- equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-selected" ), "false", "third tab has aria-selected=false" );
+ assert.ok( panels.eq( 2 ).is( ":hidden" ), "third panel is hidden" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-expanded" ), "false", "third tab has aria-expanded=false" );
+ assert.equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
- setTimeout( start );
+ setTimeout( ready );
}
setTimeout( step1 );
ctrl: "CTRL",
meta: "COMMAND"
}, function( modifier, label ) {
- asyncTest( "keyboard support - " + label + " navigation", function( assert ) {
- expect( 115 );
+ QUnit.test( "keyboard support - " + label + " navigation", function( assert ) {
+ var ready = assert.async();
+ assert.expect( 115 );
var element = $( "#tabs1" ).tabs(),
tabs = element.find( ".ui-tabs-nav li" ),
panels = element.find( ".ui-tabs-panel" ),
element.tabs( "instance" ).delay = 1;
- equal( tabs.filter( ".ui-state-focus" ).length, 0, "no tabs focused on init" );
+ assert.equal( tabs.filter( ".ui-state-focus" ).length, 0, "no tabs focused on init" );
tabs.eq( 0 ).simulate( "focus" );
// Down
eventProperties[ modifier + "Key" ] = true;
assert.hasClasses( tabs.eq( 0 ), "ui-state-focus", "first tab has focus" );
- equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
- ok( panels.eq( 0 ).is( ":visible" ), "first panel is visible" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
+ assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel is visible" );
tabs.eq( 0 ).simulate( "keydown", eventProperties );
assert.hasClasses( tabs.eq( 1 ), "ui-state-focus", "DOWN moves focus to next tab" );
assert.lacksClasses( tabs.eq( 0 ), ".ui-state-focus", "first tab is no longer focused" );
- equal( tabs.eq( 1 ).attr( "aria-selected" ), "false", "second tab has aria-selected=false" );
- equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
- ok( panels.eq( 1 ).is( ":hidden" ), "second panel is still hidden" );
- equal( tabs.eq( 1 ).attr( "aria-expanded" ), "false", "second tab has aria-expanded=false" );
- equal( panels.eq( 1 ).attr( "aria-hidden" ), "true", "second panel has aria-hidden=true" );
- ok( panels.eq( 0 ).is( ":visible" ), "first panel is still visible" );
- equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
- equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
+ assert.equal( tabs.eq( 1 ).attr( "aria-selected" ), "false", "second tab has aria-selected=false" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
+ assert.ok( panels.eq( 1 ).is( ":hidden" ), "second panel is still hidden" );
+ assert.equal( tabs.eq( 1 ).attr( "aria-expanded" ), "false", "second tab has aria-expanded=false" );
+ assert.equal( panels.eq( 1 ).attr( "aria-hidden" ), "true", "second panel has aria-hidden=true" );
+ assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel is still visible" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
+ assert.equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
setTimeout( step2, 25 );
}
var eventProperties = { keyCode: keyCode.RIGHT };
eventProperties[ modifier + "Key" ] = true;
- equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
- ok( panels.eq( 0 ).is( ":visible" ), "first panel is visible" );
- equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
- equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
- ok( panels.eq( 1 ).is( ":hidden" ), "second panel is hidden" );
- equal( tabs.eq( 1 ).attr( "aria-expanded" ), "false", "second tab has aria-expanded=false" );
- equal( panels.eq( 1 ).attr( "aria-hidden" ), "true", "second panel has aria-hidden=true" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
+ assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel is visible" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
+ assert.equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
+ assert.ok( panels.eq( 1 ).is( ":hidden" ), "second panel is hidden" );
+ assert.equal( tabs.eq( 1 ).attr( "aria-expanded" ), "false", "second tab has aria-expanded=false" );
+ assert.equal( panels.eq( 1 ).attr( "aria-hidden" ), "true", "second panel has aria-hidden=true" );
tabs.eq( 1 ).simulate( "keydown", eventProperties );
assert.hasClasses( tabs.eq( 2 ), "ui-state-focus", "RIGHT moves focus to next tab" );
- equal( tabs.eq( 2 ).attr( "aria-selected" ), "false", "third tab has aria-selected=false" );
- equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
- ok( panels.eq( 2 ).is( ":hidden" ), "third panel is still hidden" );
- equal( tabs.eq( 2 ).attr( "aria-expanded" ), "false", "third tab has aria-expanded=false" );
- equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
- ok( panels.eq( 0 ).is( ":visible" ), "first panel is still visible" );
- equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
- equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-selected" ), "false", "third tab has aria-selected=false" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
+ assert.ok( panels.eq( 2 ).is( ":hidden" ), "third panel is still hidden" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-expanded" ), "false", "third tab has aria-expanded=false" );
+ assert.equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
+ assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel is still visible" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
+ assert.equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
setTimeout( step3, 25 );
}
var eventProperties = { keyCode: keyCode.DOWN };
eventProperties[ modifier + "Key" ] = true;
- equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
- ok( panels.eq( 0 ).is( ":visible" ), "first panel is visible" );
- equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
- equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
- ok( panels.eq( 2 ).is( ":hidden" ), "third panel is hidden" );
- equal( tabs.eq( 2 ).attr( "aria-expanded" ), "false", "third tab has aria-expanded=false" );
- equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
+ assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel is visible" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
+ assert.equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
+ assert.ok( panels.eq( 2 ).is( ":hidden" ), "third panel is hidden" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-expanded" ), "false", "third tab has aria-expanded=false" );
+ assert.equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
tabs.eq( 2 ).simulate( "keydown", eventProperties );
assert.hasClasses( tabs.eq( 0 ), "ui-state-focus", "DOWN wraps focus to first tab" );
- equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
- ok( panels.eq( 0 ).is( ":visible" ), "first panel is still visible" );
- equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
- equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
+ assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel is still visible" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
+ assert.equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
setTimeout( step4, 25 );
}
var eventProperties = { keyCode: keyCode.UP };
eventProperties[ modifier + "Key" ] = true;
- equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
- ok( panels.eq( 0 ).is( ":visible" ), "first panel is visible" );
- equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
- equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
+ assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel is visible" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
+ assert.equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
tabs.eq( 0 ).simulate( "keydown", eventProperties );
assert.hasClasses( tabs.eq( 2 ), "ui-state-focus", "UP wraps focus to last tab" );
- equal( tabs.eq( 2 ).attr( "aria-selected" ), "false", "third tab has aria-selected=false" );
- equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
- ok( panels.eq( 2 ).is( ":hidden" ), "third panel is still hidden" );
- equal( tabs.eq( 2 ).attr( "aria-expanded" ), "false", "third tab has aria-expanded=false" );
- equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
- ok( panels.eq( 0 ).is( ":visible" ), "first panel is still visible" );
- equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
- equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-selected" ), "false", "third tab has aria-selected=false" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
+ assert.ok( panels.eq( 2 ).is( ":hidden" ), "third panel is still hidden" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-expanded" ), "false", "third tab has aria-expanded=false" );
+ assert.equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
+ assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel is still visible" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
+ assert.equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
setTimeout( step5, 25 );
}
var eventProperties = { keyCode: keyCode.LEFT };
eventProperties[ modifier + "Key" ] = true;
- equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
- ok( panels.eq( 0 ).is( ":visible" ), "first panel is visible" );
- equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
- equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
- ok( panels.eq( 2 ).is( ":hidden" ), "third panel is hidden" );
- equal( tabs.eq( 2 ).attr( "aria-expanded" ), "false", "third tab has aria-expanded=false" );
- equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
+ assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel is visible" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
+ assert.equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
+ assert.ok( panels.eq( 2 ).is( ":hidden" ), "third panel is hidden" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-expanded" ), "false", "third tab has aria-expanded=false" );
+ assert.equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
tabs.eq( 2 ).simulate( "keydown", eventProperties );
assert.hasClasses( tabs.eq( 1 ), "ui-state-focus", "LEFT moves focus to previous tab" );
- equal( tabs.eq( 1 ).attr( "aria-selected" ), "false", "second tab has aria-selected=false" );
- equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
- ok( panels.eq( 1 ).is( ":hidden" ), "second panel is still hidden" );
- equal( tabs.eq( 1 ).attr( "aria-expanded" ), "false", "second tab has aria-expanded=false" );
- equal( panels.eq( 1 ).attr( "aria-hidden" ), "true", "second panel has aria-hidden=true" );
- ok( panels.eq( 0 ).is( ":visible" ), "first panel is still visible" );
- equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
- equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
+ assert.equal( tabs.eq( 1 ).attr( "aria-selected" ), "false", "second tab has aria-selected=false" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
+ assert.ok( panels.eq( 1 ).is( ":hidden" ), "second panel is still hidden" );
+ assert.equal( tabs.eq( 1 ).attr( "aria-expanded" ), "false", "second tab has aria-expanded=false" );
+ assert.equal( panels.eq( 1 ).attr( "aria-hidden" ), "true", "second panel has aria-hidden=true" );
+ assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel is still visible" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
+ assert.equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
setTimeout( step6, 25 );
}
var eventProperties = { keyCode: keyCode.HOME };
eventProperties[ modifier + "Key" ] = true;
- equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
- ok( panels.eq( 0 ).is( ":visible" ), "first panel is visible" );
- equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
- equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
- ok( panels.eq( 1 ).is( ":hidden" ), "second panel is hidden" );
- equal( tabs.eq( 1 ).attr( "aria-expanded" ), "false", "second tab has aria-expanded=false" );
- equal( panels.eq( 1 ).attr( "aria-hidden" ), "true", "second panel has aria-hidden=true" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
+ assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel is visible" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
+ assert.equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
+ assert.ok( panels.eq( 1 ).is( ":hidden" ), "second panel is hidden" );
+ assert.equal( tabs.eq( 1 ).attr( "aria-expanded" ), "false", "second tab has aria-expanded=false" );
+ assert.equal( panels.eq( 1 ).attr( "aria-hidden" ), "true", "second panel has aria-hidden=true" );
tabs.eq( 1 ).simulate( "keydown", eventProperties );
assert.hasClasses( tabs.eq( 0 ), "ui-state-focus", "HOME moves focus to first tab" );
- equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
- equal( tabs.eq( 1 ).attr( "aria-selected" ), "false", "second tab has aria-selected=false" );
- ok( panels.eq( 1 ).is( ":hidden" ), "second panel is still hidden" );
- equal( tabs.eq( 1 ).attr( "aria-expanded" ), "false", "second tab has aria-expanded=false" );
- equal( panels.eq( 1 ).attr( "aria-hidden" ), "true", "second panel has aria-hidden=true" );
- ok( panels.eq( 0 ).is( ":visible" ), "first panel is still visible" );
- equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
- equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
+ assert.equal( tabs.eq( 1 ).attr( "aria-selected" ), "false", "second tab has aria-selected=false" );
+ assert.ok( panels.eq( 1 ).is( ":hidden" ), "second panel is still hidden" );
+ assert.equal( tabs.eq( 1 ).attr( "aria-expanded" ), "false", "second tab has aria-expanded=false" );
+ assert.equal( panels.eq( 1 ).attr( "aria-hidden" ), "true", "second panel has aria-hidden=true" );
+ assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel is still visible" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
+ assert.equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
setTimeout( step7, 25 );
}
var eventProperties = { keyCode: keyCode.END };
eventProperties[ modifier + "Key" ] = true;
- equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
- ok( panels.eq( 0 ).is( ":visible" ), "first panel is visible" );
- equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
- equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
+ assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel is visible" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
+ assert.equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
tabs.eq( 0 ).simulate( "keydown", eventProperties );
assert.hasClasses( tabs.eq( 2 ), "ui-state-focus", "END moves focus to last tab" );
- equal( tabs.eq( 2 ).attr( "aria-selected" ), "false", "third tab has aria-selected=false" );
- equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
- ok( panels.eq( 2 ).is( ":hidden" ), "third panel is still hidden" );
- equal( tabs.eq( 2 ).attr( "aria-expanded" ), "false", "third tab has aria-expanded=false" );
- equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
- ok( panels.eq( 0 ).is( ":visible" ), "first panel is still visible" );
- equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
- equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-selected" ), "false", "third tab has aria-selected=false" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
+ assert.ok( panels.eq( 2 ).is( ":hidden" ), "third panel is still hidden" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-expanded" ), "false", "third tab has aria-expanded=false" );
+ assert.equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
+ assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel is still visible" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
+ assert.equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
setTimeout( step8, 25 );
}
// Space
function step8() {
- equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
- ok( panels.eq( 0 ).is( ":visible" ), "first panel is visible" );
- equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
- equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
- ok( panels.eq( 2 ).is( ":hidden" ), "third panel is hidden" );
- equal( tabs.eq( 2 ).attr( "aria-expanded" ), "false", "third tab has aria-expanded=false" );
- equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
+ assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel is visible" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
+ assert.equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
+ assert.ok( panels.eq( 2 ).is( ":hidden" ), "third panel is hidden" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-expanded" ), "false", "third tab has aria-expanded=false" );
+ assert.equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
tabs.eq( 2 ).simulate( "keydown", { keyCode: keyCode.SPACE } );
- equal( tabs.eq( 2 ).attr( "aria-selected" ), "true", "third tab has aria-selected=true" );
- equal( tabs.eq( 0 ).attr( "aria-selected" ), "false", "first tab has aria-selected=false" );
- ok( panels.eq( 2 ).is( ":visible" ), "third panel is visible" );
- equal( tabs.eq( 2 ).attr( "aria-expanded" ), "true", "third tab has aria-expanded=true" );
- equal( panels.eq( 2 ).attr( "aria-hidden" ), "false", "third panel has aria-hidden=false" );
- ok( panels.eq( 0 ).is( ":hidden" ), "first panel is hidden" );
- equal( tabs.eq( 0 ).attr( "aria-expanded" ), "false", "first tab has aria-expanded=false" );
- equal( panels.eq( 0 ).attr( "aria-hidden" ), "true", "first panel has aria-hidden=true" );
-
- setTimeout( start );
+ assert.equal( tabs.eq( 2 ).attr( "aria-selected" ), "true", "third tab has aria-selected=true" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-selected" ), "false", "first tab has aria-selected=false" );
+ assert.ok( panels.eq( 2 ).is( ":visible" ), "third panel is visible" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-expanded" ), "true", "third tab has aria-expanded=true" );
+ assert.equal( panels.eq( 2 ).attr( "aria-hidden" ), "false", "third panel has aria-hidden=false" );
+ assert.ok( panels.eq( 0 ).is( ":hidden" ), "first panel is hidden" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-expanded" ), "false", "first tab has aria-expanded=false" );
+ assert.equal( panels.eq( 0 ).attr( "aria-hidden" ), "true", "first panel has aria-hidden=true" );
+
+ setTimeout( ready );
}
setTimeout( step1 );
} );
} );
-asyncTest( "keyboard support - CTRL+UP, ALT+PAGE_DOWN, ALT+PAGE_UP", function( assert ) {
- expect( 50 );
+QUnit.test( "keyboard support - CTRL+UP, ALT+PAGE_DOWN, ALT+PAGE_UP", function( assert ) {
+ var ready = assert.async();
+ assert.expect( 50 );
var element = $( "#tabs1" ).tabs(),
tabs = element.find( ".ui-tabs-nav li" ),
panels = element.find( ".ui-tabs-panel" ),
keyCode = $.ui.keyCode;
- equal( tabs.filter( ".ui-state-focus" ).length, 0, "no tabs focused on init" );
+ assert.equal( tabs.filter( ".ui-state-focus" ).length, 0, "no tabs focused on init" );
panels.attr( "tabindex", -1 );
panels.eq( 0 ).simulate( "focus" );
function step1() {
- strictEqual( document.activeElement, panels[ 0 ], "first panel is activeElement" );
+ assert.strictEqual( document.activeElement, panels[ 0 ], "first panel is activeElement" );
panels.eq( 0 ).simulate( "keydown", { keyCode: keyCode.PAGE_DOWN, altKey: true } );
- strictEqual( document.activeElement, tabs[ 1 ], "second tab is activeElement" );
+ assert.strictEqual( document.activeElement, tabs[ 1 ], "second tab is activeElement" );
assert.hasClasses( tabs.eq( 1 ), "ui-state-focus", "ALT+PAGE_DOWN moves focus to next tab" );
- equal( tabs.eq( 1 ).attr( "aria-selected" ), "true", "second tab has aria-selected=true" );
- ok( panels.eq( 1 ).is( ":visible" ), "second panel is visible" );
- equal( tabs.eq( 1 ).attr( "aria-expanded" ), "true", "second tab has aria-expanded=true" );
- equal( panels.eq( 1 ).attr( "aria-hidden" ), "false", "second panel has aria-hidden=false" );
- ok( panels.eq( 0 ).is( ":hidden" ), "first panel is hidden" );
- equal( tabs.eq( 0 ).attr( "aria-expanded" ), "false", "first tab has aria-expanded=false" );
- equal( panels.eq( 0 ).attr( "aria-hidden" ), "true", "first panel has aria-hidden=true" );
+ assert.equal( tabs.eq( 1 ).attr( "aria-selected" ), "true", "second tab has aria-selected=true" );
+ assert.ok( panels.eq( 1 ).is( ":visible" ), "second panel is visible" );
+ assert.equal( tabs.eq( 1 ).attr( "aria-expanded" ), "true", "second tab has aria-expanded=true" );
+ assert.equal( panels.eq( 1 ).attr( "aria-hidden" ), "false", "second panel has aria-hidden=false" );
+ assert.ok( panels.eq( 0 ).is( ":hidden" ), "first panel is hidden" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-expanded" ), "false", "first tab has aria-expanded=false" );
+ assert.equal( panels.eq( 0 ).attr( "aria-hidden" ), "true", "first panel has aria-hidden=true" );
tabs.eq( 1 ).simulate( "keydown", { keyCode: keyCode.PAGE_DOWN, altKey: true } );
- strictEqual( document.activeElement, tabs[ 2 ], "third tab is activeElement" );
+ assert.strictEqual( document.activeElement, tabs[ 2 ], "third tab is activeElement" );
assert.hasClasses( tabs.eq( 2 ), "ui-state-focus", "ALT+PAGE_DOWN moves focus to next tab" );
- equal( tabs.eq( 2 ).attr( "aria-selected" ), "true", "third tab has aria-selected=true" );
- ok( panels.eq( 2 ).is( ":visible" ), "third panel is visible" );
- equal( tabs.eq( 2 ).attr( "aria-expanded" ), "true", "third tab has aria-expanded=true" );
- equal( panels.eq( 2 ).attr( "aria-hidden" ), "false", "third panel has aria-hidden=false" );
- ok( panels.eq( 1 ).is( ":hidden" ), "second panel is hidden" );
- equal( tabs.eq( 1 ).attr( "aria-expanded" ), "false", "second tab has aria-expanded=false" );
- equal( panels.eq( 1 ).attr( "aria-hidden" ), "true", "second panel has aria-hidden=true" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-selected" ), "true", "third tab has aria-selected=true" );
+ assert.ok( panels.eq( 2 ).is( ":visible" ), "third panel is visible" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-expanded" ), "true", "third tab has aria-expanded=true" );
+ assert.equal( panels.eq( 2 ).attr( "aria-hidden" ), "false", "third panel has aria-hidden=false" );
+ assert.ok( panels.eq( 1 ).is( ":hidden" ), "second panel is hidden" );
+ assert.equal( tabs.eq( 1 ).attr( "aria-expanded" ), "false", "second tab has aria-expanded=false" );
+ assert.equal( panels.eq( 1 ).attr( "aria-hidden" ), "true", "second panel has aria-hidden=true" );
tabs.eq( 2 ).simulate( "keydown", { keyCode: keyCode.PAGE_DOWN, altKey: true } );
- strictEqual( document.activeElement, tabs[ 0 ], "first tab is activeElement" );
+ assert.strictEqual( document.activeElement, tabs[ 0 ], "first tab is activeElement" );
assert.hasClasses( tabs.eq( 0 ), "ui-state-focus", "ALT+PAGE_DOWN wraps focus to first tab" );
- equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
- ok( panels.eq( 0 ).is( ":visible" ), "first panel is visible" );
- equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
- equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
- ok( panels.eq( 2 ).is( ":hidden" ), "third panel is hidden" );
- equal( tabs.eq( 2 ).attr( "aria-expanded" ), "false", "third tab has aria-expanded=false" );
- equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
+ assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel is visible" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-expanded" ), "true", "first tab has aria-expanded=true" );
+ assert.equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
+ assert.ok( panels.eq( 2 ).is( ":hidden" ), "third panel is hidden" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-expanded" ), "false", "third tab has aria-expanded=false" );
+ assert.equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
panels.eq( 0 ).simulate( "focus" );
setTimeout( step2 );
}
function step2() {
- strictEqual( document.activeElement, panels[ 0 ], "first panel is activeElement" );
+ assert.strictEqual( document.activeElement, panels[ 0 ], "first panel is activeElement" );
panels.eq( 0 ).simulate( "keydown", { keyCode: keyCode.PAGE_UP, altKey: true } );
- strictEqual( document.activeElement, tabs[ 2 ], "third tab is activeElement" );
+ assert.strictEqual( document.activeElement, tabs[ 2 ], "third tab is activeElement" );
assert.hasClasses( tabs.eq( 2 ), "ui-state-focus", "ALT+PAGE_UP wraps focus to last tab" );
- equal( tabs.eq( 2 ).attr( "aria-selected" ), "true", "third tab has aria-selected=true" );
- ok( panels.eq( 2 ).is( ":visible" ), "third panel is visible" );
- equal( tabs.eq( 2 ).attr( "aria-expanded" ), "true", "third tab has aria-expanded=true" );
- equal( panels.eq( 2 ).attr( "aria-hidden" ), "false", "third panel has aria-hidden=false" );
- ok( panels.eq( 0 ).is( ":hidden" ), "first panel is hidden" );
- equal( tabs.eq( 0 ).attr( "aria-expanded" ), "false", "first tab has aria-expanded=false" );
- equal( panels.eq( 0 ).attr( "aria-hidden" ), "true", "first panel has aria-hidden=true" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-selected" ), "true", "third tab has aria-selected=true" );
+ assert.ok( panels.eq( 2 ).is( ":visible" ), "third panel is visible" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-expanded" ), "true", "third tab has aria-expanded=true" );
+ assert.equal( panels.eq( 2 ).attr( "aria-hidden" ), "false", "third panel has aria-hidden=false" );
+ assert.ok( panels.eq( 0 ).is( ":hidden" ), "first panel is hidden" );
+ assert.equal( tabs.eq( 0 ).attr( "aria-expanded" ), "false", "first tab has aria-expanded=false" );
+ assert.equal( panels.eq( 0 ).attr( "aria-hidden" ), "true", "first panel has aria-hidden=true" );
tabs.eq( 2 ).simulate( "keydown", { keyCode: keyCode.PAGE_UP, altKey: true } );
- strictEqual( document.activeElement, tabs[ 1 ], "second tab is activeElement" );
+ assert.strictEqual( document.activeElement, tabs[ 1 ], "second tab is activeElement" );
assert.hasClasses( tabs.eq( 1 ), "ui-state-focus", "ALT+PAGE_UP moves focus to previous tab" );
- equal( tabs.eq( 1 ).attr( "aria-selected" ), "true", "second tab has aria-selected=true" );
- ok( panels.eq( 1 ).is( ":visible" ), "second panel is visible" );
- equal( tabs.eq( 1 ).attr( "aria-expanded" ), "true", "second tab has aria-expanded=true" );
- equal( panels.eq( 1 ).attr( "aria-hidden" ), "false", "second panel has aria-hidden=false" );
- ok( panels.eq( 2 ).is( ":hidden" ), "third panel is hidden" );
- equal( tabs.eq( 2 ).attr( "aria-expanded" ), "false", "third tab has aria-expanded=false" );
- equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
+ assert.equal( tabs.eq( 1 ).attr( "aria-selected" ), "true", "second tab has aria-selected=true" );
+ assert.ok( panels.eq( 1 ).is( ":visible" ), "second panel is visible" );
+ assert.equal( tabs.eq( 1 ).attr( "aria-expanded" ), "true", "second tab has aria-expanded=true" );
+ assert.equal( panels.eq( 1 ).attr( "aria-hidden" ), "false", "second panel has aria-hidden=false" );
+ assert.ok( panels.eq( 2 ).is( ":hidden" ), "third panel is hidden" );
+ assert.equal( tabs.eq( 2 ).attr( "aria-expanded" ), "false", "third tab has aria-expanded=false" );
+ assert.equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
panels.eq( 1 ).simulate( "focus" );
setTimeout( step3 );
}
function step3() {
- strictEqual( document.activeElement, panels[ 1 ], "second panel is activeElement" );
+ assert.strictEqual( document.activeElement, panels[ 1 ], "second panel is activeElement" );
panels.eq( 1 ).simulate( "keydown", { keyCode: keyCode.UP, ctrlKey: true } );
- strictEqual( document.activeElement, tabs[ 1 ], "second tab is activeElement" );
+ assert.strictEqual( document.activeElement, tabs[ 1 ], "second tab is activeElement" );
- setTimeout( start );
+ setTimeout( ready );
}
setTimeout( step1 );
} );
-test( "#3627 - Ajax tab with url containing a fragment identifier fails to load", function() {
- expect( 1 );
+QUnit.test( "#3627 - Ajax tab with url containing a fragment identifier fails to load", function( assert ) {
+ assert.expect( 1 );
$( "#tabs2" ).tabs( {
active: 2,
beforeLoad: function( event, ui ) {
event.preventDefault();
- ok( /test.html$/.test( ui.ajaxSettings.url ), "should ignore fragment identifier" );
+ assert.ok( /test.html$/.test( ui.ajaxSettings.url ), "should ignore fragment identifier" );
}
} );
} );
-test( "#4033 - IE expands hash to full url and misinterprets tab as ajax", function() {
- expect( 2 );
+QUnit.test( "#4033 - IE expands hash to full url and misinterprets tab as ajax", function( assert ) {
+ assert.expect( 2 );
var element = $( "<div><ul><li><a href='#tab'>Tab</a></li></ul><div id='tab'></div></div>" );
element.appendTo( "#qunit-fixture" );
element.tabs( {
beforeLoad: function() {
event.preventDefault();
- ok( false, "should not be an ajax tab" );
+ assert.ok( false, "should not be an ajax tab" );
}
} );
- equal( element.find( ".ui-tabs-nav li" ).attr( "aria-controls" ), "tab", "aria-contorls attribute is correct" );
- state( element, 1 );
+ assert.equal( element.find( ".ui-tabs-nav li" ).attr( "aria-controls" ), "tab", "aria-contorls attribute is correct" );
+ state( assert, element, 1 );
} );
} );
define( [
+ "qunit",
"jquery",
"./helper",
"ui/widgets/tabs"
-], function( $, testHelper ) {
+], function( QUnit, $, testHelper ) {
var state = testHelper.state;
-module( "tabs: events" );
+QUnit.module( "tabs: events" );
-test( "create", function() {
- expect( 10 );
+QUnit.test( "create", function( assert ) {
+ assert.expect( 10 );
var element = $( "#tabs1" ),
tabs = element.find( "ul li" ),
element.tabs( {
create: function( event, ui ) {
- equal( ui.tab.length, 1, "tab length" );
- strictEqual( ui.tab[ 0 ], tabs[ 0 ], "tab" );
- equal( ui.panel.length, 1, "panel length" );
- strictEqual( ui.panel[ 0 ], panels[ 0 ], "panel" );
+ assert.equal( ui.tab.length, 1, "tab length" );
+ assert.strictEqual( ui.tab[ 0 ], tabs[ 0 ], "tab" );
+ assert.equal( ui.panel.length, 1, "panel length" );
+ assert.strictEqual( ui.panel[ 0 ], panels[ 0 ], "panel" );
}
} );
element.tabs( "destroy" );
element.tabs( {
active: 2,
create: function( event, ui ) {
- equal( ui.tab.length, 1, "tab length" );
- strictEqual( ui.tab[ 0 ], tabs[ 2 ], "tab" );
- equal( ui.panel.length, 1, "panel length" );
- strictEqual( ui.panel[ 0 ], panels[ 2 ], "panel" );
+ assert.equal( ui.tab.length, 1, "tab length" );
+ assert.strictEqual( ui.tab[ 0 ], tabs[ 2 ], "tab" );
+ assert.equal( ui.panel.length, 1, "panel length" );
+ assert.strictEqual( ui.panel[ 0 ], panels[ 2 ], "panel" );
}
} );
element.tabs( "destroy" );
active: false,
collapsible: true,
create: function( event, ui ) {
- equal( ui.tab.length, 0, "tab length" );
- equal( ui.panel.length, 0, "panel length" );
+ assert.equal( ui.tab.length, 0, "tab length" );
+ assert.equal( ui.panel.length, 0, "panel length" );
}
} );
element.tabs( "destroy" );
} );
-test( "beforeActivate", function() {
- expect( 38 );
+QUnit.test( "beforeActivate", function( assert ) {
+ assert.expect( 38 );
var element = $( "#tabs1" ).tabs( {
active: false,
// From collapsed
element.one( "tabsbeforeactivate", function( event, ui ) {
- ok( !( "originalEvent" in event ), "originalEvent" );
- equal( ui.oldTab.length, 0, "oldTab length" );
- equal( ui.oldPanel.length, 0, "oldPanel length" );
- equal( ui.newTab.length, 1, "newTab length" );
- strictEqual( ui.newTab[ 0 ], tabs[ 0 ], "newTab" );
- equal( ui.newPanel.length, 1, "newPanel length" );
- strictEqual( ui.newPanel[ 0 ], panels[ 0 ], "newPanel" );
- state( element, 0, 0, 0 );
+ assert.ok( !( "originalEvent" in event ), "originalEvent" );
+ assert.equal( ui.oldTab.length, 0, "oldTab length" );
+ assert.equal( ui.oldPanel.length, 0, "oldPanel length" );
+ assert.equal( ui.newTab.length, 1, "newTab length" );
+ assert.strictEqual( ui.newTab[ 0 ], tabs[ 0 ], "newTab" );
+ assert.equal( ui.newPanel.length, 1, "newPanel length" );
+ assert.strictEqual( ui.newPanel[ 0 ], panels[ 0 ], "newPanel" );
+ state( assert, element, 0, 0, 0 );
} );
element.tabs( "option", "active", 0 );
- state( element, 1, 0, 0 );
+ state( assert, element, 1, 0, 0 );
// Switching tabs
element.one( "tabsbeforeactivate", function( event, ui ) {
- equal( event.originalEvent.type, "click", "originalEvent" );
- equal( ui.oldTab.length, 1, "oldTab length" );
- strictEqual( ui.oldTab[ 0 ], tabs[ 0 ], "oldTab" );
- equal( ui.oldPanel.length, 1, "oldPanel length" );
- strictEqual( ui.oldPanel[ 0 ], panels[ 0 ], "oldPanel" );
- equal( ui.newTab.length, 1, "newTab length" );
- strictEqual( ui.newTab[ 0 ], tabs[ 1 ], "newTab" );
- equal( ui.newPanel.length, 1, "newPanel length" );
- strictEqual( ui.newPanel[ 0 ], panels[ 1 ], "newPanel" );
- state( element, 1, 0, 0 );
+ assert.equal( event.originalEvent.type, "click", "originalEvent" );
+ assert.equal( ui.oldTab.length, 1, "oldTab length" );
+ assert.strictEqual( ui.oldTab[ 0 ], tabs[ 0 ], "oldTab" );
+ assert.equal( ui.oldPanel.length, 1, "oldPanel length" );
+ assert.strictEqual( ui.oldPanel[ 0 ], panels[ 0 ], "oldPanel" );
+ assert.equal( ui.newTab.length, 1, "newTab length" );
+ assert.strictEqual( ui.newTab[ 0 ], tabs[ 1 ], "newTab" );
+ assert.equal( ui.newPanel.length, 1, "newPanel length" );
+ assert.strictEqual( ui.newPanel[ 0 ], panels[ 1 ], "newPanel" );
+ state( assert, element, 1, 0, 0 );
} );
anchors.eq( 1 ).trigger( "click" );
- state( element, 0, 1, 0 );
+ state( assert, element, 0, 1, 0 );
// Collapsing
element.one( "tabsbeforeactivate", function( event, ui ) {
- ok( !( "originalEvent" in event ), "originalEvent" );
- equal( ui.oldTab.length, 1, "oldTab length" );
- strictEqual( ui.oldTab[ 0 ], tabs[ 1 ], "oldTab" );
- equal( ui.oldPanel.length, 1, "oldPanel length" );
- strictEqual( ui.oldPanel[ 0 ], panels[ 1 ], "oldPanel" );
- equal( ui.newTab.length, 0, "newTab length" );
- equal( ui.newPanel.length, 0, "newPanel length" );
- state( element, 0, 1, 0 );
+ assert.ok( !( "originalEvent" in event ), "originalEvent" );
+ assert.equal( ui.oldTab.length, 1, "oldTab length" );
+ assert.strictEqual( ui.oldTab[ 0 ], tabs[ 1 ], "oldTab" );
+ assert.equal( ui.oldPanel.length, 1, "oldPanel length" );
+ assert.strictEqual( ui.oldPanel[ 0 ], panels[ 1 ], "oldPanel" );
+ assert.equal( ui.newTab.length, 0, "newTab length" );
+ assert.equal( ui.newPanel.length, 0, "newPanel length" );
+ state( assert, element, 0, 1, 0 );
} );
element.tabs( "option", "active", false );
- state( element, 0, 0, 0 );
+ state( assert, element, 0, 0, 0 );
// Prevent activation
element.one( "tabsbeforeactivate", function( event, ui ) {
- ok( !( "originalEvent" in event ), "originalEvent" );
- equal( ui.oldTab.length, 0, "oldTab length" );
- equal( ui.oldPanel.length, 0, "oldTab" );
- equal( ui.newTab.length, 1, "newTab length" );
- strictEqual( ui.newTab[ 0 ], tabs[ 1 ], "newTab" );
- equal( ui.newPanel.length, 1, "newPanel length" );
- strictEqual( ui.newPanel[ 0 ], panels[ 1 ], "newPanel" );
+ assert.ok( !( "originalEvent" in event ), "originalEvent" );
+ assert.equal( ui.oldTab.length, 0, "oldTab length" );
+ assert.equal( ui.oldPanel.length, 0, "oldTab" );
+ assert.equal( ui.newTab.length, 1, "newTab length" );
+ assert.strictEqual( ui.newTab[ 0 ], tabs[ 1 ], "newTab" );
+ assert.equal( ui.newPanel.length, 1, "newPanel length" );
+ assert.strictEqual( ui.newPanel[ 0 ], panels[ 1 ], "newPanel" );
event.preventDefault();
- state( element, 0, 0, 0 );
+ state( assert, element, 0, 0, 0 );
} );
element.tabs( "option", "active", 1 );
- state( element, 0, 0, 0 );
+ state( assert, element, 0, 0, 0 );
} );
-test( "activate", function() {
- expect( 30 );
+QUnit.test( "activate", function( assert ) {
+ assert.expect( 30 );
var element = $( "#tabs1" ).tabs( {
active: false,
// From collapsed
element.one( "tabsactivate", function( event, ui ) {
- ok( !( "originalEvent" in event ), "originalEvent" );
- equal( ui.oldTab.length, 0, "oldTab length" );
- equal( ui.oldPanel.length, 0, "oldPanel length" );
- equal( ui.newTab.length, 1, "newTab length" );
- strictEqual( ui.newTab[ 0 ], tabs[ 0 ], "newTab" );
- equal( ui.newPanel.length, 1, "newPanel length" );
- strictEqual( ui.newPanel[ 0 ], panels[ 0 ], "newPanel" );
- state( element, 1, 0, 0 );
+ assert.ok( !( "originalEvent" in event ), "originalEvent" );
+ assert.equal( ui.oldTab.length, 0, "oldTab length" );
+ assert.equal( ui.oldPanel.length, 0, "oldPanel length" );
+ assert.equal( ui.newTab.length, 1, "newTab length" );
+ assert.strictEqual( ui.newTab[ 0 ], tabs[ 0 ], "newTab" );
+ assert.equal( ui.newPanel.length, 1, "newPanel length" );
+ assert.strictEqual( ui.newPanel[ 0 ], panels[ 0 ], "newPanel" );
+ state( assert, element, 1, 0, 0 );
} );
element.tabs( "option", "active", 0 );
- state( element, 1, 0, 0 );
+ state( assert, element, 1, 0, 0 );
// Switching tabs
element.one( "tabsactivate", function( event, ui ) {
- equal( event.originalEvent.type, "click", "originalEvent" );
- equal( ui.oldTab.length, 1, "oldTab length" );
- strictEqual( ui.oldTab[ 0 ], tabs[ 0 ], "oldTab" );
- equal( ui.oldPanel.length, 1, "oldPanel length" );
- strictEqual( ui.oldPanel[ 0 ], panels[ 0 ], "oldPanel" );
- equal( ui.newTab.length, 1, "newTab length" );
- strictEqual( ui.newTab[ 0 ], tabs[ 1 ], "newTab" );
- equal( ui.newPanel.length, 1, "newPanel length" );
- strictEqual( ui.newPanel[ 0 ], panels[ 1 ], "newPanel" );
- state( element, 0, 1, 0 );
+ assert.equal( event.originalEvent.type, "click", "originalEvent" );
+ assert.equal( ui.oldTab.length, 1, "oldTab length" );
+ assert.strictEqual( ui.oldTab[ 0 ], tabs[ 0 ], "oldTab" );
+ assert.equal( ui.oldPanel.length, 1, "oldPanel length" );
+ assert.strictEqual( ui.oldPanel[ 0 ], panels[ 0 ], "oldPanel" );
+ assert.equal( ui.newTab.length, 1, "newTab length" );
+ assert.strictEqual( ui.newTab[ 0 ], tabs[ 1 ], "newTab" );
+ assert.equal( ui.newPanel.length, 1, "newPanel length" );
+ assert.strictEqual( ui.newPanel[ 0 ], panels[ 1 ], "newPanel" );
+ state( assert, element, 0, 1, 0 );
} );
anchors.eq( 1 ).trigger( "click" );
- state( element, 0, 1, 0 );
+ state( assert, element, 0, 1, 0 );
// Collapsing
element.one( "tabsactivate", function( event, ui ) {
- ok( !( "originalEvent" in event ), "originalEvent" );
- equal( ui.oldTab.length, 1, "oldTab length" );
- strictEqual( ui.oldTab[ 0 ], tabs[ 1 ], "oldTab" );
- equal( ui.oldPanel.length, 1, "oldPanel length" );
- strictEqual( ui.oldPanel[ 0 ], panels[ 1 ], "oldPanel" );
- equal( ui.newTab.length, 0, "newTab length" );
- equal( ui.newPanel.length, 0, "newPanel length" );
- state( element, 0, 0, 0 );
+ assert.ok( !( "originalEvent" in event ), "originalEvent" );
+ assert.equal( ui.oldTab.length, 1, "oldTab length" );
+ assert.strictEqual( ui.oldTab[ 0 ], tabs[ 1 ], "oldTab" );
+ assert.equal( ui.oldPanel.length, 1, "oldPanel length" );
+ assert.strictEqual( ui.oldPanel[ 0 ], panels[ 1 ], "oldPanel" );
+ assert.equal( ui.newTab.length, 0, "newTab length" );
+ assert.equal( ui.newPanel.length, 0, "newPanel length" );
+ state( assert, element, 0, 0, 0 );
} );
element.tabs( "option", "active", false );
- state( element, 0, 0, 0 );
+ state( assert, element, 0, 0, 0 );
// Prevent activation
element.one( "tabsbeforeactivate", function( event ) {
- ok( true, "tabsbeforeactivate" );
+ assert.ok( true, "tabsbeforeactivate" );
event.preventDefault();
} );
element.one( "tabsactivate", function() {
- ok( false, "tabsactivate" );
+ assert.ok( false, "tabsactivate" );
} );
element.tabs( "option", "active", 1 );
} );
-test( "beforeLoad", function() {
- expect( 32 );
+QUnit.test( "beforeLoad", function( assert ) {
+ assert.expect( 32 );
var tab, panelId, panel,
element = $( "#tabs2" );
panelId = tab.attr( "aria-controls" );
panel = $( "#" + panelId );
- ok( !( "originalEvent" in event ), "originalEvent" );
- ok( "abort" in ui.jqXHR, "jqXHR" );
- ok( ui.ajaxSettings.url, "data/test.html", "ajaxSettings.url" );
- equal( ui.tab.length, 1, "tab length" );
- strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
- equal( ui.panel.length, 1, "panel length" );
- strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
- equal( ui.panel.html(), "", "panel html" );
+ assert.ok( !( "originalEvent" in event ), "originalEvent" );
+ assert.ok( "abort" in ui.jqXHR, "jqXHR" );
+ assert.ok( ui.ajaxSettings.url, "data/test.html", "ajaxSettings.url" );
+ assert.equal( ui.tab.length, 1, "tab length" );
+ assert.strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
+ assert.equal( ui.panel.length, 1, "panel length" );
+ assert.strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
+ assert.equal( ui.panel.html(), "", "panel html" );
event.preventDefault();
- state( element, 0, 0, 1, 0, 0 );
+ state( assert, element, 0, 0, 1, 0, 0 );
} );
element.tabs( { active: 2 } );
- state( element, 0, 0, 1, 0, 0 );
- equal( panel.html(), "", "panel html after" );
+ state( assert, element, 0, 0, 1, 0, 0 );
+ assert.equal( panel.html(), "", "panel html after" );
element.tabs( "destroy" );
// .option()
panelId = tab.attr( "aria-controls" );
panel = $( "#" + panelId );
- ok( !( "originalEvent" in event ), "originalEvent" );
- ok( "abort" in ui.jqXHR, "jqXHR" );
- ok( ui.ajaxSettings.url, "data/test.html", "ajaxSettings.url" );
- equal( ui.tab.length, 1, "tab length" );
- strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
- equal( ui.panel.length, 1, "panel length" );
- strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
- equal( ui.panel.html(), "", "panel html" );
+ assert.ok( !( "originalEvent" in event ), "originalEvent" );
+ assert.ok( "abort" in ui.jqXHR, "jqXHR" );
+ assert.ok( ui.ajaxSettings.url, "data/test.html", "ajaxSettings.url" );
+ assert.equal( ui.tab.length, 1, "tab length" );
+ assert.strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
+ assert.equal( ui.panel.length, 1, "panel length" );
+ assert.strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
+ assert.equal( ui.panel.html(), "", "panel html" );
event.preventDefault();
- state( element, 1, 0, 0, 0, 0 );
+ state( assert, element, 1, 0, 0, 0, 0 );
} );
element.tabs();
element.tabs( "option", "active", 2 );
- state( element, 0, 0, 1, 0, 0 );
- equal( panel.html(), "", "panel html after" );
+ state( assert, element, 0, 0, 1, 0, 0 );
+ assert.equal( panel.html(), "", "panel html after" );
// Click, change panel content
element.one( "tabsbeforeload", function( event, ui ) {
panelId = tab.attr( "aria-controls" );
panel = $( "#" + panelId );
- equal( event.originalEvent.type, "click", "originalEvent" );
- ok( "abort" in ui.jqXHR, "jqXHR" );
- ok( ui.ajaxSettings.url, "data/test.html", "ajaxSettings.url" );
- equal( ui.tab.length, 1, "tab length" );
- strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
- equal( ui.panel.length, 1, "panel length" );
- strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
+ assert.equal( event.originalEvent.type, "click", "originalEvent" );
+ assert.ok( "abort" in ui.jqXHR, "jqXHR" );
+ assert.ok( ui.ajaxSettings.url, "data/test.html", "ajaxSettings.url" );
+ assert.equal( ui.tab.length, 1, "tab length" );
+ assert.strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
+ assert.equal( ui.panel.length, 1, "panel length" );
+ assert.strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
ui.panel.html( "<p>testing</p>" );
event.preventDefault();
- state( element, 0, 0, 1, 0, 0 );
+ state( assert, element, 0, 0, 1, 0, 0 );
} );
element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 3 ).trigger( "click" );
- state( element, 0, 0, 0, 1, 0 );
+ state( assert, element, 0, 0, 0, 1, 0 );
// .toLowerCase() is needed to convert <P> to <p> in old IEs
- equal( panel.html().toLowerCase(), "<p>testing</p>", "panel html after" );
+ assert.equal( panel.html().toLowerCase(), "<p>testing</p>", "panel html after" );
} );
-asyncTest( "load", function() {
- expect( 21 );
+QUnit.test( "load", function( assert ) {
+ var ready = assert.async();
+ assert.expect( 21 );
var tab, panelId, panel,
element = $( "#tabs2" );
panelId = tab.attr( "aria-controls" );
panel = $( "#" + panelId );
- ok( !( "originalEvent" in event ), "originalEvent" );
- equal( ui.tab.length, 1, "tab length" );
- strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
- equal( ui.panel.length, 1, "panel length" );
- strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
- equal( ui.panel.find( "p" ).length, 1, "panel html" );
- state( element, 0, 0, 1, 0, 0 );
+ assert.ok( !( "originalEvent" in event ), "originalEvent" );
+ assert.equal( ui.tab.length, 1, "tab length" );
+ assert.strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
+ assert.equal( ui.panel.length, 1, "panel length" );
+ assert.strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
+ assert.equal( ui.panel.find( "p" ).length, 1, "panel html" );
+ state( assert, element, 0, 0, 1, 0, 0 );
tabsload1();
} );
element.tabs( { active: 2 } );
panelId = tab.attr( "aria-controls" );
panel = $( "#" + panelId );
- ok( !( "originalEvent" in event ), "originalEvent" );
- equal( ui.tab.length, 1, "tab length" );
- strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
- equal( ui.panel.length, 1, "panel length" );
- strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
- equal( ui.panel.find( "p" ).length, 1, "panel html" );
- state( element, 0, 0, 0, 1, 0 );
+ assert.ok( !( "originalEvent" in event ), "originalEvent" );
+ assert.equal( ui.tab.length, 1, "tab length" );
+ assert.strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
+ assert.equal( ui.panel.length, 1, "panel length" );
+ assert.strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
+ assert.equal( ui.panel.find( "p" ).length, 1, "panel html" );
+ state( assert, element, 0, 0, 0, 1, 0 );
tabsload2();
} );
element.tabs( "option", "active", 3 );
function tabsload2() {
- // click, change panel content
+ // Click, change panel content
element.one( "tabsload", function( event, ui ) {
tab = element.find( ".ui-tabs-nav li" ).eq( 4 );
panelId = tab.attr( "aria-controls" );
panel = $( "#" + panelId );
- equal( event.originalEvent.type, "click", "originalEvent" );
- equal( ui.tab.length, 1, "tab length" );
- strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
- equal( ui.panel.length, 1, "panel length" );
- strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
- equal( ui.panel.find( "p" ).length, 1, "panel html" );
- state( element, 0, 0, 0, 0, 1 );
- start();
+ assert.equal( event.originalEvent.type, "click", "originalEvent" );
+ assert.equal( ui.tab.length, 1, "tab length" );
+ assert.strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
+ assert.equal( ui.panel.length, 1, "panel length" );
+ assert.strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
+ assert.equal( ui.panel.find( "p" ).length, 1, "panel html" );
+ state( assert, element, 0, 0, 0, 0, 1 );
+ ready();
} );
element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 4 ).trigger( "click" );
}
], function( $, helper ) {
return $.extend( helper, {
- disabled: function( tabs, state ) {
+ disabled: function( assert, tabs, state ) {
var expected, actual,
internalState = tabs.tabs( "option", "disabled" );
} );
}
- expected = $.map( new Array( tabs.find ( ".ui-tabs-nav li" ).length ), function( _, index ) {
+ expected = $.map( new Array( tabs.find( ".ui-tabs-nav li" ).length ), function( _, index ) {
if ( typeof state === "boolean" ) {
return state ? 1 : 0;
} else {
return 0;
}
- // mixed state - invalid
+ // Mixed state - invalid
return -1;
} ).get();
- deepEqual( tabs.tabs( "option", "disabled" ), state );
- deepEqual( actual, expected );
+ assert.deepEqual( tabs.tabs( "option", "disabled" ), state );
+ assert.deepEqual( actual, expected );
},
- equalHeight: function( tabs, height ) {
+ equalHeight: function( assert, tabs, height ) {
tabs.find( ".ui-tabs-panel" ).each( function() {
// Handle overly-precise values
var actualHeight = parseFloat( $( this ).outerHeight().toFixed( 1 ) );
- equal( actualHeight, height );
+ assert.equal( actualHeight, height );
} );
},
- state: function( tabs ) {
- var expected = $.makeArray( arguments ).slice( 1 ),
+ state: function( assert, tabs ) {
+ var expected = $.makeArray( arguments ).slice( 2 ),
actual = tabs.find( ".ui-tabs-nav li" ).map( function() {
var tab = $( this ),
panel = $( $.ui.tabs.prototype._sanitizeSelector(
if ( !tabIsActive && !panelIsActive ) {
return 0;
}
- return -1; // mixed state - invalid
+ return -1; // Mixed state - invalid
} ).get();
- deepEqual( actual, expected );
+ assert.deepEqual( actual, expected );
}
} );
define( [
+ "qunit",
"jquery",
"./helper",
"ui/widgets/tabs"
-], function( $, testHelper ) {
+], function( QUnit, $, testHelper ) {
var disabled = testHelper.disabled,
state = testHelper.state;
-module( "tabs: methods" );
+QUnit.module( "tabs: methods" );
-test( "destroy", function( assert ) {
- expect( 2 );
+QUnit.test( "destroy", function( assert ) {
+ assert.expect( 2 );
assert.domEqual( "#tabs1", function() {
$( "#tabs1" ).tabs().tabs( "destroy" );
} );
} );
} );
-asyncTest( "destroy - ajax", function( assert ) {
- expect( 1 );
+QUnit.test( "destroy - ajax", function( assert ) {
+ var ready = assert.async();
+ assert.expect( 1 );
assert.domEqual( "#tabs2", function( done ) {
var element = $( "#tabs2" ).tabs( {
load: function() {
setTimeout( function() {
element.tabs( "destroy" );
done();
- start();
+ ready();
} );
}
} );
} );
} );
-test( "enable", function() {
- expect( 8 );
+QUnit.test( "enable", function( assert ) {
+ assert.expect( 8 );
var element = $( "#tabs1" ).tabs( { disabled: true } );
- disabled( element, true );
+ disabled( assert, element, true );
element.tabs( "enable" );
- disabled( element, false );
+ disabled( assert, element, false );
element.tabs( "destroy" );
element.tabs( { disabled: [ 0, 1 ] } );
- disabled( element, [ 0, 1 ] );
+ disabled( assert, element, [ 0, 1 ] );
element.tabs( "enable" );
- disabled( element, false );
+ disabled( assert, element, false );
} );
-test( "enable( index )", function() {
- expect( 10 );
+QUnit.test( "enable( index )", function( assert ) {
+ assert.expect( 10 );
var element = $( "#tabs1" ).tabs( { disabled: true } );
- disabled( element, true );
+ disabled( assert, element, true );
// fully disabled -> partially disabled
element.tabs( "enable", 1 );
- disabled( element, [ 0, 2 ] );
+ disabled( assert, element, [ 0, 2 ] );
// partially disabled -> partially disabled
element.tabs( "enable", 2 );
- disabled( element, [ 0 ] );
+ disabled( assert, element, [ 0 ] );
// already enabled tab, no change
element.tabs( "enable", 2 );
- disabled( element, [ 0 ] );
+ disabled( assert, element, [ 0 ] );
// partially disabled -> fully enabled
element.tabs( "enable", 0 );
- disabled( element, false );
+ disabled( assert, element, false );
} );
-test( "disable", function() {
- expect( 8 );
+QUnit.test( "disable", function( assert ) {
+ assert.expect( 8 );
var element = $( "#tabs1" ).tabs( { disabled: false } );
- disabled( element, false );
+ disabled( assert, element, false );
element.tabs( "disable" );
- disabled( element, true );
+ disabled( assert, element, true );
element.tabs( "destroy" );
element.tabs( { disabled: [ 0, 1 ] } );
- disabled( element, [ 0, 1 ] );
+ disabled( assert, element, [ 0, 1 ] );
element.tabs( "disable" );
- disabled( element, true );
+ disabled( assert, element, true );
} );
-test( "disable( index )", function() {
- expect( 10 );
+QUnit.test( "disable( index )", function( assert ) {
+ assert.expect( 10 );
var element = $( "#tabs1" ).tabs( { disabled: false } );
- disabled( element, false );
+ disabled( assert, element, false );
// fully enabled -> partially disabled
element.tabs( "disable", 1 );
- disabled( element, [ 1 ] );
+ disabled( assert, element, [ 1 ] );
// partially disabled -> partially disabled
element.tabs( "disable", 2 );
- disabled( element, [ 1, 2 ] );
+ disabled( assert, element, [ 1, 2 ] );
// already disabled tab, no change
element.tabs( "disable", 2 );
- disabled( element, [ 1, 2 ] );
+ disabled( assert, element, [ 1, 2 ] );
// partially disabled -> fully disabled
element.tabs( "disable", 0 );
- disabled( element, true );
+ disabled( assert, element, true );
} );
-test( "refresh", function() {
- expect( 27 );
+QUnit.test( "refresh", function( assert ) {
+ assert.expect( 27 );
var element = $( "#tabs1" ).tabs();
- state( element, 1, 0, 0 );
- disabled( element, false );
+ state( assert, element, 1, 0, 0 );
+ disabled( assert, element, false );
// Disable tab via markup
element.find( ".ui-tabs-nav li" ).eq( 1 ).addClass( "ui-state-disabled" );
element.tabs( "refresh" );
- state( element, 1, 0, 0 );
- disabled( element, [ 1 ] );
+ state( assert, element, 1, 0, 0 );
+ disabled( assert, element, [ 1 ] );
// Add remote tab
element.find( ".ui-tabs-nav" ).append( "<li id='newTab'><a href='data/test.html'>new</a></li>" );
element.tabs( "refresh" );
- state( element, 1, 0, 0, 0 );
- disabled( element, [ 1 ] );
- equal( element.find( "#" + $( "#newTab" ).attr( "aria-controls" ) ).length, 1,
+ state( assert, element, 1, 0, 0, 0 );
+ disabled( assert, element, [ 1 ] );
+ assert.equal( element.find( "#" + $( "#newTab" ).attr( "aria-controls" ) ).length, 1,
"panel added for remote tab" );
// Remove all tabs
element.find( ".ui-tabs-nav li, .ui-tabs-panel" ).remove();
element.tabs( "refresh" );
- state( element );
- equal( element.tabs( "option", "active" ), false, "no active tab" );
+ state( assert, element );
+ assert.equal( element.tabs( "option", "active" ), false, "no active tab" );
// Add tabs
element.find( ".ui-tabs-nav" )
.append( "<div id='newTab4'>new 4</div>" )
.append( "<div id='newTab5'>new 5</div>" );
element.tabs( "refresh" );
- state( element, 0, 0, 0, 0 );
- disabled( element, [ 0 ] );
+ state( assert, element, 0, 0, 0, 0 );
+ disabled( assert, element, [ 0 ] );
// Activate third tab
element.tabs( "option", "active", 2 );
- state( element, 0, 0, 1, 0 );
- disabled( element, [ 0 ] );
+ state( assert, element, 0, 0, 1, 0 );
+ disabled( assert, element, [ 0 ] );
// Remove fourth tab, third tab should stay active
element.find( ".ui-tabs-nav li" ).eq( 3 ).remove();
element.find( ".ui-tabs-panel" ).eq( 3 ).remove();
element.tabs( "refresh" );
- state( element, 0, 0, 1 );
- disabled( element, [ 0 ] );
+ state( assert, element, 0, 0, 1 );
+ disabled( assert, element, [ 0 ] );
// Remove third (active) tab, second tab should become active
element.find( ".ui-tabs-nav li" ).eq( 2 ).remove();
element.find( ".ui-tabs-panel" ).eq( 2 ).remove();
element.tabs( "refresh" );
- state( element, 0, 1 );
- disabled( element, [ 0 ] );
+ state( assert, element, 0, 1 );
+ disabled( assert, element, [ 0 ] );
// Remove first tab, previously active tab (now first) should stay active
element.find( ".ui-tabs-nav li" ).eq( 0 ).remove();
element.find( ".ui-tabs-panel" ).eq( 0 ).remove();
element.tabs( "refresh" );
- state( element, 1 );
- disabled( element, false );
+ state( assert, element, 1 );
+ disabled( assert, element, false );
} );
-test( "refresh - looping", function() {
- expect( 6 );
+QUnit.test( "refresh - looping", function( assert ) {
+ assert.expect( 6 );
var element = $( "#tabs1" ).tabs( {
disabled: [ 0 ],
active: 1
} );
- state( element, 0, 1, 0 );
- disabled( element, [ 0 ] );
+ state( assert, element, 0, 1, 0 );
+ disabled( assert, element, [ 0 ] );
// Remove active, jump to previous
// previous is disabled, just back one more
// activate last tab
element.find( ".ui-tabs-nav li" ).eq( 2 ).remove();
element.tabs( "refresh" );
- state( element, 0, 1 );
- disabled( element, [ 0 ] );
+ state( assert, element, 0, 1 );
+ disabled( assert, element, [ 0 ] );
} );
-asyncTest( "load", function() {
- expect( 30 );
+QUnit.test( "load", function( assert ) {
+ var ready = assert.async();
+ assert.expect( 30 );
var element = $( "#tabs2" ).tabs();
panelId = tab.attr( "aria-controls" ),
panel = $( "#" + panelId );
- ok( !( "originalEvent" in event ), "originalEvent" );
- equal( ui.tab.length, 1, "tab length" );
- strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
- equal( ui.panel.length, 1, "panel length" );
- strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
- state( element, 1, 0, 0, 0, 0 );
+ assert.ok( !( "originalEvent" in event ), "originalEvent" );
+ assert.equal( ui.tab.length, 1, "tab length" );
+ assert.strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
+ assert.equal( ui.panel.length, 1, "panel length" );
+ assert.strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
+ state( assert, element, 1, 0, 0, 0, 0 );
} );
element.one( "tabsload", function( event, ui ) {
panelId = tab.attr( "aria-controls" ),
panel = $( "#" + panelId );
- ok( !( "originalEvent" in event ), "originalEvent" );
- equal( uiTab.length, 1, "tab length" );
- strictEqual( uiTab[ 0 ], tab[ 0 ], "tab" );
- equal( uiPanel.length, 1, "panel length" );
- strictEqual( uiPanel[ 0 ], panel[ 0 ], "panel" );
- equal( uiPanel.find( "p" ).length, 1, "panel html" );
- state( element, 1, 0, 0, 0, 0 );
+ assert.ok( !( "originalEvent" in event ), "originalEvent" );
+ assert.equal( uiTab.length, 1, "tab length" );
+ assert.strictEqual( uiTab[ 0 ], tab[ 0 ], "tab" );
+ assert.equal( uiPanel.length, 1, "panel length" );
+ assert.strictEqual( uiPanel[ 0 ], panel[ 0 ], "panel" );
+ assert.equal( uiPanel.find( "p" ).length, 1, "panel html" );
+ state( assert, element, 1, 0, 0, 0, 0 );
setTimeout( tabsload1 );
} );
element.tabs( "load", 3 );
- state( element, 1, 0, 0, 0, 0 );
+ state( assert, element, 1, 0, 0, 0, 0 );
function tabsload1() {
// no need to test details of event (tested in events tests)
element.one( "tabsbeforeload", function() {
- ok( true, "tabsbeforeload invoked" );
+ assert.ok( true, "tabsbeforeload invoked" );
} );
element.one( "tabsload", function() {
- ok( true, "tabsload invoked" );
+ assert.ok( true, "tabsload invoked" );
setTimeout( tabsload2 );
} );
element.tabs( "option", "active", 3 );
- state( element, 0, 0, 0, 1, 0 );
+ state( assert, element, 0, 0, 0, 1, 0 );
}
function tabsload2() {
panelId = tab.attr( "aria-controls" ),
panel = $( "#" + panelId );
- ok( !( "originalEvent" in event ), "originalEvent" );
- equal( ui.tab.length, 1, "tab length" );
- strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
- equal( ui.panel.length, 1, "panel length" );
- strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
- state( element, 0, 0, 0, 1, 0 );
+ assert.ok( !( "originalEvent" in event ), "originalEvent" );
+ assert.equal( ui.tab.length, 1, "tab length" );
+ assert.strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
+ assert.equal( ui.panel.length, 1, "panel length" );
+ assert.strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
+ state( assert, element, 0, 0, 0, 1, 0 );
} );
element.one( "tabsload", function( event, ui ) {
panelId = tab.attr( "aria-controls" ),
panel = $( "#" + panelId );
- ok( !( "originalEvent" in event ), "originalEvent" );
- equal( uiTab.length, 1, "tab length" );
- strictEqual( uiTab[ 0 ], tab[ 0 ], "tab" );
- equal( uiPanel.length, 1, "panel length" );
- strictEqual( uiPanel[ 0 ], panel[ 0 ], "panel" );
- state( element, 0, 0, 0, 1, 0 );
- start();
+ assert.ok( !( "originalEvent" in event ), "originalEvent" );
+ assert.equal( uiTab.length, 1, "tab length" );
+ assert.strictEqual( uiTab[ 0 ], tab[ 0 ], "tab" );
+ assert.equal( uiPanel.length, 1, "panel length" );
+ assert.strictEqual( uiPanel[ 0 ], panel[ 0 ], "panel" );
+ state( assert, element, 0, 0, 0, 1, 0 );
+ ready();
} );
element.tabs( "load", 3 );
- state( element, 0, 0, 0, 1, 0 );
+ state( assert, element, 0, 0, 0, 1, 0 );
}
} );
-test( "widget", function() {
- expect( 2 );
+QUnit.test( "widget", function( assert ) {
+ assert.expect( 2 );
var element = $( "#tabs1" ).tabs(),
widgetElement = element.tabs( "widget" );
- equal( widgetElement.length, 1, "one element" );
- strictEqual( widgetElement[ 0 ], element[ 0 ], "same element" );
+ assert.equal( widgetElement.length, 1, "one element" );
+ assert.strictEqual( widgetElement[ 0 ], element[ 0 ], "same element" );
} );
} );
define( [
+ "qunit",
"jquery",
"./helper",
"ui/widgets/tabs"
-], function( $, testHelper ) {
+], function( QUnit, $, testHelper ) {
var disabled = testHelper.disabled,
equalHeight = testHelper.equalHeight,
state = testHelper.state;
-module( "tabs: options" );
+QUnit.module( "tabs: options" );
-test( "{ active: default }", function() {
- expect( 6 );
+QUnit.test( "{ active: default }", function( assert ) {
+ assert.expect( 6 );
var element = $( "#tabs1" ).tabs();
- equal( element.tabs( "option", "active" ), 0, "should be 0 by default" );
- state( element, 1, 0, 0 );
+ assert.equal( element.tabs( "option", "active" ), 0, "should be 0 by default" );
+ state( assert, element, 1, 0, 0 );
element.tabs( "destroy" );
location.hash = "#fragment-3";
element = $( "#tabs1" ).tabs();
- equal( element.tabs( "option", "active" ), 2, "should be 2 based on URL" );
- state( element, 0, 0, 1 );
+ assert.equal( element.tabs( "option", "active" ), 2, "should be 2 based on URL" );
+ state( assert, element, 0, 0, 1 );
element.tabs( "destroy" );
location.hash = "#custom-id";
element = $( "#tabs2" ).tabs();
- equal( element.tabs( "option", "active" ), 3, "should be 3 based on URL" );
- state( element, 0, 0, 0, 1, 0 );
+ assert.equal( element.tabs( "option", "active" ), 3, "should be 3 based on URL" );
+ state( assert, element, 0, 0, 0, 1, 0 );
element.tabs( "destroy" );
location.hash = "#";
} );
-test( "{ active: false }", function() {
- expect( 7 );
+QUnit.test( "{ active: false }", function( assert ) {
+ assert.expect( 7 );
var element = $( "#tabs1" ).tabs( {
active: false,
collapsible: true
} );
- state( element, 0, 0, 0 );
- equal( element.find( ".ui-tabs-nav .ui-state-active" ).length, 0, "no tabs selected" );
- strictEqual( element.tabs( "option", "active" ), false );
+ state( assert, element, 0, 0, 0 );
+ assert.equal( element.find( ".ui-tabs-nav .ui-state-active" ).length, 0, "no tabs selected" );
+ assert.strictEqual( element.tabs( "option", "active" ), false );
element.tabs( "option", "collapsible", false );
- state( element, 1, 0, 0 );
- equal( element.tabs( "option", "active" ), 0 );
+ state( assert, element, 1, 0, 0 );
+ assert.equal( element.tabs( "option", "active" ), 0 );
element.tabs( "destroy" );
element.tabs( {
active: false
} );
- state( element, 1, 0, 0 );
- strictEqual( element.tabs( "option", "active" ), 0 );
+ state( assert, element, 1, 0, 0 );
+ assert.strictEqual( element.tabs( "option", "active" ), 0 );
} );
-test( "{ active: Number }", function() {
- expect( 8 );
+QUnit.test( "{ active: Number }", function( assert ) {
+ assert.expect( 8 );
var element = $( "#tabs1" ).tabs( {
active: 2
} );
- equal( element.tabs( "option", "active" ), 2 );
- state( element, 0, 0, 1 );
+ assert.equal( element.tabs( "option", "active" ), 2 );
+ state( assert, element, 0, 0, 1 );
element.tabs( "option", "active", 0 );
- equal( element.tabs( "option", "active" ), 0 );
- state( element, 1, 0, 0 );
+ assert.equal( element.tabs( "option", "active" ), 0 );
+ state( assert, element, 1, 0, 0 );
element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 1 ).trigger( "click" );
- equal( element.tabs( "option", "active" ), 1 );
- state( element, 0, 1, 0 );
+ assert.equal( element.tabs( "option", "active" ), 1 );
+ state( assert, element, 0, 1, 0 );
element.tabs( "option", "active", 10 );
- equal( element.tabs( "option", "active" ), 1 );
- state( element, 0, 1, 0 );
+ assert.equal( element.tabs( "option", "active" ), 1 );
+ state( assert, element, 0, 1, 0 );
} );
-test( "{ active: -Number }", function() {
- expect( 8 );
+QUnit.test( "{ active: -Number }", function( assert ) {
+ assert.expect( 8 );
var element = $( "#tabs1" ).tabs( {
active: -1
} );
- equal( element.tabs( "option", "active" ), 2 );
- state( element, 0, 0, 1 );
+ assert.equal( element.tabs( "option", "active" ), 2 );
+ state( assert, element, 0, 0, 1 );
element.tabs( "option", "active", -2 );
- equal( element.tabs( "option", "active" ), 1 );
- state( element, 0, 1, 0 );
+ assert.equal( element.tabs( "option", "active" ), 1 );
+ state( assert, element, 0, 1, 0 );
element.tabs( "option", "active", -10 );
- equal( element.tabs( "option", "active" ), 1 );
- state( element, 0, 1, 0 );
+ assert.equal( element.tabs( "option", "active" ), 1 );
+ state( assert, element, 0, 1, 0 );
element.tabs( "option", "active", -3 );
- equal( element.tabs( "option", "active" ), 0 );
- state( element, 1, 0, 0 );
+ assert.equal( element.tabs( "option", "active" ), 0 );
+ state( assert, element, 1, 0, 0 );
} );
-test( "active - mismatched tab/panel order", function() {
- expect( 3 );
+QUnit.test( "active - mismatched tab/panel order", function( assert ) {
+ assert.expect( 3 );
location.hash = "#tabs7-2";
var element = $( "#tabs7" ).tabs();
- equal( element.tabs( "option", "active" ), 1, "should be 1 based on URL" );
- state( element, 0, 1 );
+ assert.equal( element.tabs( "option", "active" ), 1, "should be 1 based on URL" );
+ state( assert, element, 0, 1 );
element.tabs( "option", "active", 0 );
- state( element, 1, 0 );
+ state( assert, element, 1, 0 );
location.hash = "#";
} );
-test( "collapsible", function( assert ) {
- expect( 13 );
+QUnit.test( "collapsible", function( assert ) {
+ assert.expect( 13 );
var element = $( "#tabs1" ).tabs( {
active: 1,
} );
assert.hasClasses( element, "ui-tabs-collapsible" );
element.tabs( "option", "active", false );
- equal( element.tabs( "option", "active" ), false );
- state( element, 0, 0, 0 );
+ assert.equal( element.tabs( "option", "active" ), false );
+ state( assert, element, 0, 0, 0 );
element.tabs( "option", "active", 1 );
- equal( element.tabs( "option", "active" ), 1 );
- state( element, 0, 1, 0 );
+ assert.equal( element.tabs( "option", "active" ), 1 );
+ state( assert, element, 0, 1, 0 );
element.find( ".ui-state-active .ui-tabs-anchor" ).trigger( "click" );
- equal( element.tabs( "option", "active" ), false );
- state( element, 0, 0, 0 );
+ assert.equal( element.tabs( "option", "active" ), false );
+ state( assert, element, 0, 0, 0 );
element.tabs( "option", "collapsible", false );
assert.lacksClasses( element, "ui-tabs-collapsible" );
collapsible: false
} );
element.tabs( "option", "active", false );
- equal( element.tabs( "option", "active" ), 1 );
- state( element, 0, 1, 0 );
+ assert.equal( element.tabs( "option", "active" ), 1 );
+ state( assert, element, 0, 1, 0 );
element.find( ".ui-state-active .ui-tabs-anchor" ).eq( 1 ).trigger( "click" );
- equal( element.tabs( "option", "active" ), 1 );
- state( element, 0, 1, 0 );
+ assert.equal( element.tabs( "option", "active" ), 1 );
+ state( assert, element, 0, 1, 0 );
} );
-test( "disabled", function( assert ) {
- expect( 23 );
+QUnit.test( "disabled", function( assert ) {
+ assert.expect( 23 );
// Fully enabled by default
var event,
element = $( "#tabs1" ).tabs();
- disabled( element, false );
+ disabled( assert, element, false );
assert.lacksClasses( element.tabs( "widget" ), "ui-state-disabled" );
assert.lacksClasses( element.tabs( "widget" ), "ui-tabs-disabled" );
- ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" );
+ assert.ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" );
// Disable single tab
element.tabs( "option", "disabled", [ 1 ] );
- disabled( element, [ 1 ] );
+ disabled( assert, element, [ 1 ] );
assert.lacksClasses( element.tabs( "widget" ), "ui-state-disabled" );
assert.lacksClasses( element.tabs( "widget" ), "ui-tabs-disabled" );
- ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" );
+ assert.ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" );
// Disabled active tab
element.tabs( "option", "disabled", [ 0, 1 ] );
- disabled( element, [ 0, 1 ] );
+ disabled( assert, element, [ 0, 1 ] );
assert.lacksClasses( element.tabs( "widget" ), "ui-state-disabled" );
assert.lacksClasses( element.tabs( "widget" ), "ui-tabs-disabled" );
- ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" );
+ assert.ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" );
// Disable all tabs
element.tabs( "option", "disabled", [ 0, 1, 2 ] );
- disabled( element, true );
+ disabled( assert, element, true );
assert.lacksClasses( element.tabs( "widget" ), "ui-state-disabled" );
assert.hasClasses( element.tabs( "widget" ), "ui-tabs-disabled" );
- ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" );
+ assert.ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" );
event = $.Event( "click" );
element.find( ".ui-tabs-anchor" ).eq( 0 ).trigger( event );
- ok( event.isDefaultPrevented(), "click is prevented for disabled tab" );
+ assert.ok( event.isDefaultPrevented(), "click is prevented for disabled tab" );
// Enable all tabs
element.tabs( "option", "disabled", [] );
- disabled( element, false );
+ disabled( assert, element, false );
} );
-test( "{ event: null }", function() {
- expect( 5 );
+QUnit.test( "{ event: null }", function( assert ) {
+ assert.expect( 5 );
var element = $( "#tabs1" ).tabs( {
event: null
} );
- state( element, 1, 0, 0 );
+ state( assert, element, 1, 0, 0 );
element.tabs( "option", "active", 1 );
- equal( element.tabs( "option", "active" ), 1 );
- state( element, 0, 1, 0 );
+ assert.equal( element.tabs( "option", "active" ), 1 );
+ state( assert, element, 0, 1, 0 );
// Ensure default click handler isn't bound
element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 2 ).trigger( "click" );
- equal( element.tabs( "option", "active" ), 1 );
- state( element, 0, 1, 0 );
+ assert.equal( element.tabs( "option", "active" ), 1 );
+ state( assert, element, 0, 1, 0 );
} );
-test( "{ event: custom }", function() {
- expect( 11 );
+QUnit.test( "{ event: custom }", function( assert ) {
+ assert.expect( 11 );
var element = $( "#tabs1" ).tabs( {
event: "custom1 custom2"
} );
- state( element, 1, 0, 0 );
+ state( assert, element, 1, 0, 0 );
element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 1 ).trigger( "custom1" );
- equal( element.tabs( "option", "active" ), 1 );
- state( element, 0, 1, 0 );
+ assert.equal( element.tabs( "option", "active" ), 1 );
+ state( assert, element, 0, 1, 0 );
// Ensure default click handler isn't bound
element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 2 ).trigger( "click" );
- equal( element.tabs( "option", "active" ), 1 );
- state( element, 0, 1, 0 );
+ assert.equal( element.tabs( "option", "active" ), 1 );
+ state( assert, element, 0, 1, 0 );
element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 2 ).trigger( "custom2" );
- equal( element.tabs( "option", "active" ), 2 );
- state( element, 0, 0, 1 );
+ assert.equal( element.tabs( "option", "active" ), 2 );
+ state( assert, element, 0, 0, 1 );
element.tabs( "option", "event", "custom3" );
// Ensure old event handlers are unbound
element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 1 ).trigger( "custom1" );
- equal( element.tabs( "option", "active" ), 2 );
- state( element, 0, 0, 1 );
+ assert.equal( element.tabs( "option", "active" ), 2 );
+ state( assert, element, 0, 0, 1 );
element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 1 ).trigger( "custom3" );
- equal( element.tabs( "option", "active" ), 1 );
- state( element, 0, 1, 0 );
+ assert.equal( element.tabs( "option", "active" ), 1 );
+ state( assert, element, 0, 1, 0 );
} );
-test( "{ heightStyle: 'auto' }", function() {
- expect( 2 );
+QUnit.test( "{ heightStyle: 'auto' }", function( assert ) {
+ assert.expect( 2 );
var element = $( "#tabs8" ).tabs( { heightStyle: "auto" } );
- equalHeight( element, 45 );
+ equalHeight( assert, element, 45 );
} );
-test( "{ heightStyle: 'content' }", function() {
- expect( 2 );
+QUnit.test( "{ heightStyle: 'content' }", function( assert ) {
+ assert.expect( 2 );
var element = $( "#tabs8" ).tabs( { heightStyle: "content" } ),
sizes = element.find( ".ui-tabs-panel" ).map( function() {
return $( this ).height();
} ).get();
- equal( sizes[ 0 ], 45 );
- equal( sizes[ 1 ], 15 );
+ assert.equal( sizes[ 0 ], 45 );
+ assert.equal( sizes[ 1 ], 15 );
} );
-test( "{ heightStyle: 'fill' }", function() {
- expect( 4 );
+QUnit.test( "{ heightStyle: 'fill' }", function( assert ) {
+ assert.expect( 4 );
$( "#tabs8Wrapper" ).height( 500 );
var element = $( "#tabs8" ).tabs( { heightStyle: "fill" } );
- equalHeight( element, 485 );
+ equalHeight( assert, element, 485 );
element.tabs( "destroy" );
element = $( "#tabs8" ).css( {
"padding": "1px 0"
} );
element.tabs( { heightStyle: "fill" } );
- equalHeight( element, 481 );
+ equalHeight( assert, element, 481 );
} );
-test( "{ heightStyle: 'fill' } with sibling", function() {
- expect( 2 );
+QUnit.test( "{ heightStyle: 'fill' } with sibling", function( assert ) {
+ assert.expect( 2 );
$( "#tabs8Wrapper" ).height( 500 );
$( "<p>Lorem Ipsum</p>" )
.css( {
} )
.prependTo( "#tabs8Wrapper" );
var element = $( "#tabs8" ).tabs( { heightStyle: "fill" } );
- equalHeight( element, 385 );
+ equalHeight( assert, element, 385 );
} );
-test( "{ heightStyle: 'fill' } with multiple siblings", function() {
- expect( 2 );
+QUnit.test( "{ heightStyle: 'fill' } with multiple siblings", function( assert ) {
+ assert.expect( 2 );
$( "#tabs8Wrapper" ).height( 500 );
$( "<p>Lorem Ipsum</p>" )
.css( {
} )
.prependTo( "#tabs8Wrapper" );
var element = $( "#tabs8" ).tabs( { heightStyle: "fill" } );
- equalHeight( element, 335 );
+ equalHeight( assert, element, 335 );
} );
-test( "hide and show: false", function() {
- expect( 3 );
+QUnit.test( "hide and show: false", function( assert ) {
+ assert.expect( 3 );
var element = $( "#tabs1" ).tabs( {
show: false,
hide: false
widget = element.tabs( "instance" ),
panels = element.find( ".ui-tabs-panel" );
widget._show = function() {
- ok( false, "_show() called" );
+ assert.ok( false, "_show() called" );
};
widget._hide = function() {
- ok( false, "_hide() called" );
+ assert.ok( false, "_hide() called" );
};
- ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
+ assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
element.tabs( "option", "active", 1 );
- ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
- ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
+ assert.ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
+ assert.ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
} );
-asyncTest( "hide and show - animation", function() {
- expect( 5 );
+QUnit.test( "hide and show - animation", function( assert ) {
+ var ready = assert.async();
+ assert.expect( 5 );
var element = $( "#tabs1" ).tabs( {
show: "drop",
hide: 2000
widget = element.tabs( "instance" ),
panels = element.find( ".ui-tabs-panel" );
widget._show = function( element, options, callback ) {
- strictEqual( element[ 0 ], panels[ 1 ], "correct element in _show()" );
- equal( options, "drop", "correct options in _show()" );
+ assert.strictEqual( element[ 0 ], panels[ 1 ], "correct element in _show()" );
+ assert.equal( options, "drop", "correct options in _show()" );
setTimeout( function() {
callback();
} );
};
widget._hide = function( element, options, callback ) {
- strictEqual( element[ 0 ], panels[ 0 ], "correct element in _hide()" );
- equal( options, 2000, "correct options in _hide()" );
+ assert.strictEqual( element[ 0 ], panels[ 0 ], "correct element in _hide()" );
+ assert.equal( options, 2000, "correct options in _hide()" );
setTimeout( function() {
callback();
- start();
+ ready();
} );
};
- ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
+ assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
element.tabs( "option", "active", 1 );
} );