forked from jquery-archive/jquery-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjquery.testHelper.js
More file actions
58 lines (48 loc) · 1.28 KB
/
jquery.testHelper.js
File metadata and controls
58 lines (48 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* mobile support unit tests
*/
(function( $ ) {
$.testHelper = {
excludeFileProtocol: function(callback){
var message = "Tests require script reload and cannot be run via file: protocol";
if (location.protocol == "file:") {
test(message, function(){
ok(false, message);
});
} else {
callback();
}
},
reloads: {},
reloadLib: function(libName){
if(this.reloads[libName] === undefined) {
this.reloads[libName] = {
lib: $("script[src$=" + libName + "]"),
count: 0
};
}
var lib = this.reloads[libName].lib.clone(),
src = lib.attr('src');
//NOTE append "cache breaker" to force reload
lib.attr('src', src + "?" + this.reloads[libName].count++);
$("body").append(lib);
},
alterExtend: function(extraExtension){
var extendFn = $.extend;
$.extend = function(object, extension){
// NOTE extend the object as normal
var result = extendFn.apply(this, arguments);
// NOTE add custom extensions
result = extendFn(result, extraExtension);
return result;
};
},
hideActivePageWhenComplete: function() {
if( $('#qunit-testresult').length > 0 ) {
$('.ui-page-active').css('display', 'none');
} else {
setTimeout($.testHelper.hideActivePageWhenComplete, 500);
}
}
};
})(jQuery);