Skip to content

Commit 3d14498

Browse files
committed
moved select caching tests out to a seperate test file to prevent issues in the core test suite
1 parent 907cf65 commit 3d14498

File tree

3 files changed

+97
-58
lines changed

3 files changed

+97
-58
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<title>jQuery Mobile Select Events Test Suite</title>
7+
8+
<script src="../../../js/jquery.js"></script>
9+
<script src="../jquery.setNameSpace.js"></script>
10+
<script src="../../../external/qunit.js"></script>
11+
<script src="../../../tests/jquery.testHelper.js"></script>
12+
<script src="../../../js"></script>
13+
<script src="select_cached.js"></script>
14+
15+
<link rel="stylesheet" href="../../../themes/default/"/>
16+
<link rel="stylesheet" href="../../../external/qunit.css"/>
17+
</head>
18+
<body>
19+
20+
<h1 id="qunit-header">jQuery Mobile Select Event Test Suite</h1>
21+
<h2 id="qunit-banner"></h2>
22+
<h2 id="qunit-userAgent"></h2>
23+
<ol id="qunit-tests">
24+
</ol>
25+
<div id="default" data-nstest-role="page"></div>
26+
</body>
27+
</html>

tests/unit/select/select_cached.js

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* mobile select unit tests
3+
*/
4+
5+
(function($){
6+
var resetHash;
7+
8+
resetHash = function(timeout){
9+
$.testHelper.openPage( location.hash.indexOf("#default") >= 0 ? "#" : "#default" );
10+
};
11+
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;
15+
16+
$.testHelper.pageSequence([
17+
resetHash,
18+
19+
function(){
20+
$.mobile.changePage( "cached.html" );
21+
},
22+
23+
function(){
24+
selectButton = $( "#cached-page-select" ).siblings( 'a' );
25+
selectButton.click();
26+
},
27+
28+
function(){
29+
ok( $.mobile.activePage.hasClass('ui-dialog'), "the dialog came up" );
30+
var option = $.mobile.activePage.find( "li a" ).not(":contains('" + selectButton.text() + "')").last();
31+
value = option.text();
32+
option.click();
33+
},
34+
35+
function(){
36+
same( value, selectButton.text(), "the selected value is propogated back to the button text" );
37+
start();
38+
}
39+
]);
40+
});
41+
42+
// https://github.com/jquery/jquery-mobile/issues/2181
43+
asyncTest( "dialog sized select should prevent the removal of its parent page from the dom", function(){
44+
var selectButton, parentPageId;
45+
46+
expect( 2 );
47+
48+
$.testHelper.pageSequence([
49+
resetHash,
50+
51+
function(){
52+
$.mobile.changePage( "cached.html" );
53+
},
54+
55+
function(){
56+
selectButton = $.mobile.activePage.find( "#cached-page-select" ).siblings( 'a' );
57+
parentPageId = $.mobile.activePage.attr( 'id' );
58+
same( $("#" + parentPageId).length, 1, "establish the parent page exists" );
59+
selectButton.click();
60+
},
61+
62+
function(){
63+
same( $( "#" + parentPageId).length, 1, "make sure parent page is still there after opening the dialog" );
64+
$.mobile.activePage.find( "li a" ).last().click();
65+
},
66+
67+
start
68+
]);
69+
});
70+
})(jQuery);

tests/unit/select/select_core.js

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -253,62 +253,4 @@
253253
same( select.selectmenu( 'option', 'disabled' ), false, "disbaled option set" );
254254
});
255255

256-
// https://github.com/jquery/jquery-mobile/issues/2181
257-
asyncTest( "dialog sized select should alter the value of its parent select", function(){
258-
var selectButton, value;
259-
260-
$.testHelper.pageSequence([
261-
resetHash,
262-
263-
function(){
264-
$.mobile.changePage( "cached.html" );
265-
},
266-
267-
function(){
268-
selectButton = $( "#cached-page-select" ).siblings( 'a' );
269-
selectButton.click();
270-
},
271-
272-
function(){
273-
ok( $.mobile.activePage.hasClass('ui-dialog'), "the dialog came up" );
274-
var option = $.mobile.activePage.find( "li a" ).not(":contains('" + selectButton.text() + "')").last();
275-
value = option.text();
276-
option.click();
277-
},
278-
279-
function(){
280-
same( value, selectButton.text(), "the selected value is propogated back to the button text" );
281-
start();
282-
}
283-
]);
284-
});
285-
286-
// https://github.com/jquery/jquery-mobile/issues/2181
287-
asyncTest( "dialog sized select should prevent the removal of its parent page from the dom", function(){
288-
var selectButton, parentPageId;
289-
290-
expect( 2 );
291-
292-
$.testHelper.pageSequence([
293-
resetHash,
294-
295-
function(){
296-
$.mobile.changePage( "cached.html" );
297-
},
298-
299-
function(){
300-
selectButton = $.mobile.activePage.find( "#cached-page-select" ).siblings( 'a' );
301-
parentPageId = $.mobile.activePage.attr( 'id' );
302-
same( $("#" + parentPageId).length, 1, "establish the parent page exists" );
303-
selectButton.click();
304-
},
305-
306-
function(){
307-
same( $( "#" + parentPageId).length, 1, "make sure parent page is still there after opening the dialog" );
308-
$.mobile.activePage.find( "li a" ).last().click();
309-
},
310-
311-
start
312-
]);
313-
});
314256
})(jQuery);

0 commit comments

Comments
 (0)