Skip to content

Commit 262b7dc

Browse files
author
scottjehl
committed
Merge remote branch 'origin/master'
2 parents 845dc1e + 8bbc9f8 commit 262b7dc

File tree

4 files changed

+61
-111
lines changed

4 files changed

+61
-111
lines changed

js/jquery.mobile.define.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// creates the define method on window, only used where async loading
22
// is not desired in the docs and experiments
33
window.define = function(){
4-
Array.prototype.slice.call(arguments).pop()();
4+
Array.prototype.slice.call( arguments ).pop()( window.jQuery );
55
};

tests/unit/event/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
$.testHelper.setPushState();
1313
</script>
1414

15+
<script src="../../../js/jquery.mobile.define.js"></script>
1516
<script src="../../../js/jquery.mobile.event.js"></script>
1617
<script src="../../../js/"></script>
1718

tests/unit/init/index.html

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,16 @@
44
<meta charset="UTF-8" />
55
<title>jQuery Mobile Init Test Suite</title>
66
<!-- meta viewport left out on purpose for test append -->
7-
<script src="../../../external/requirejs/require.js"></script>
87
<script src="../../../js/jquery.js"></script>
98
<script src="../jquery.setNameSpace.js"></script>
10-
<script src="../../../tests/jquery.testHelper.js"></script>
9+
<script src="../../../js/"></script>
1110
<script src="../../../external/qunit.js"></script>
12-
<script>
13-
$.testHelper.asyncLoad([
14-
[
15-
"jquery.mobile.core",
16-
"jquery.mobile.hashchange",
17-
],
18-
[ "init_core.js" ],
19-
[ "jquery.mobile.init" ]
20-
]);
21-
</script>
22-
23-
<link rel="stylesheet" href="../../../css/themes/default/jquery.mobile.css"/>
11+
<script src="../../jquery.testHelper.js"></script>
12+
<script src="init_core.js"></script>
13+
<!-- added explicitly for library reloading (see testHelper ) -->
14+
<script src="../../../js/jquery.mobile.core.js"></script>
15+
<script src="../../../js/jquery.mobile.init.js"></script>
16+
<link rel="stylesheet" href="../../../css/themes/default/" />
2417
<link rel="stylesheet" href="../../../external/qunit.css"/>
2518

2619
<script src="../swarminject.js"></script>

tests/unit/init/init_core.js

Lines changed: 52 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,15 @@
33
*/
44
(function($){
55
var mobilePage = undefined,
6-
libName = 'jquery.mobile.init',
7-
coreLib = 'jquery.mobile.core',
6+
libName = 'jquery.mobile.init.js',
7+
coreLib = 'jquery.mobile.core.js',
88
extendFn = $.extend,
99
originalLoadingMessage = $.mobile.loadingMessage;
1010
setGradeA = function(value) { $.mobile.gradeA = function(){ return value; }; },
1111
reloadCoreNSandInit = function(){
12-
return $.testHelper.deferredSequence([
13-
function() {
14-
$.testHelper.reloadModule("../jquery.setNameSpace.js");
15-
},
16-
function () {
17-
$.testHelper.reloadModule(libName);
18-
}
19-
]);
12+
$.testHelper.reloadLib(coreLib);
13+
$.testHelper.reloadLib("jquery.setNamespace.js");
14+
$.testHelper.reloadLib(libName);
2015
};
2116

2217

@@ -61,40 +56,27 @@
6156
initFired = true;
6257
});
6358

59+
$.testHelper.reloadLib(libName);
6460

65-
$.testHelper.deferredSequence([
66-
function() {
67-
return $.testHelper.reloadModule(libName);
68-
},
69-
70-
function() {
71-
setTimeout(function(){
72-
ok(initFired, "init fired");
73-
start();
74-
}, 1000);
75-
}
76-
]);
61+
setTimeout(function(){
62+
ok(initFired, "init fired");
63+
start();
64+
}, 1000);
7765
});
7866

