Skip to content

Commit 11e8a9c

Browse files
committed
Added test for mixed static and dynamic collapsibles in collapsible set
1 parent fba69fd commit 11e8a9c

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

tests/unit/collapsible/collapsible_core.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
$( '<div data-'+ $.mobile.ns +'role="collapsible"><h3>Collapsible Item ' + i + '</h3></div>' ).appendTo( set );
129129
}
130130
set.collapsibleset( "refresh" );
131-
equal( set.find( ".ui-collapsible" ).length, 3, "The 3 collapsible should be enhanced" );
131+
equal( set.find( ".ui-collapsible" ).length, 3, "The 3 collapsibles should be enhanced" );
132132
ok( set.find( ".ui-collapsible" ).eq( 0 ).find( "a" ).hasClass( "ui-corner-top" ), "The 1st collapsible should have top corners" );
133133
ok( !set.find( ".ui-collapsible" ).eq( 0 ).find( "a" ).hasClass( "ui-corner-bottom" ), "The 1st collapsible should NOT have bottom corners" );
134134
ok( !set.find( ".ui-collapsible" ).eq( 1 ).find( "a" ).hasClass( "ui-corner-top" ), "The 2nd collapsible should NOT have top corners" );
@@ -140,6 +140,30 @@
140140
]);
141141
});
142142

143+
asyncTest( "Collapsible Set with static and dynamic content", function(){
144+
$.testHelper.pageSequence([
145+
function(){
146+
$.testHelper.openPage( "#collapsible-set-with-static-and-dynamic-content" );
147+
},
148+
149+
function() {
150+
var set = $( ".ui-page-active" ).find( ".ui-collapsible-set" );
151+
for ( var i = 0; i < 2; i++ ) {
152+
$( '<div data-'+ $.mobile.ns +'role="collapsible"><h3>Collapsible Item ' + i + '</h3></div>' ).appendTo( set );
153+
}
154+
set.collapsibleset( "refresh" );
155+
equal( set.find( ".ui-collapsible" ).length, 3, "The 3 collapsibles should be enhanced" );
156+
ok( set.find( ".ui-collapsible" ).eq( 0 ).find( "a" ).hasClass( "ui-corner-top" ), "The 1st collapsible should have top corners" );
157+
ok( !set.find( ".ui-collapsible" ).eq( 0 ).find( "a" ).hasClass( "ui-corner-bottom" ), "The 1st collapsible should NOT have bottom corners" );
158+
ok( !set.find( ".ui-collapsible" ).eq( 1 ).find( "a" ).hasClass( "ui-corner-top" ), "The 2nd collapsible should NOT have top corners" );
159+
ok( !set.find( ".ui-collapsible" ).eq( 1 ).find( "a" ).hasClass( "ui-corner-bottom" ), "The 2nd collapsible should NOT have bottom corners" );
160+
ok( set.find( ".ui-collapsible" ).eq( 2 ).find( "a" ).hasClass( "ui-corner-bottom" ), "The 3rd collapsible should have bottom corners" );
161+
ok( !set.find( ".ui-collapsible" ).eq( 2 ).find( "a" ).hasClass( "ui-corner-top" ), "The 3rd collapsible should NOT have top corners" );
162+
start();
163+
}
164+
]);
165+
});
166+
143167
module( "Theming", {});
144168

145169
asyncTest( "Collapsible", 6, function(){

tests/unit/collapsible/index.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,5 +183,21 @@ <h1>Collapsible Set with dynamic content</h1>
183183
</div>
184184
</div>
185185

186+
<div data-nstest-role="page" id='collapsible-set-with-static-and-dynamic-content'>
187+
<div data-nstest-role="header">
188+
<h1>Collapsible Set with dynamic content</h1>
189+
</div>
190+
<div data-nstest-role="content">
191+
<div data-nstest-role="collapsible-set">
192+
<div data-nstest-role="collapsible">
193+
<h3>Section A</h3>
194+
195+
<p>I'm the collapsible content in a set so this feels like an accordion. I'm hidden by default because I
196+
have the "collapsed" state; you need to expand the header to see me.</p>
197+
</div>
198+
</div>
199+
</div>
200+
</div>
201+
186202
</body>
187203
</html>

0 commit comments

Comments
 (0)