Skip to content

Commit 0546cd5

Browse files
committed
Tabs: Added tests for idPrefix, tabTemplate, panelTemplate. Fixes #7139 - Tabs: Deprecate templating (idPrefix, tabTemplate, panelTemplate options).
1 parent 2e882de commit 0546cd5

File tree

1 file changed

+37
-8
lines changed

1 file changed

+37
-8
lines changed

tests/unit/tabs/tabs_deprecated.js

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ test( "panel ids", function() {
2020
element.tabs( "option", "active", 2 );
2121
});
2222

23-
module("tabs (deprecated): options");
23+
module( "tabs (deprecated): options" );
2424

2525
test('ajaxOptions', function() {
2626
ok(false, "missing test - untested code is broken code.");
@@ -30,16 +30,45 @@ test('cache', function() {
3030
ok(false, "missing test - untested code is broken code.");
3131
});
3232

33-
test('idPrefix', function() {
34-
ok(false, "missing test - untested code is broken code.");
33+
test( "idPrefix", function() {
34+
expect( 1 );
35+
36+
$( "#tabs2" )
37+
.one( "tabsbeforeload", function( event, ui ) {
38+
ok( /^testing-\d+$/.test( ui.panel.attr( "id" ) ), "generated id" );
39+
event.preventDefault();
40+
})
41+
.tabs({
42+
idPrefix: "testing-",
43+
active: 2
44+
});
3545
});
3646

37-
test('tabTemplate', function() {
38-
ok(false, "missing test - untested code is broken code.");
39-
});
47+
test( "tabTemplate + panelTemplate", function() {
48+
// defaults are tested in the add method test
49+
expect( 11 );
4050

41-
test('panelTemplate', function() {
42-
ok(false, "missing test - untested code is broken code.");
51+
var element = $( "#tabs2" ).tabs({
52+
tabTemplate: "<li class='customTab'><a href='http://example.com/#{href}'>#{label}</a></li>",
53+
panelTemplate: "<div class='customPanel'></div>"
54+
});
55+
element.one( "tabsadd", function( event, ui ) {
56+
var anchor = $( ui.tab );
57+
equal( ui.index, 5, "ui.index" );
58+
equal( anchor.text(), "New", "ui.tab" );
59+
equal( anchor.attr( "href" ), "http://example.com/#new", "tab href" );
60+
ok( anchor.parent().hasClass( "customTab" ), "tab custom class" );
61+
equal( ui.panel.id, "new", "ui.panel" );
62+
ok( $( ui.panel ).hasClass( "customPanel" ), "panel custom class" );
63+
});
64+
element.tabs( "add", "#new", "New" );
65+
var tab = element.find( ".ui-tabs-nav li" ).last(),
66+
anchor = tab.find( "a" );
67+
equals( tab.text(), "New", "label" );
68+
ok( tab.hasClass( "customTab" ), "tab custom class" );
69+
equals( anchor.attr( "href" ), "http://example.com/#new", "href" );
70+
equals( anchor.attr( "aria-controls" ), "new", "aria-controls" );
71+
ok( element.find( "#new" ).hasClass( "customPanel" ), "panel custom class" );
4372
});
4473

4574
test('cookie', function() {

0 commit comments

Comments
 (0)