aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2011-05-16 14:41:27 -0400
committerScott González <scott.gonzalez@gmail.com>2011-05-16 14:41:27 -0400
commit5e588593473f0988a958a2cbba4951a895821ba8 (patch)
treeb7eef49f898be435aee9683c2efc7fcba9d02595 /tests/unit
parent965cb7359ea704715839e3c171ae751d6a32dde9 (diff)
downloadjquery-ui-5e588593473f0988a958a2cbba4951a895821ba8.tar.gz
jquery-ui-5e588593473f0988a958a2cbba4951a895821ba8.zip
Tabs: Added tests for load method.
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/tabs/tabs_methods.js81
1 files changed, 79 insertions, 2 deletions
diff --git a/tests/unit/tabs/tabs_methods.js b/tests/unit/tabs/tabs_methods.js
index 221b0d39d..5cf917550 100644
--- a/tests/unit/tabs/tabs_methods.js
+++ b/tests/unit/tabs/tabs_methods.js
@@ -145,8 +145,85 @@ test( "refresh", function() {
tabs_disabled( element, false );
});
-test('load', function() {
- ok(false, "missing test - untested code is broken code.");
+asyncTest( "load", function() {
+ expect( 30 );
+
+ var element = $( "#tabs2" ).tabs();
+
+ // load content of inactive tab
+ // useful for preloading content with custom caching
+ element.one( "tabsbeforeload", function( event, ui ) {
+ var tab = element.find( ".ui-tabs-nav a" ).eq( 3 ),
+ panelId = tab.attr( "aria-controls" ),
+ panel = $( "#" + panelId );
+
+ ok( !( "originalEvent" in event ), "originalEvent" );
+ equals( ui.tab.size(), 1, "tab size" );
+ strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
+ equals( ui.panel.size(), 1, "panel size" );
+ strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
+ tabs_state( element, 1, 0, 0, 0, 0 );
+ });
+ element.one( "tabsload", function( event, ui ) {
+ var tab = element.find( ".ui-tabs-nav a" ).eq( 3 ),
+ panelId = tab.attr( "aria-controls" ),
+ panel = $( "#" + panelId );
+
+ ok( !( "originalEvent" in event ), "originalEvent" );
+ equals( ui.tab.size(), 1, "tab size" );
+ strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
+ equals( ui.panel.size(), 1, "panel size" );
+ strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
+ equals( ui.panel.find( "p" ).length, 1, "panel html" );
+ tabs_state( element, 1, 0, 0, 0, 0 );
+ setTimeout( tabsload1, 1 );
+ });
+ element.tabs( "load", 3 );
+ tabs_state( 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" );
+ });
+ element.one( "tabsload", function() {
+ ok( true, "tabsload invoked" );
+ setTimeout( tabsload2, 1 );
+ });
+ element.tabs( "option", "active", 3 );
+ tabs_state( element, 0, 0, 0, 1, 0 );
+ }
+
+ function tabsload2() {
+ // reload content of active tab
+ element.one( "tabsbeforeload", function( event, ui ) {
+ var tab = element.find( ".ui-tabs-nav a" ).eq( 3 ),
+ panelId = tab.attr( "aria-controls" ),
+ panel = $( "#" + panelId );
+
+ ok( !( "originalEvent" in event ), "originalEvent" );
+ equals( ui.tab.size(), 1, "tab size" );
+ strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
+ equals( ui.panel.size(), 1, "panel size" );
+ strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
+ tabs_state( element, 0, 0, 0, 1, 0 );
+ });
+ element.one( "tabsload", function( event, ui ) {
+ var tab = element.find( ".ui-tabs-nav a" ).eq( 3 ),
+ panelId = tab.attr( "aria-controls" ),
+ panel = $( "#" + panelId );
+
+ ok( !( "originalEvent" in event ), "originalEvent" );
+ equals( ui.tab.size(), 1, "tab size" );
+ strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
+ equals( ui.panel.size(), 1, "panel size" );
+ strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
+ tabs_state( element, 0, 0, 0, 1, 0 );
+ start();
+ });
+ element.tabs( "load", 3 );
+ tabs_state( element, 0, 0, 0, 1, 0 );
+ }
});
}( jQuery ) );