aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/tabs/helper.js
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2015-04-07 10:55:52 -0400
committerScott González <scott.gonzalez@gmail.com>2015-04-09 09:27:00 -0400
commitbde431bb449b1d957d4e0b736111ff342f2a919d (patch)
tree27fd40037c30dbff8ef3b6113e90817ab96b53bf /tests/unit/tabs/helper.js
parentdc4b015a8b9acdb5bff2d5dd89737b3d8b64097f (diff)
downloadjquery-ui-bde431bb449b1d957d4e0b736111ff342f2a919d.tar.gz
jquery-ui-bde431bb449b1d957d4e0b736111ff342f2a919d.zip
Tests: Rename files
Ref gh-1528
Diffstat (limited to 'tests/unit/tabs/helper.js')
-rw-r--r--tests/unit/tabs/helper.js74
1 files changed, 74 insertions, 0 deletions
diff --git a/tests/unit/tabs/helper.js b/tests/unit/tabs/helper.js
new file mode 100644
index 000000000..5c9625f8c
--- /dev/null
+++ b/tests/unit/tabs/helper.js
@@ -0,0 +1,74 @@
+define( [
+ "jquery",
+ "lib/helper",
+ "ui/tabs"
+], function( $, helper ) {
+
+return $.extend( helper, {
+ disabled: function( tabs, state ) {
+ var expected, actual,
+ internalState = tabs.tabs( "option", "disabled" );
+
+ if ( internalState === false ) {
+ internalState = [];
+ }
+ if ( internalState === true ) {
+ internalState = $.map( new Array( tabs.find( ".ui-tabs-nav li" ).length ), function( _, index ) {
+ return index;
+ });
+ }
+
+ expected = $.map( new Array( tabs.find ( ".ui-tabs-nav li" ).length ), function( _, index ) {
+ if ( typeof state === "boolean" ) {
+ return state ? 1 : 0;
+ } else {
+ return $.inArray( index, state ) !== -1 ? 1 : 0;
+ }
+ });
+
+ actual = tabs.find( ".ui-tabs-nav li" ).map(function( index ) {
+ var tab = $( this ),
+ tabIsDisabled = tab.hasClass( "ui-state-disabled" );
+
+ if ( tabIsDisabled && $.inArray( index, internalState ) !== -1 ) {
+ return 1;
+ }
+ if ( !tabIsDisabled && $.inArray( index, internalState ) === -1 ) {
+ return 0;
+ }
+ // mixed state - invalid
+ return -1;
+ }).get();
+
+ deepEqual( tabs.tabs( "option", "disabled" ), state );
+ deepEqual( actual, expected );
+ },
+
+ equalHeight: function( tabs, height ) {
+ tabs.find( ".ui-tabs-panel" ).each(function() {
+ equal( $( this ).outerHeight(), height );
+ });
+ },
+
+ state: function( tabs ) {
+ var expected = $.makeArray( arguments ).slice( 1 ),
+ actual = tabs.find( ".ui-tabs-nav li" ).map(function() {
+ var tab = $( this ),
+ panel = $( $.ui.tabs.prototype._sanitizeSelector(
+ "#" + tab.attr( "aria-controls" ) ) ),
+ tabIsActive = tab.hasClass( "ui-state-active" ),
+ panelIsActive = panel.css( "display" ) !== "none";
+
+ if ( tabIsActive && panelIsActive ) {
+ return 1;
+ }
+ if ( !tabIsActive && !panelIsActive ) {
+ return 0;
+ }
+ return -1; // mixed state - invalid
+ }).get();
+ deepEqual( actual, expected );
+ }
+} );
+
+} );