aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/tabs/tabs_options.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/tabs/tabs_options.js')
-rw-r--r--tests/unit/tabs/tabs_options.js71
1 files changed, 37 insertions, 34 deletions
diff --git a/tests/unit/tabs/tabs_options.js b/tests/unit/tabs/tabs_options.js
index e1ebf5efa..40d4ceaa7 100644
--- a/tests/unit/tabs/tabs_options.js
+++ b/tests/unit/tabs/tabs_options.js
@@ -1,5 +1,8 @@
(function( $ ) {
+var disabled = TestHelpers.tabs.disabled,
+ state = TestHelpers.tabs.state;
+
module( "tabs: options" );
test( "{ active: default }", function() {
@@ -7,13 +10,13 @@ test( "{ active: default }", function() {
var element = $( "#tabs1" ).tabs();
equal( element.tabs( "option", "active" ), 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", "active" ), 2, "should be 2 based on URL" );
- tabs_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.tabs( "destroy" );
location.hash = "#";
});
@@ -25,19 +28,19 @@ test( "{ active: false }", function() {
active: false,
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", "active" ), false );
element.tabs( "option", "collapsible", false );
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
equal( element.tabs( "option", "active" ), 0 );
element.tabs( "destroy" );
element.tabs({
active: false
});
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
strictEqual( element.tabs( "option", "active" ), 0 );
});
@@ -48,19 +51,19 @@ test( "{ active: Number }", function() {
active: 2
});
equal( element.tabs( "option", "active" ), 2 );
- tabs_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.tabs( "option", "active", 0 );
equal( element.tabs( "option", "active" ), 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", "active" ), 1 );
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.tabs( "option", "active", 10 );
equal( element.tabs( "option", "active" ), 1 );
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
});
if ( $.uiBackCompat === false ) {
@@ -69,19 +72,19 @@ if ( $.uiBackCompat === false ) {
active: -1
});
equal( element.tabs( "option", "active" ), 2 );
- tabs_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.tabs( "option", "active", -2 );
equal( element.tabs( "option", "active" ), 1 );
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.tabs( "option", "active", -10 );
equal( element.tabs( "option", "active" ), 1 );
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.tabs( "option", "active", -3 );
equal( element.tabs( "option", "active" ), 0 );
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
});
}
@@ -91,9 +94,9 @@ test( "active - mismatched tab/panel order", function() {
location.hash = "#tabs7-2";
var element = $( "#tabs7" ).tabs();
equal( element.tabs( "option", "active" ), 1, "should be 1 based on URL" );
- tabs_state( element, 0, 1 );
+ state( element, 0, 1 );
element.tabs( "option", "active", 0 );
- tabs_state( element, 1, 0 );
+ state( element, 1, 0 );
location.hash = "#";
});
@@ -105,11 +108,11 @@ test( "{ collapsible: false }", function() {
});
element.tabs( "option", "active", false );
equal( element.tabs( "option", "active" ), 1 );
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.find( ".ui-state-active a" ).eq( 1 ).click();
equal( element.tabs( "option", "active" ), 1 );
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
});
test( "{ collapsible: true }", function() {
@@ -122,15 +125,15 @@ test( "{ collapsible: true }", function() {
element.tabs( "option", "active", false );
equal( element.tabs( "option", "active" ), false );
- tabs_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
element.tabs( "option", "active", 1 );
equal( element.tabs( "option", "active" ), 1 );
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.find( ".ui-state-active a" ).click();
equal( element.tabs( "option", "active" ), false );
- tabs_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
});
test( "disabled", function() {
@@ -138,23 +141,23 @@ test( "disabled", function() {
// fully enabled by default
var element = $( "#tabs1" ).tabs();
- tabs_disabled( element, false );
+ disabled( element, false );
// disable single tab
element.tabs( "option", "disabled", [ 1 ] );
- tabs_disabled( element, [ 1 ] );
+ disabled( element, [ 1 ] );
// disabled active tab
element.tabs( "option", "disabled", [ 0, 1 ] );
- tabs_disabled( element, [ 0, 1 ] );
+ disabled( element, [ 0, 1 ] );
// disable all tabs
element.tabs( "option", "disabled", [ 0, 1, 2 ] );
- tabs_disabled( element, true );
+ disabled( element, true );
// enable all tabs
element.tabs( "option", "disabled", [] );
- tabs_disabled( element, false );
+ disabled( element, false );
});
test( "{ event: null }", function() {
@@ -163,16 +166,16 @@ test( "{ event: null }", function() {
var element = $( "#tabs1" ).tabs({
event: null
});
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
element.tabs( "option", "active", 1 );
equal( element.tabs( "option", "active" ), 1 );
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
// ensure default click handler isn't bound
element.find( ".ui-tabs-nav a" ).eq( 2 ).click();
equal( element.tabs( "option", "active" ), 1 );
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
});
test( "{ event: custom }", function() {
@@ -181,31 +184,31 @@ test( "{ event: custom }", function() {
var element = $( "#tabs1" ).tabs({
event: "custom1 custom2"
});
- tabs_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
element.find( ".ui-tabs-nav a" ).eq( 1 ).trigger( "custom1" );
equal( element.tabs( "option", "active" ), 1 );
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
// ensure default click handler isn't bound
element.find( ".ui-tabs-nav a" ).eq( 2 ).trigger( "click" );
equal( element.tabs( "option", "active" ), 1 );
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.find( ".ui-tabs-nav a" ).eq( 2 ).trigger( "custom2" );
equal( element.tabs( "option", "active" ), 2 );
- tabs_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.tabs( "option", "event", "custom3" );
// ensure old event handlers are unbound
element.find( ".ui-tabs-nav a" ).eq( 1 ).trigger( "custom1" );
equal( element.tabs( "option", "active" ), 2 );
- tabs_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.find( ".ui-tabs-nav a" ).eq( 1 ).trigger( "custom3" );
equal( element.tabs( "option", "active" ), 1 );
- tabs_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
});
// TODO: add animation tests