mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-05-23 13:45:49 +00:00
58 lines
1.2 KiB
JavaScript
58 lines
1.2 KiB
JavaScript
/*
|
|
* mobile event unit tests
|
|
*/
|
|
|
|
(function( $ ) {
|
|
var libName = "jquery.mobile.event.js",
|
|
events = ("touchstart touchmove touchend orientationchange tap taphold " +
|
|
"swipe swipeleft swiperight scrollstart scrollstop").split( " " );
|
|
|
|
module(libName, {
|
|
teardown: function(){
|
|
$.each(events, function(i, name){
|
|
$("#main").unbind(name);
|
|
});
|
|
}
|
|
});
|
|
|
|
$.testHelper.excludeFileProtocol(function(){
|
|
test( "new events defined on the jquery object", function(){
|
|
$.each(events, function( i, name ) {
|
|
delete $.fn[name];
|
|
same($.fn[name], undefined);
|
|
});
|
|
|
|
$.testHelper.reloadLib(libName);
|
|
|
|
$.each($.fn.clone(events), function( i, name ) {
|
|
ok($.fn[name] !== undefined);
|
|
});
|
|
});
|
|
});
|
|
|
|
test( "defined event functions bind a closure when passed", function(){
|
|
expect( 1 );
|
|
|
|
$('#main')[events[0]](function(){
|
|
ok(true);
|
|
});
|
|
|
|
$('#main').trigger(events[0]);
|
|
});
|
|
|
|
test( "defined event functions trigger the event with no arguments", function(){
|
|
expect( 1 );
|
|
|
|
$('#main')[events[0]](function(){
|
|
ok(true);
|
|
});
|
|
|
|
$('#main')[events[0]]();
|
|
});
|
|
|
|
test( "defining event functions sets the attrFn to true", function(){
|
|
$.each(events, function(i, name){
|
|
ok($.attrFn[name]);
|
|
});
|
|
});
|
|
})(jQuery);
|