Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit b6cfd58

Browse files
author
Gabriel Schulhof
committed
Tests: Integration: Custom select: Ensure dialog is removed after destroying dialog-sized select menu.
Applied manually from b070b64
1 parent 2e55b22 commit b6cfd58

File tree

1 file changed

+83
-13
lines changed

1 file changed

+83
-13
lines changed

tests/unit/select/select_core.js

Lines changed: 83 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -501,27 +501,97 @@
501501
});
502502

503503
asyncTest( "destroying a custom select menu leaves no traces", function() {
504-
$.testHelper.pageSequence( [
505-
function() { $.mobile.changePage( "#destroyTestCustom" ); },
504+
expect( 7 );
505+
506+
var unenhancedSelectClone,
507+
prefix = ".destroyingASelectMenuLeavesNoTraces",
508+
id = "select-" + Math.round( Math.random() * 1177 ),
509+
unenhancedSelect = $(
510+
"<select id='" + id + "' data-" + ( $.mobile.ns || "" ) + "native-menu='false'>" +
511+
"<option>Title</option>" +
512+
"<option value='option1'>Option 1</option>" +
513+
"<option value='option2'>Option 2</option>" +
514+
"</select>");
515+
$.testHelper.detailedEventCascade( [
506516
function() {
507-
var unenhancedSelect = $(
508-
"<select data-" + ( $.mobile.ns || "" ) + "native-menu='false'>" +
509-
"<option>Title</option>" +
510-
"<option value='option1'>Option 1</option>" +
511-
"<option value='option2'>Option 2</option>" +
512-
"</select>"),
513-
unenhancedSelectClone = unenhancedSelect.clone();
517+
$.mobile.changePage( "#destroyTest" );
518+
},
519+
520+
{
521+
pagechange: { src: $.mobile.pageContainer, event: "pagechange" + prefix + "0" }
522+
},
523+
524+
function() {
525+
unenhancedSelectClone = unenhancedSelect.clone();
514526

515-
$( "#destroyTestCustom" ).append( unenhancedSelectClone );
527+
$( "#destroyTest" ).append( unenhancedSelectClone );
516528
unenhancedSelectClone.selectmenu();
529+
$( "#" + id + "-button" ).click();
530+
},
531+
532+
{
533+
popupafteropen: { src: $.mobile.document, event: "popupafteropen" + prefix + "1" }
534+
},
535+
536+
function( result ) {
537+
deepEqual( result.popupafteropen.timedOut, false, "Popup did open" );
538+
$( "#" + id + "-listbox" ).popup( "close" );
539+
},
540+
541+
{
542+
popupafterclose: { src: $.mobile.document, event: "popupafterclose" + prefix + "2" }
543+
},
544+
545+
function( result ) {
546+
var idx;
547+
548+
deepEqual( result.popupafterclose.timedOut, false, "Popup did close" );
549+
517550
unenhancedSelectClone.selectmenu( "destroy" );
518551
unenhancedSelectClone.remove();
519552

520-
deepEqual( $( "#destroyTestCustom" ).children().length, 0, "After adding, enhancing, destroying, and removing the select menu, the page is empty" );
553+
deepEqual( $( "#destroyTest" ).children().length, 0, "After adding, enhancing, opening, destroying, and removing the popup-sized select menu, the page is empty" );
521554
ok( domEqual( unenhancedSelect, unenhancedSelectClone ), "DOM for select after enhancement/destruction is equal to DOM for unenhanced select" );
555+
556+
// Add a bunch of options to make sure the menu ends up larger than
557+
// the screen, thus requiring a dialog
558+
for ( idx = 3 ; idx < 60 ; idx++ ) {
559+
unenhancedSelect.append( "<option value='option" + idx + "'>Option " + idx + "</option>" );
560+
}
561+
unenhancedSelectClone = unenhancedSelect.clone();
562+
$( "#destroyTest" ).append( unenhancedSelectClone );
563+
unenhancedSelectClone.selectmenu();
564+
$( "#" + id + "-button" ).click();
522565
},
523-
function() { $.mobile.back(); },
524-
function() { start(); }
566+
567+
{
568+
pagechange: { src: $.mobile.pageContainer, event: "pagechange" + prefix + "3" }
569+
},
570+
571+
function() {
572+
// Close the dialog
573+
$.mobile.activePage.find( "a:first" ).click();
574+
},
575+
576+
{
577+
pagechange: { src: $.mobile.pageContainer, event: "pagechange" + prefix + "4" }
578+
},
579+
580+
function() {
581+
unenhancedSelectClone.selectmenu( "destroy" );
582+
unenhancedSelectClone.remove();
583+
584+
deepEqual( $( "#destroyTest" ).children().length, 0, "After adding, enhancing, opening, destroying, and removing the dialog-sized select menu, the page is empty" );
585+
ok( domEqual( unenhancedSelect, unenhancedSelectClone ), "DOM for select after enhancement/destruction is equal to DOM for unenhanced select" );
586+
deepEqual( $( "#" + id + "-dialog" ).length, 0, "After adding, enhancing, opening, destroying, and removing the dialog-sized select menu, no dialog page is left behind" );
587+
$.mobile.back();
588+
},
589+
590+
{
591+
pagechange: { src: $.mobile.pageContainer, event: "pagechange" + prefix + "5" }
592+
},
593+
594+
start
525595
]);
526596
});
527597

0 commit comments

Comments
 (0)