79-
asyncTest( "enhancments are skipped when the browser is not grade A", function(){
67+
test( "enhancments are skipped when the browser is not grade A", function(){
8068
setGradeA(false);
81-
$.testHelper.reloadModule(libName).done(
82-
function() {
83-
//NOTE easiest way to check for enhancements, not the most obvious
84-
ok(!$("html").hasClass("ui-mobile"), "html elem doesn't have class ui-mobile");
85-
start();
86-
}
87-
);
69+
$.testHelper.reloadLib(libName);
70+
71+
//NOTE easiest way to check for enhancements, not the most obvious
72+
ok(!$("html").hasClass("ui-mobile"), "html elem doesn't have class ui-mobile");
8873
});
8974

90-
asyncTest( "enhancments are added when the browser is grade A", function(){
75+
test( "enhancments are added when the browser is grade A", function(){
9176
setGradeA(true);
92-
$.testHelper.reloadModule(libName).done(
93-
function() {
94-
ok($("html").hasClass("ui-mobile"), "html elem has class mobile");
95-
start();
96-
}
97-
);
77+
$.testHelper.reloadLib(libName);
78+
79+
ok($("html").hasClass("ui-mobile"), "html elem has class mobile");
9880
});
9981

10082
asyncTest( "useFastClick is configurable via mobileinit", function(){
@@ -103,12 +85,10 @@
10385
start();
10486
});
10587

106-
$.testHelper.reloadModule(libName).done(
107-
function() {
108-
same( $.mobile.useFastClick, false , "fast click is set to false after init" );
109-
$.mobile.useFastClick = true;
110-
}
111-
);
88+
$.testHelper.reloadLib(libName);
89+
90+
same( $.mobile.useFastClick, false , "fast click is set to false after init" );
91+
$.mobile.useFastClick = true;
11292
});
11393

11494

@@ -117,47 +97,35 @@
11797
return $(":jqmData(role='page')").first();
11898
};
11999

120-
asyncTest( "active page and start page should be set to the fist page in the selected set", function(){
100+
test( "active page and start page should be set to the fist page in the selected set", function(){
121101
expect( 2 );
122-
$.testHelper.reloadModule(libName).done(
123-
function() {
124-
var firstPage = findFirstPage();
102+
$.testHelper.reloadLib(libName);
103+
var firstPage = findFirstPage();
125104

126-
same($.mobile.firstPage[0], firstPage[0]);
127-
same($.mobile.activePage[0], firstPage[0]);
128-
start();
129-
}
130-
);
105+
same($.mobile.firstPage[0], firstPage[0]);
106+
same($.mobile.activePage[0], firstPage[0]);
131107
});
132108

133-
asyncTest( "mobile viewport class is defined on the first page's parent", function(){
109+
test( "mobile viewport class is defined on the first page's parent", function(){
134110
expect( 1 );
135-
$.testHelper.reloadModule(libName).done(
136-
function() {
137-
var firstPage = findFirstPage();
111+
$.testHelper.reloadLib(libName);
112+
var firstPage = findFirstPage();
138113

139-
ok(firstPage.parent().hasClass("ui-mobile-viewport"), "first page has viewport");
140-
start();
141-
}
142-
);
114+
ok(firstPage.parent().hasClass("ui-mobile-viewport"), "first page has viewport");
143115
});
144116

145-
asyncTest( "mobile page container is the first page's parent", function(){
117+
test( "mobile page container is the first page's parent", function(){
146118
expect( 1 );
147-
$.testHelper.reloadModule(libName).done(
148-
function() {
149-
var firstPage = findFirstPage();
119+
$.testHelper.reloadLib(libName);
120+
var firstPage = findFirstPage();
150121

151-
same($.mobile.pageContainer[0], firstPage.parent()[0]);
152-
start();
153-
}
154-
);
122+
same($.mobile.pageContainer[0], firstPage.parent()[0]);
155123
});
156124

157125
asyncTest( "hashchange triggered on document ready with single argument: true", function(){
158126
$.testHelper.sequence([
159127
function(){
160-
$.testHelper.openPage( "#foo" );
128+
location.hash = "#foo";
161129
},
162130

163131
// delay the bind until the first hashchange
@@ -169,7 +137,7 @@
169137
},
170138

171139
function(){
172-
return $.testHelper.reloadModule(libName);
140+
$.testHelper.reloadLib(libName);
173141
}
174142
], 1000);
175143
});
@@ -217,38 +185,24 @@
217185

218186
asyncTest( "page loading should contain default loading message", function(){
219187
expect( 1 );
188+
reloadCoreNSandInit();
189+
$.mobile.showPageLoadingMsg();
220190

221-
$.testHelper.deferredSequence([
222-
function() {
223-
return $.testHelper.reloadModule(libName);
224-
},
225-
function() {
226-
$.mobile.showPageLoadingMsg();
227-
228-
setTimeout(function(){
229-
same($(".ui-loader h1").text(), "loading");
230-
start();
231-
}, 500);
232-
}
233-
]);
191+
setTimeout(function(){
192+
same($(".ui-loader h1").text(), "loading");
193+
start();
194+
}, 500);
234195
});
235196

236197
asyncTest( "page loading should contain custom loading message", function(){
237198
$.mobile.loadingMessage = "foo";
199+
$.testHelper.reloadLib(libName);
200+
$.mobile.showPageLoadingMsg();
238201

239-
$.testHelper.deferredSequence([
240-
function() {
241-
return $.testHelper.reloadModule(libName);
242-
},
243-
function() {
244-
$.mobile.showPageLoadingMsg();
245-
246-
setTimeout(function(){
247-
same($(".ui-loader h1").text(), "foo");
248-
start();
249-
}, 500);
250-
}
251-
]);
202+
setTimeout(function(){
203+
same($(".ui-loader h1").text(), "foo");
204+
start();
205+
}, 500);
252206
});
253207

254208
asyncTest( "page loading should contain custom loading message when set during runtime", function(){
@@ -262,8 +216,10 @@
262216
});
263217

264218

219+
265220
// NOTE: the next two tests work on timeouts that assume a page will be created within 2 seconds
266221
// it'd be great to get these using a more reliable callback or event
222+
267223
asyncTest( "page does auto-initialize at domready when autoinitialize option is true (default) ", function(){
268224

269225
$( "<div />", { "data-nstest-role": "page", "id": "autoinit-on" } ).prependTo( "body" )

0 commit comments

Comments
 (0)