Browse files

[controlgroup unit tests] Add test to make sure re-instantiation beha…

…ves like .refresh()
  • Loading branch information...
1 parent aa7a04b commit 40e27982cc8f8641d8bab48ea9a576efeadc80b7 @gabrielschulhof gabrielschulhof committed Nov 16, 2012
Showing with 23 additions and 0 deletions.
  1. +16 −0 tests/unit/controlgroup/controlgroup_core.js
  2. +7 −0 tests/unit/controlgroup/index.html
View
16 tests/unit/controlgroup/controlgroup_core.js
@@ -142,4 +142,20 @@
$.mobile.ignoreContentEnabled = false;
});
+
+ test( "calling .controlgroup() again is the same as calling .controlgroup( 'refresh' )", function() {
+ var btn1 = $( "<a href='#' data-" + ( $.mobile.ns || "" ) + "role='button'>Option 3</a>" ).buttonMarkup(),
+ btn2 = $( "<a href='#' data-" + ( $.mobile.ns || "" ) + "role='button'>Option 4</a>" ).buttonMarkup(),
+ grp = $( "#test-reinstantiate" )
+
+ grp
+ .controlgroup( "container" )
+ .prepend( btn1 )
+ .append( btn2 )
+ grp
+ .controlgroup();
+
+ ok( btn1.hasClass( "ui-first-child" ), "The prepended button has class ui-first-child" );
+ ok( btn2.hasClass( "ui-last-child" ), "The appended button has class ui-last-child" );
+ });
})(jQuery);
View
7 tests/unit/controlgroup/index.html
@@ -73,6 +73,13 @@ <h2 id="qunit-userAgent"></h2>
</fieldset>
</div>
+ <div data-nstest-role="fieldcontain">
+ <fieldset data-nstest-role="controlgroup" id="test-reinstantiate">
+ <legend>Options</legend>
+ <a href="#" data-nstest-role="button">Option 1</a>
+ <a href="#" data-nstest-role="button">Option 2</a>
+ </fieldset>
+ </div>
</div>
</div>

0 comments on commit 40e2798

Please sign in to comment.