Skip to content

Commit a6e6a05

Browse files
committed
Tabs tests: Added tests for show and hide options.
1 parent c6567ba commit a6e6a05

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

tests/unit/tabs/tabs_options.js

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,54 @@ test( "{ heightStyle: 'fill' } with multiple siblings", function() {
280280
equalHeight( element, 335 );
281281
});
282282

283-
// TODO: add animation tests
283+
test( "hide and show: false", function() {
284+
expect( 3 );
285+
var element = $( "#tabs1" ).tabs({
286+
show: false,
287+
hide: false
288+
}),
289+
widget = element.data( "tabs" ),
290+
panels = element.find( ".ui-tabs-panel" );
291+
widget._show = function() {
292+
ok( false, "_show() called" );
293+
};
294+
widget._hide = function() {
295+
ok( false, "_hide() called" );
296+
};
297+
298+
ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
299+
element.tabs( "option", "active", 1 );
300+
ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
301+
ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
302+
});
303+
304+
asyncTest( "hide and show - animation", function() {
305+
expect( 5 );
306+
var element = $( "#tabs1" ).tabs({
307+
show: "drop",
308+
hide: 2000
309+
}),
310+
widget = element.data( "tabs" ),
311+
panels = element.find( ".ui-tabs-panel" );
312+
widget._show = function( element, options, callback ) {
313+
strictEqual( element[ 0 ], panels[ 1 ], "correct element in _show()" );
314+
equal( options, "drop", "correct options in _show()" );
315+
setTimeout(function() {
316+
callback();
317+
}, 1 );
318+
};
319+
widget._hide = function( element, options, callback ) {
320+
strictEqual( element[ 0 ], panels[ 0 ], "correct element in _hide()" );
321+
equal( options, 2000, "correct options in _hide()" );
322+
setTimeout(function() {
323+
callback();
324+
start();
325+
}, 1 );
326+
};
327+
328+
ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
329+
element.tabs( "option", "active", 1 );
330+
});
331+
284332

285333
}( jQuery ) );

0 commit comments

Comments
 (0)