2 * mobile select unit tests
6 module("jquery.mobile.forms.select native");
8 test( "native menu selections alter the button text", function(){
9 var select = $( "#native-select-choice-few" ), setAndCheck;
11 setAndCheck = function(key){
14 select.val( key ).selectmenu( 'refresh' );
15 text = select.find( "option[value='" + key + "']" ).text();
16 same( select.parent().find(".ui-btn-text").text(), text );
19 setAndCheck( 'rush' );
20 setAndCheck( 'standard' );
23 asyncTest( "selecting a value removes the related buttons down state", function(){
24 var select = $( "#native-select-choice-few" );
26 $.testHelper.sequence([
28 // click the native menu parent button
29 select.parent().trigger( 'vmousedown' );
33 ok( select.parent().hasClass("ui-btn-down-c"), "button down class added" );
37 // trigger a change on the select
38 select.trigger( "change" );
42 ok( !select.parent().hasClass("ui-btn-down-c"), "button down class removed" );
48 // issue https://github.com/jquery/jquery-mobile/issues/2410
49 test( "adding options and refreshing a native select defaults the text", function() {
50 var select = $( "#native-refresh" ),
51 button = select.siblings( '.ui-btn-inner' ),
54 same(button.text(), "default");
55 select.find( "option" ).remove(); //remove the loading message
56 select.append('<option value="1">' + text + '</option>');
57 select.selectmenu('refresh');
58 same(button.text(), text);
62 test( "native selects should provide open and close as a no-op", function() {
63 // exception will prevent test success if undef
64 $( "#native-refresh" ).selectmenu( 'open' );
65 $( "#native-refresh" ).selectmenu( 'close' );