aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/tabs/tabs_deprecated.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/tabs/tabs_deprecated.js')
-rw-r--r--tests/unit/tabs/tabs_deprecated.js110
1 files changed, 57 insertions, 53 deletions
diff --git a/tests/unit/tabs/tabs_deprecated.js b/tests/unit/tabs/tabs_deprecated.js
index 80bc4a326..8386a13ac 100644
--- a/tests/unit/tabs/tabs_deprecated.js
+++ b/tests/unit/tabs/tabs_deprecated.js
@@ -1,5 +1,7 @@
(function( $ ) {
+var state = TestHelpers.tabs.state;
+
module( "tabs (deprecated): core" );
test( "panel ids", function() {
@@ -48,17 +50,17 @@ asyncTest( "cache", function() {
cache: true
});
element.one( "tabsshow", function( event, ui ) {
- tabs_state( element, 0, 0, 1, 0, 0 );
+ state( element, 0, 0, 1, 0, 0 );
});
element.one( "tabsload", function( event, ui ) {
ok( true, "tabsload" );
setTimeout(function() {
element.tabs( "option", "active", 0 );
- tabs_state( element, 1, 0, 0, 0, 0 );
+ state( element, 1, 0, 0, 0, 0 );
element.one( "tabsshow", function( event, ui ) {
- tabs_state( element, 0, 0, 1, 0, 0 );
+ state( element, 0, 0, 1, 0, 0 );
});
element.one( "tabsload", function( event, ui ) {
ok( false, "should be cached" );
@@ -68,7 +70,7 @@ asyncTest( "cache", function() {
}, 1 );
});
element.tabs( "option", "active", 2 );
- tabs_state( element, 0, 0, 1, 0, 0 );
+ state( element, 0, 0, 1, 0, 0 );
});
test( "idPrefix", function() {
@@ -89,10 +91,11 @@ test( "tabTemplate + panelTemplate", function() {
// defaults are tested in the add method test
expect( 11 );
- var element = $( "#tabs2" ).tabs({
- tabTemplate: "<li class='customTab'><a href='http://example.com/#{href}'>#{label}</a></li>",
- panelTemplate: "<div class='customPanel'></div>"
- });
+ var tab, anchor,
+ element = $( "#tabs2" ).tabs({
+ tabTemplate: "<li class='customTab'><a href='http://example.com/#{href}'>#{label}</a></li>",
+ panelTemplate: "<div class='customPanel'></div>"
+ });
element.one( "tabsadd", function( event, ui ) {
var anchor = $( ui.tab );
equal( ui.index, 5, "ui.index" );
@@ -103,8 +106,8 @@ test( "tabTemplate + panelTemplate", function() {
ok( $( ui.panel ).hasClass( "customPanel" ), "panel custom class" );
});
element.tabs( "add", "#new", "New" );
- var tab = element.find( ".ui-tabs-nav li" ).last(),
- anchor = tab.find( "a" );
+ tab = element.find( ".ui-tabs-nav li" ).last();
+ anchor = tab.find( "a" );
equal( tab.text(), "New", "label" );
ok( tab.hasClass( "customTab" ), "tab custom class" );
equal( anchor.attr( "href" ), "http://example.com/#new", "href" );
@@ -170,50 +173,50 @@ test( "selected", function() {
var element = $( "#tabs1" ).tabs();
equal( element.tabs( "option", "selected" ), 0, "should be 0 by default" );
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
element.tabs( "destroy" );
location.hash = "#fragment-3";
element = $( "#tabs1" ).tabs();
equal( element.tabs( "option", "selected" ), 2, "should be 2 based on URL" );
- tabs_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.tabs( "destroy" );
el = $('#tabs1').tabs({
selected: -1,
collapsible: true
});
- tabs_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
equal( element.find( ".ui-tabs-nav .ui-state-active" ).size(), 0, "no tabs selected" );
strictEqual( element.tabs( "option", "selected" ), -1 );
element.tabs( "option", "collapsible", false );
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
equal( element.tabs( "option", "selected" ), 0 );
element.tabs( "destroy" );
element.tabs({
selected: -1
});
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
strictEqual( element.tabs( "option", "selected" ), 0 );
element.tabs( "destroy" );
element.tabs({ selected: 2 });
equal( element.tabs( "option", "selected" ), 2 );
- tabs_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.tabs( "option", "selected", 0 );
equal( element.tabs( "option", "selected" ), 0 );
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
element.find( ".ui-tabs-nav a" ).eq( 1 ).click();
equal( element.tabs( "option", "selected" ), 1 );
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.tabs( "option", "selected", 10 );
equal( element.tabs( "option", "selected" ), 1 );
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
location.hash = "#";
});
@@ -236,7 +239,7 @@ asyncTest( "load", function() {
strictEqual( ui.tab, tab[ 0 ], "tab" );
strictEqual( ui.panel, panel[ 0 ], "panel" );
equal( $( ui.panel ).find( "p" ).length, 1, "panel html" );
- tabs_state( element, 0, 0, 1, 0, 0 );
+ state( element, 0, 0, 1, 0, 0 );
tabsload1();
});
element.tabs({ active: 2 });
@@ -252,7 +255,7 @@ asyncTest( "load", function() {
strictEqual( ui.tab, tab[ 0 ], "tab" );
strictEqual( ui.panel, panel[ 0 ], "panel" );
equal( $( ui.panel ).find( "p" ).length, 1, "panel html" );
- tabs_state( element, 0, 0, 0, 1, 0 );
+ state( element, 0, 0, 0, 1, 0 );
tabsload2();
});
element.tabs( "option", "active", 3 );
@@ -269,7 +272,7 @@ asyncTest( "load", function() {
strictEqual( ui.tab, tab[ 0 ], "tab" );
strictEqual( ui.panel, panel[ 0 ], "panel" );
equal( $( ui.panel ).find( "p" ).length, 1, "panel html" );
- tabs_state( element, 0, 0, 0, 0, 1 );
+ state( element, 0, 0, 0, 0, 1 );
start();
});
element.find( ".ui-tabs-nav a" ).eq( 4 ).click();
@@ -324,10 +327,10 @@ test( "show", function() {
strictEqual( ui.tab, tabs[ 0 ], "ui.tab" );
strictEqual( ui.panel, panels[ 0 ], "ui.panel" );
equal( ui.index, 0, "ui.index" );
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
});
element.tabs( "option", "active", 0 );
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
// switching tabs
element.one( "tabsshow", function( event, ui ) {
@@ -335,17 +338,17 @@ test( "show", function() {
strictEqual( ui.tab, tabs[ 1 ], "ui.tab" );
strictEqual( ui.panel, panels[ 1 ], "ui.panel" );
equal( ui.index, 1, "ui.index" );
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
});
tabs.eq( 1 ).click();
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
// collapsing
element.one( "tabsshow", function( event, ui ) {
ok( false, "collapsing" );
});
element.tabs( "option", "active", false );
- tabs_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
});
test( "select", function() {
@@ -364,10 +367,10 @@ test( "select", function() {
strictEqual( ui.tab, tabs[ 0 ], "ui.tab" );
strictEqual( ui.panel, panels[ 0 ], "ui.panel" );
equal( ui.index, 0, "ui.index" );
- tabs_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
});
element.tabs( "option", "active", 0 );
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
// switching tabs
element.one( "tabsselect", function( event, ui ) {
@@ -375,17 +378,17 @@ test( "select", function() {
strictEqual( ui.tab, tabs[ 1 ], "ui.tab" );
strictEqual( ui.panel, panels[ 1 ], "ui.panel" );
equal( ui.index, 1, "ui.index" );
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
});
tabs.eq( 1 ).click();
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
// collapsing
element.one( "tabsselect", function( event, ui ) {
ok( false, "collapsing" );
});
element.tabs( "option", "active", false );
- tabs_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
});
module( "tabs (deprecated): methods" );
@@ -393,8 +396,9 @@ module( "tabs (deprecated): methods" );
test( "add", function() {
expect( 27 );
- var element = $( "#tabs1" ).tabs();
- tabs_state( element, 1, 0, 0 );
+ var tab, anchor,
+ element = $( "#tabs1" ).tabs();
+ state( element, 1, 0, 0 );
// add without index
element.one( "tabsadd", function( event, ui ) {
@@ -403,9 +407,9 @@ test( "add", function() {
equal( ui.panel.id, "new", "ui.panel" );
});
element.tabs( "add", "#new", "New" );
- tabs_state( element, 1, 0, 0, 0 );
- var tab = element.find( ".ui-tabs-nav li" ).last(),
- anchor = tab.find( "a" );
+ state( element, 1, 0, 0, 0 );
+ tab = element.find( ".ui-tabs-nav li" ).last();
+ anchor = tab.find( "a" );
equal( tab.text(), "New", "label" );
equal( anchor.attr( "href" ), "#new", "href" );
equal( anchor.attr( "aria-controls" ), "new", "aria-controls" );
@@ -413,7 +417,7 @@ test( "add", function() {
anchor.simulate( "mouseover" );
ok( tab.hasClass( "ui-state-hover" ), "hovered" );
anchor.simulate( "click" );
- tabs_state( element, 0, 0, 0, 1 );
+ state( element, 0, 0, 0, 1 );
// add remote tab with index
element.one( "tabsadd", function( event, ui ) {
@@ -422,7 +426,7 @@ test( "add", function() {
equal( ui.panel.id, $( ui.tab ).attr( "aria-controls" ), "ui.panel" );
});
element.tabs( "add", "data/test.html", "New Remote", 1 );
- tabs_state( element, 0, 0, 0, 0, 1 );
+ state( element, 0, 0, 0, 0, 1 );
tab = element.find( ".ui-tabs-nav li" ).eq( 1 );
anchor = tab.find( "a" );
equal( tab.text(), "New Remote", "label" );
@@ -432,7 +436,7 @@ test( "add", function() {
anchor.simulate( "mouseover" );
ok( tab.hasClass( "ui-state-hover" ), "hovered" );
anchor.simulate( "click" );
- tabs_state( element, 0, 1, 0, 0, 0 );
+ state( element, 0, 1, 0, 0, 0 );
// add to empty tab set
element = $( "<div><ul></ul></div>" ).tabs();
@@ -443,7 +447,7 @@ test( "add", function() {
equal( ui.panel.id, "first", "ui.panel" );
});
element.tabs( "add", "#first", "First" );
- tabs_state( element, 1 );
+ state( element, 1 );
equal( element.tabs( "option", "active" ), 0, "active: 0 after add" );
});
@@ -460,7 +464,7 @@ test( "remove", function() {
expect( 17 );
var element = $( "#tabs1" ).tabs({ active: 1 });
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.one( "tabsremove", function( event, ui ) {
equal( ui.index, -1, "ui.index" );
@@ -468,7 +472,7 @@ test( "remove", function() {
equal( ui.panel.id, "fragment-2", "ui.panel" );
});
element.tabs( "remove", 1 );
- tabs_state( element, 0, 1 );
+ state( element, 0, 1 );
equal( element.tabs( "option", "active" ), 1 );
equal( element.find( ".ui-tabs-nav li a[href$='fragment-2']" ).length, 0,
"remove correct list item" );
@@ -480,7 +484,7 @@ test( "remove", function() {
equal( ui.panel.id, "fragment-3", "ui.panel" );
});
element.tabs( "remove", 1 );
- tabs_state( element, 1 );
+ state( element, 1 );
equal( element.tabs( "option", "active"), 0 );
element.one( "tabsremove", function( event, ui ) {
@@ -496,43 +500,43 @@ test( "select", function() {
expect( 23 );
var element = $( "#tabs1" ).tabs();
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
element.tabs( "select", 1 );
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
equal( element.tabs( "option", "active" ), 1, "active" );
equal( element.tabs( "option", "selected" ), 1, "selected" );
element.tabs( "destroy" );
element.tabs({ collapsible: true });
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
element.tabs( "select", 0 );
- tabs_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
equal( element.tabs( "option", "active" ), false, "active" );
equal( element.tabs( "option", "selected" ), -1, "selected" );
element.tabs( "destroy" );
element.tabs({ collapsible: true });
element.tabs( "select", -1 );
- tabs_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
equal( element.tabs( "option", "active" ), false, "active" );
equal( element.tabs( "option", "selected" ), -1, "selected" );
element.tabs( "destroy" );
element.tabs();
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
equal( element.tabs( "option", "active" ), 0, "active" );
equal( element.tabs( "option", "selected" ), 0, "selected" );
element.tabs( "select", 0 );
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
equal( element.tabs( "option", "active" ), 0, "active" );
equal( element.tabs( "option", "selected" ), 0, "selected" );
element.tabs( "select", -1 );
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
equal( element.tabs( "option", "active" ), 0, "active" );
equal( element.tabs( "option", "selected" ), 0, "selected" );
element.tabs( "select", "#fragment-2" );
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
equal( element.tabs( "option", "active" ), 1, "active" );
equal( element.tabs( "option", "selected" ), 1, "selected" );
});