select test cleanup, added test to check that the dialog hash key is removed when a large select menu item is clicked Fixes #1454

This commit is contained in:
John Bender 2011-04-19 23:26:31 -07:00
parent 16a38a61ea
commit b0e3d5fbf1
3 changed files with 118 additions and 27 deletions

View file

@ -109,6 +109,62 @@
</select>
</div>
<div data-nstest-role="fieldcontain" id="select-choice-many-container-hash-check">
<label for="select-choice-many-hash-check" class="select">Your state:</label>
<select name="select-choice-many-hash-check" id="select-choice-many-hash-check">
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
<option value="FL">Florida</option>
<option value="GA">Georgia</option>
<option value="HI">Hawaii</option>
<option value="ID">Idaho</option>
<option value="IL">Illinois</option>
<option value="IN">Indiana</option>
<option value="IA">Iowa</option>
<option value="KS">Kansas</option>
<option value="KY">Kentucky</option>
<option value="LA">Louisiana</option>
<option value="ME">Maine</option>
<option value="MD">Maryland</option>
<option value="MA">Massachusetts</option>
<option value="MI">Michigan</option>
<option value="MN">Minnesota</option>
<option value="MS">Mississippi</option>
<option value="MO">Missouri</option>
<option value="MT">Montana</option>
<option value="NE">Nebraska</option>
<option value="NV">Nevada</option>
<option value="NH">New Hampshire</option>
<option value="NJ">New Jersey</option>
<option value="NM">New Mexico</option>
<option value="NY">New York</option>
<option value="NC">North Carolina</option>
<option value="ND">North Dakota</option>
<option value="OH">Ohio</option>
<option value="OK">Oklahoma</option>
<option value="OR">Oregon</option>
<option value="PA">Pennsylvania</option>
<option value="RI">Rhode Island</option>
<option value="SC">South Carolina</option>
<option value="SD">South Dakota</option>
<option value="TN">Tennessee</option>
<option value="TX">Texas</option>
<option value="UT">Utah</option>
<option value="VT">Vermont</option>
<option value="VA">Virginia</option>
<option value="WA">Washington</option>
<option value="WV">West Virginia</option>
<option value="WI">Wisconsin</option>
<option value="WY">Wyoming</option>
</select>
</div>
<div data-nstest-role="fieldcontain" id="select-offscreen-container">
<style>
/* keep the select small and close to the screen border to test rendering */

View file

@ -5,7 +5,7 @@
(function($){
var libName = "jquery.mobile.forms.select.js";
$(document).bind('mobileinit', function(){
$(document).bind("mobileinit", function(){
$.mobile.selectmenu.prototype.options.nativeMenu = false;
});
@ -13,16 +13,35 @@
teardown: function(){ location.hash = ""; }
});
asyncTest( "custom select menu always renders screen from the left", function(){
expect( 1 );
var select = $("ul#select-offscreen-menu");
$('#select-offscreen-container a').trigger("click");
$("#select-offscreen-container a").trigger("click");
setTimeout(function(){
ok(select.offset().left >= 30);
start();
}, 1000);
});
asyncTest( "selecting an item from a dialog sized custom select menu leaves no dialog hash key", function(){
var dialogHashKey = "ui-state=dialog";
$.testHelper.sequence([
function(){
$("#select-choice-many-container-hash-check a").trigger("click");
},
function(){
ok(location.hash.indexOf(dialogHashKey) > -1);
$(".ui-page-active li").trigger("click");
},
function(){
ok(location.hash.indexOf(dialogHashKey) == -1);
start();
}
], 500);
});
})(jQuery);

View file

@ -13,42 +13,58 @@
teardown: function(){ location.hash = ""; }
});
test( "a large select menu should come up in a dialog many times", function(){
asyncTest( "a large select menu should come up in a dialog many times", function(){
var menu, select = $("#select-choice-many-container a");
// bring up the dialog
select.trigger("click");
menu = $("#select-choice-many-menu");
same(menu.parents('.ui-dialog').length, 1);
$.testHelper.sequence([
function(){
// bring up the dialog
select.trigger("click");
},
// select and close the dialog
menu.parents('ui-dialog').find("span.ui-icon-delete").click();
function(){
menu = $("#select-choice-many-menu");
same(menu.parents('.ui-dialog').length, 1);
},
//bring up the dialog again
select.trigger("click");
same(menu.parents('.ui-dialog').length, 1);
function(){
// select and close the dialog
menu.parents('ui-dialog').find("span.ui-icon-delete").click();
},
function(){
//bring up the dialog again
select.trigger("click");
},
function(){
same(menu.parents('.ui-dialog').length, 1);
start();
}
], 500);
});
test( "firing a click at least 400 ms later on the select screen overlay does close it", function(){
asyncTest( "firing a click at least 400 ms later on the select screen overlay does close it", function(){
$.Event.prototype.originalEvent = {
touches: [ 'foo' ]
};
$("#select-choice-few-button").trigger("click");
$.testHelper.sequence([
function(){
// bring up the smaller choice menu
$("#select-choice-few-button").trigger("click");
},
// click the first menu item
setTimeout(function(){
$("#select-choice-few-menu a:first").click();
}, 400);
function(){
//select the first menu item
$("#select-choice-few-menu a:first").click();
},
// verify the menu is hidden
setTimeout(function(){
same($("#select-choice-few-menu").parent(".ui-selectmenu-hidden").length, 1);
start();
}, 500);
stop();
function(){
same($("#select-choice-few-menu").parent(".ui-selectmenu-hidden").length, 1);
start();
}
], 400);
});
test( "selects marked with data-native-menu=true should use a div as their button", function(){