Skip to content

Commit 25f420e

Browse files
committed
Accordion tests: Cleaned up deprecated tests.
1 parent 5ed1046 commit 25f420e

File tree

2 files changed

+193
-133
lines changed

2 files changed

+193
-133
lines changed
Lines changed: 152 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,100 @@
1-
/*
2-
* accordion_core.js
3-
*/
4-
5-
6-
(function($) {
7-
8-
module("accordion (deprecated): expanded active option, activate method", accordionSetupTeardown() );
9-
10-
test("activate", function() {
11-
var expected = $('#list1').accordion(),
12-
actual = expected.accordion('activate', 2);
13-
equals(actual, expected, 'activate is chainable');
14-
});
15-
16-
test("activate, numeric", function() {
17-
var ac = $('#list1').accordion({ active: 1 });
18-
state(ac, 0, 1, 0);
19-
ac.accordion("activate", 2);
20-
state(ac, 0, 0, 1);
21-
ac.accordion("activate", 0);
22-
state(ac, 1, 0, 0);
23-
ac.accordion("activate", 1);
24-
state(ac, 0, 1, 0);
25-
ac.accordion("activate", 2);
26-
state(ac, 0, 0, 1);
27-
});
28-
29-
test("activate, boolean and numeric, collapsible:true", function() {
30-
var ac = $('#list1').accordion({collapsible: true}).accordion("activate", 2);
31-
state(ac, 0, 0, 1);
32-
ok("x", "----");
33-
ac.accordion("activate", 0);
34-
state(ac, 1, 0, 0);
35-
ok("x", "----");
36-
ac.accordion("activate", -1);
37-
state(ac, 0, 0, 0);
38-
});
39-
40-
test("activate, boolean, collapsible: false", function() {
41-
var ac = $('#list1').accordion().accordion("activate", 2);
42-
state(ac, 0, 0, 1);
43-
ac.accordion("activate", false);
44-
state(ac, 0, 0, 1);
45-
});
46-
47-
test("activate, string expression", function() {
48-
var ac = $('#list1').accordion({ active: "h3:last" });
49-
state(ac, 0, 0, 1);
50-
ac.accordion("activate", ":first");
51-
state(ac, 1, 0, 0);
52-
ac.accordion("activate", ":eq(1)");
53-
state(ac, 0, 1, 0);
54-
ac.accordion("activate", ":last");
55-
state(ac, 0, 0, 1);
56-
});
57-
58-
test("activate, jQuery or DOM element", function() {
59-
var ac = $('#list1').accordion({ active: $("#list1 h3:last") });
60-
state(ac, 0, 0, 1);
61-
ac.accordion("activate", $("#list1 h3:first"));
62-
state(ac, 1, 0, 0);
63-
ac.accordion("activate", $("#list1 h3")[1]);
64-
state(ac, 0, 1, 0);
65-
});
66-
67-
test("{ active: Selector }", function() {
1+
(function( $ ) {
2+
3+
module( "accordion (deprecated): expanded active option, activate method", accordionSetupTeardown() );
4+
5+
test( "activate, numeric", function() {
6+
var ac = $( "#list1" ).accordion({ active: 1 });
7+
state( ac, 0, 1, 0 );
8+
ac.accordion( "activate", 2 );
9+
state( ac, 0, 0, 1 );
10+
ac.accordion( "activate", 0 );
11+
state( ac, 1, 0, 0 );
12+
ac.accordion( "activate", 1 );
13+
state( ac, 0, 1, 0 );
14+
ac.accordion( "activate", 2 );
15+
state( ac, 0, 0, 1 );
16+
});
17+
18+
test( "activate, numeric, collapsible:true", function() {
19+
var ac = $( "#list1" ).accordion({ collapsible: true });
20+
ac.accordion( "activate", 2 );
21+
state( ac, 0, 0, 1 );
22+
ac.accordion( "activate", 0 );
23+
state( ac, 1, 0, 0 );
24+
ac.accordion( "activate", -1 );
25+
state( ac, 0, 0, 0 );
26+
});
27+
28+
test( "activate, boolean, collapsible: true", function() {
29+
var ac = $( "#list1" ).accordion({ collapsible: true });
30+
ac.accordion( "activate", 2 );
31+
state( ac, 0, 0, 1 );
32+
ac.accordion( "activate", false );
33+
state( ac, 0, 0, 0 );
34+
});
35+
36+
test( "activate, boolean, collapsible: false", function() {
37+
var ac = $( "#list1" ).accordion();
38+
ac.accordion( "activate", 2 );
39+
state( ac, 0, 0, 1 );
40+
ac.accordion( "activate", false );
41+
state( ac, 0, 0, 1 );
42+
});
43+
44+
test( "activate, string expression", function() {
45+
var ac = $( "#list1" ).accordion({ active: "h3:last" });
46+
state( ac, 0, 0, 1 );
47+
ac.accordion( "activate", ":first" );
48+
state( ac, 1, 0, 0 );
49+
ac.accordion( "activate", ":eq(1)" );
50+
state( ac, 0, 1, 0 );
51+
ac.accordion( "activate", ":last" );
52+
state( ac, 0, 0, 1 );
53+
});
54+
55+
test( "activate, jQuery or DOM element", function() {
56+
var ac = $( "#list1" ).accordion({ active: $( "#list1 h3:last" ) });
57+
state( ac, 0, 0, 1 );
58+
ac.accordion( "activate", $( "#list1 h3:first" ) );
59+
state( ac, 1, 0, 0 );
60+
ac.accordion( "activate", $( "#list1 h3" )[ 1 ] );
61+
state( ac, 0, 1, 0 );
62+
});
63+
64+
test( "{ active: Selector }", function() {
6865
var ac = $("#list1").accordion({
6966
active: "h3:last"
7067
});
71-
state(ac, 0, 0, 1);
72-
ac.accordion('option', 'active', "h3:eq(1)");
73-
state(ac, 0, 1, 0);
68+
state( ac, 0, 0, 1 );
69+
ac.accordion( "option", "active", "h3:eq(1)" );
70+
state( ac, 0, 1, 0 );
7471
});
7572

76-
test("{ active: Element }", function() {
77-
var ac = $("#list1").accordion({
78-
active: $("#list1 h3:last")[0]
73+
test( "{ active: Element }", function() {
74+
var ac = $( "#list1" ).accordion({
75+
active: $( "#list1 h3:last" )[ 0 ]
7976
});
80-
state(ac, 0, 0, 1);
81-
ac.accordion('option', 'active', $("#list1 h3:eq(1)")[0]);
82-
state(ac, 0, 1, 0);
77+
state( ac, 0, 0, 1 );
78+
ac.accordion( "option", "active", $( "#list1 h3:eq(1)" )[ 0 ] );
79+
state( ac, 0, 1, 0 );
8380
});
8481

85-
test("{ active: jQuery Object }", function() {
86-
var ac = $("#list1").accordion({
87-
active: $("#list1 h3:last")
82+
test( "{ active: jQuery Object }", function() {
83+
var ac = $( "#list1" ).accordion({
84+
active: $( "#list1 h3:last" )
8885
});
89-
state(ac, 0, 0, 1);
90-
ac.accordion('option', 'active', $("#list1 h3:eq(1)"));
91-
state(ac, 0, 1, 0);
86+
state( ac, 0, 0, 1 );
87+
ac.accordion( "option", "active", $( "#list1 h3:eq(1)" ) );
88+
state( ac, 0, 1, 0 );
9289
});
9390

9491

9592

9693

9794

95+
module( "accordion (deprecated) - height options", accordionSetupTeardown() );
9896

99-
module("accordion (deprecated) - height options", accordionSetupTeardown() );
100-
101-
test("{ autoHeight: true }, default", function() {
97+
test( "{ autoHeight: true }, default", function() {
10298
equalHeights($('#navigation').accordion({ autoHeight: true }), 95, 130);
10399
});
104100

@@ -113,42 +109,67 @@ test("{ autoHeight: false }", function() {
113109
ok( sizes[2] >= 42 && sizes[2] <= 54, "was " + sizes[2] );
114110
});
115111

116-
// fillSpace: false == autoHeight: true, covered above
117-
test("{ fillSpace: true }", function() {
118-
$("#navigationWrapper").height(500);
119-
equalHeights($('#navigation').accordion({ fillSpace: true }), 446, 458);
120-
});
121-
122-
test("{ fillSpace: true } with sibling", function() {
123-
$("#navigationWrapper").height(500);
124-
var sibling = $("<p>Lorem Ipsum</p>");
125-
$("#navigationWrapper").prepend( sibling.height(100) );
126-
//sibling.outerHeight(true) == 126
127-
equalHeights($('#navigation').accordion({ fillSpace: true}), 320, 332);
128-
});
129-
130-
test("{ fillSpace: true } with multiple siblings", function() {
131-
$("#navigationWrapper").height(500);
132-
var sibling = $("<p>Lorem Ipsum</p>");
133-
$("#navigationWrapper")
134-
.prepend( sibling.clone().height(100) )
135-
.prepend( sibling.clone().height(100).css( "position", "absolute" ) )
136-
.prepend( sibling.clone().height(50) );
137-
//sibling.outerHeight(true) == 126
138-
equalHeights($('#navigation').accordion({ fillSpace: true}), 244, 256);
139-
});
140-
141-
142-
143-
144-
module("accordion (deprecated) - icons", accordionSetupTeardown() );
145-
146-
test("change headerSelected option after creation", function() {
147-
var list = $("#list1");
148-
list.accordion( { icons: { "activeHeader": "test" } } );
149-
equals( $( "#list1 span.test" ).length, 1);
150-
list.accordion( "option", "icons", { "headerSelected": "deprecated" } );
151-
equals( $( "#list1 span.deprecated" ).length, 1);
112+
test( "{ fillSpace: true }", function() {
113+
$( "#navigationWrapper" ).height( 500 );
114+
var ac = $( "#navigation" ).accordion({ fillSpace: true });
115+
equalHeights( ac, 446, 458 );
116+
});
117+
118+
test( "{ fillSapce: true } with sibling", function() {
119+
$( "#navigationWrapper" ).height( 500 );
120+
$( "<p>Lorem Ipsum</p>" )
121+
.css({
122+
height: 50,
123+
marginTop: 20,
124+
marginBottom: 30
125+
})
126+
.prependTo( "#navigationWrapper" );
127+
var ac = $( "#navigation" ).accordion({ fillSpace: true });
128+
equalHeights( ac , 346, 358);
129+
});
130+
131+
test( "{ fillSpace: true } with multiple siblings", function() {
132+
$( "#navigationWrapper" ).height( 500 );
133+
$( "<p>Lorem Ipsum</p>" )
134+
.css({
135+
height: 50,
136+
marginTop: 20,
137+
marginBottom: 30
138+
})
139+
.prependTo( "#navigationWrapper" );
140+
$( "<p>Lorem Ipsum</p>" )
141+
.css({
142+
height: 50,
143+
marginTop: 20,
144+
marginBottom: 30,
145+
position: "absolute"
146+
})
147+
.prependTo( "#navigationWrapper" );
148+
$( "<p>Lorem Ipsum</p>" )
149+
.css({
150+
height: 25,
151+
marginTop: 10,
152+
marginBottom: 15
153+
})
154+
.prependTo( "#navigationWrapper" );
155+
var ac = $( "#navigation" ).accordion({ fillSpace: true });
156+
equalHeights( ac, 296, 308 );
157+
});
158+
159+
160+
161+
162+
163+
module( "accordion (deprecated) - icons", accordionSetupTeardown() );
164+
165+
test( "icons, headerSelected", function() {
166+
var list = $( "#list1" ).accordion({
167+
icons: { headerSelected: "a1", header: "h1" }
168+
});
169+
ok( list.find( ".ui-accordion-header.ui-state-active span.ui-icon" ).hasClass( "a1" ) );
170+
list.accordion( "option", "icons", { headerSelected: "a2", header: "h2" } );
171+
ok( !list.find( ".ui-accordion-header.ui-state-active span.ui-icon" ).hasClass( "a1" ) );
172+
ok( list.find( ".ui-accordion-header.ui-state-active span.ui-icon" ).hasClass( "a2" ) );
152173
});
153174

154175

@@ -175,26 +196,29 @@ test( "resize", function() {
175196

176197

177198

199+
178200
module( "accordion (deprecated) - navigation", accordionSetupTeardown() );
179201

180-
test("{ navigation: true, navigationFilter: header }", function() {
181-
$("#navigation").accordion({
202+
test( "{ navigation: true, navigationFilter: header }", function() {
203+
var ac = $( "#navigation" ).accordion({
182204
navigation: true,
183205
navigationFilter: function() {
184-
return /\?p=1\.1\.3$/.test(this.href);
206+
return /\?p=1\.1\.3$/.test( this.href );
185207
}
186208
});
187-
equals( $("#navigation .ui-accordion-content:eq(2)").size(), 1, "third content active" );
209+
equal( ac.accordion( "option", "active" ), 2 );
210+
state( ac, 0, 0, 1 );
188211
});
189212

190-
test("{ navigation: true, navigationFilter: content }", function() {
191-
$("#navigation").accordion({
213+
test( "{ navigation: true, navigationFilter: content }", function() {
214+
var ac = $("#navigation").accordion({
192215
navigation: true,
193216
navigationFilter: function() {
194217
return /\?p=1\.1\.3\.2$/.test(this.href);
195218
}
196219
});
197-
equals( $("#navigation .ui-accordion-content:eq(2)").size(), 1, "third content active" );
220+
equal( ac.accordion( "option", "active" ), 2 );
221+
state( ac, 0, 0, 1 );
198222
});
199223

200224
})(jQuery);

tests/unit/accordion/accordion_options.js

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,48 @@ test( "{ heightStyle: 'content' }", function() {
137137
test( "{ heightStyle: 'fill' }", function() {
138138
$( "#navigationWrapper" ).height( 500 );
139139
var ac = $( "#navigation" ).accordion({ heightStyle: "fill" });
140-
equalHeights( ac, 446, 458);
141-
ac.accordion( "destroy" );
140+
equalHeights( ac, 446, 458 );
141+
});
142142

143-
$( "<div>" ).height( 100 ).appendTo( "#navigationWrapper" );
144-
ac.accordion({ heightStyle: "fill" });
145-
equalHeights( ac, 346, 358 );
143+
test( "{ heightStyle: 'fill' } with sibling", function() {
144+
$( "#navigationWrapper" ).height( 500 );
145+
$( "<p>Lorem Ipsum</p>" )
146+
.css({
147+
height: 50,
148+
marginTop: 20,
149+
marginBottom: 30
150+
})
151+
.prependTo( "#navigationWrapper" );
152+
var ac = $( "#navigation" ).accordion({ heightStyle: "fill" });
153+
equalHeights( ac , 346, 358);
154+
});
155+
156+
test( "{ heightStyle: 'fill' } with multiple siblings", function() {
157+
$( "#navigationWrapper" ).height( 500 );
158+
$( "<p>Lorem Ipsum</p>" )
159+
.css({
160+
height: 50,
161+
marginTop: 20,
162+
marginBottom: 30
163+
})
164+
.prependTo( "#navigationWrapper" );
165+
$( "<p>Lorem Ipsum</p>" )
166+
.css({
167+
height: 50,
168+
marginTop: 20,
169+
marginBottom: 30,
170+
position: "absolute"
171+
})
172+
.prependTo( "#navigationWrapper" );
173+
$( "<p>Lorem Ipsum</p>" )
174+
.css({
175+
height: 25,
176+
marginTop: 10,
177+
marginBottom: 15
178+
})
179+
.prependTo( "#navigationWrapper" );
180+
var ac = $( "#navigation" ).accordion({ heightStyle: "fill" });
181+
equalHeights( ac, 296, 308 );
146182
});
147183

148184
test( "{ icons: false }", function() {

0 commit comments

Comments
 (0)