Skip to content

Commit

Permalink
Tabs: Added tests for idPrefix, tabTemplate, panelTemplate. Fixes #71…
Browse files Browse the repository at this point in the history
…39 - Tabs: Deprecate templating (idPrefix, tabTemplate, panelTemplate options).
  • Loading branch information
scottgonzalez committed May 9, 2011
1 parent 2e882de commit 0546cd5
Showing 1 changed file with 37 additions and 8 deletions.
45 changes: 37 additions & 8 deletions tests/unit/tabs/tabs_deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand All @@ -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: "<li class='customTab'><a href='http://example.com/#{href}'>#{label}</a></li>",
panelTemplate: "<div class='customPanel'></div>"
});
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() {
Expand Down

0 comments on commit 0546cd5

Please sign in to comment.