tests for newly refreshed items and button update with custom selects

This commit is contained in:
John Bender 2011-09-09 10:41:49 -07:00
parent 59fc26d25f
commit 97654c2d90
2 changed files with 55 additions and 2 deletions

View file

@ -10,8 +10,6 @@
<script src="../../../external/qunit.js"></script>
<script src="../../../tests/jquery.testHelper.js"></script>
<script src="../../../js"></script>
<script src="select_native.js"></script>
<script src="select_events.js"></script>
<script src="select_core.js"></script>
<link rel="stylesheet" href="../../../themes/default/"/>
@ -326,6 +324,14 @@
<option value="-1">default</option>
<option value="-1">other</option>
</select>
<select name="custom-refresh" id="custom-refresh" data-nstest-native-menu="false">
<option value="-1">default</option>
</select>
<select name="custom-refresh-opts-list" id="custom-refresh-opts-list" data-nstest-native-menu="false">
<option value="-1">default</option>
</select>
</div>

View file

@ -253,4 +253,51 @@
same( select.selectmenu( 'option', 'disabled' ), false, "disbaled option set" );
});
test( "adding options and refreshing a custom select defaults the text", function() {
var select = $( "#custom-refresh" ),
button = select.siblings( "a" ).find( ".ui-btn-inner" ),
text = "foo";
same(button.text(), "default");
select.find( "option" ).remove(); //remove the loading message
select.append('<option value="1">' + text + '</option>');
select.selectmenu( 'refresh' );
same(button.text(), text);
});
asyncTest( "adding options and refreshing a custom select changes the options list", function(){
var select = $( "#custom-refresh-opts-list" ),
button = select.siblings( "a" ).find( ".ui-btn-inner" ),
text = "foo";
$.testHelper.sequence([
// bring up the dialog
function() {
button.click();
},
function() {
same( $( ".ui-selectmenu.in ul" ).text(), "default" );
$( ".ui-selectmenu-screen" ).click();
},
function() {
select.find( "option" ).remove(); //remove the loading message
select.append('<option value="1">' + text + '</option>');
select.selectmenu( 'refresh' );
},
function() {
button.click();
},
function() {
same( $( ".ui-selectmenu.in ul" ).text(), text );
$( ".ui-selectmenu-screen" ).click();
},
start
], 500);
});
})(jQuery);