From: Scott González Date: Mon, 9 May 2011 15:31:01 +0000 (-0400) Subject: Tabs: Added tests for idPrefix, tabTemplate, panelTemplate. Fixes #7139 - Tabs: Depre... X-Git-Tag: 1.9m5~71 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0546cd57bbd0ccee25e96e1fb8be5f208b08dfd4;p=jquery-ui.git Tabs: Added tests for idPrefix, tabTemplate, panelTemplate. Fixes #7139 - Tabs: Deprecate templating (idPrefix, tabTemplate, panelTemplate options). --- diff --git a/tests/unit/tabs/tabs_deprecated.js b/tests/unit/tabs/tabs_deprecated.js index 90c43037c..8d63409a8 100644 --- a/tests/unit/tabs/tabs_deprecated.js +++ b/tests/unit/tabs/tabs_deprecated.js @@ -20,7 +20,7 @@ test( "panel ids", function() { element.tabs( "option", "active", 2 ); }); -module("tabs (deprecated): options"); +module( "tabs (deprecated): options" ); test('ajaxOptions', function() { ok(false, "missing test - untested code is broken code."); @@ -30,16 +30,45 @@ test('cache', function() { ok(false, "missing test - untested code is broken code."); }); -test('idPrefix', function() { - ok(false, "missing test - untested code is broken code."); +test( "idPrefix", function() { + expect( 1 ); + + $( "#tabs2" ) + .one( "tabsbeforeload", function( event, ui ) { + ok( /^testing-\d+$/.test( ui.panel.attr( "id" ) ), "generated id" ); + event.preventDefault(); + }) + .tabs({ + idPrefix: "testing-", + active: 2 + }); }); -test('tabTemplate', function() { - ok(false, "missing test - untested code is broken code."); -}); +test( "tabTemplate + panelTemplate", function() { + // defaults are tested in the add method test + expect( 11 ); -test('panelTemplate', function() { - ok(false, "missing test - untested code is broken code."); + var element = $( "#tabs2" ).tabs({ + tabTemplate: "
  • #{label}
  • ", + panelTemplate: "
    " + }); + element.one( "tabsadd", function( event, ui ) { + var anchor = $( ui.tab ); + equal( ui.index, 5, "ui.index" ); + equal( anchor.text(), "New", "ui.tab" ); + equal( anchor.attr( "href" ), "http://example.com/#new", "tab href" ); + ok( anchor.parent().hasClass( "customTab" ), "tab custom class" ); + equal( ui.panel.id, "new", "ui.panel" ); + 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" ); + equals( tab.text(), "New", "label" ); + ok( tab.hasClass( "customTab" ), "tab custom class" ); + equals( anchor.attr( "href" ), "http://example.com/#new", "href" ); + equals( anchor.attr( "aria-controls" ), "new", "aria-controls" ); + ok( element.find( "#new" ).hasClass( "customPanel" ), "panel custom class" ); }); test('cookie', function() {