2 * mobile select unit tests
8 resetHash = function(timeout){
9 $.testHelper.openPage( location.hash.indexOf("#default") >= 0 ? "#" : "#default" );
12 // https://github.com/jquery/jquery-mobile/issues/2181
13 asyncTest( "dialog sized select should alter the value of its parent select", function(){
14 var selectButton, value;
16 $.testHelper.pageSequence([
20 $.mobile.changePage( "cached.html" );
24 ok( $.mobile.activePage.is("#dialog-select-parent-cache-test"), "cached page appears" );
25 selectButton = $( "#cached-page-select" ).siblings( 'a' );
30 ok( $.mobile.activePage.hasClass('ui-dialog'), "the dialog came up" );
31 var option = $.mobile.activePage.find( "li a" ).not(":contains('" + selectButton.text() + "')").last();
32 value = $.trim(option.text());
37 deepEqual( value, $.trim(selectButton.text()), "the selected value is propogated back to the button text" );
43 // https://github.com/jquery/jquery-mobile/issues/2181
44 asyncTest( "dialog sized select should prevent the removal of its parent page from the dom", function(){
45 var selectButton, parentPageId;
49 $.testHelper.pageSequence([
53 $.mobile.changePage( "cached.html" );
57 selectButton = $.mobile.activePage.find( "#cached-page-select" ).siblings( 'a' );
58 parentPageId = $.mobile.activePage.attr( 'id' );
59 deepEqual( $("#" + parentPageId).length, 1, "establish the parent page exists" );
64 deepEqual( $( "#" + parentPageId).length, 1, "make sure parent page is still there after opening the dialog" );
65 $.mobile.activePage.find( "li a" ).last().click();
72 asyncTest( "dialog sized select shouldn't rebind its parent page remove handler when closing, if the parent page domCache option is true", function(){
75 $.testHelper.pageSequence([
79 $.mobile.changePage( "cached-dom-cache-true.html" );
83 $.mobile.activePage.find( "#domcache-page-select" ).siblings( 'a' ).click();
87 ok( $.mobile.activePage.hasClass('ui-dialog'), "the dialog came up" );
88 $.mobile.activePage.find( "li a" ).last().click();
92 ok( $.mobile.activePage.is( "#dialog-select-parent-domcache-test" ), "the dialog closed" );
93 $.mobile.changePage( $( "#default" ) );
97 deepEqual( $("#dialog-select-parent-domcache-test").length, 1, "make sure the select parent page is still cached in the dom after changing page" );
103 asyncTest( "menupage is removed when the parent page is removed", function(){
104 var dialogCount = $(":jqmData(role='dialog')").length;
105 $.testHelper.pageSequence([
109 $.mobile.changePage( "uncached-dom-cached-false.html" );
113 // for performance reason we don't initially create the menu dialog now
114 deepEqual( $(":jqmData(role='dialog')").length, dialogCount);
116 // manually trigger dialog opening
117 $( "#domcache-uncached-page-select" ).data( 'selectmenu' ).open();
121 // check if dialog was successfully created
122 deepEqual( $(":jqmData(role='dialog')").length, dialogCount + 1 );
123 $( "#domcache-uncached-page-select" ).data( 'selectmenu' ).close();
127 // navigate to parent(initial) page
128 window.history.back();
132 deepEqual( $(":jqmData(role='dialog')").length, dialogCount );