mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-05-13 00:53:10 +00:00
started mobile.event unit tests
This commit is contained in:
parent
419787affe
commit
524008f5f3
2 changed files with 76 additions and 0 deletions
42
tests/unit/event/event_core.js
Normal file
42
tests/unit/event/event_core.js
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* 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);
|
||||
|
||||
$.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( "defining event functions sets the attrFn to true", function(){
|
||||
$.each(events, function(i, name){
|
||||
ok($.attrFn[name]);
|
||||
});
|
||||
});
|
||||
})(jQuery);
|
||||
34
tests/unit/event/index.html
Normal file
34
tests/unit/event/index.html
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>jQuery Mobile Event Test Suite</title>
|
||||
|
||||
<script type="text/javascript" src="../../../js/jquery.js"></script>
|
||||
<script type="text/javascript" src="../../../tests/jquery.testHelper.js"></script>
|
||||
<script type="text/javascript" src="../../../js/jquery.ui.widget.js"></script>
|
||||
<script type="text/javascript" src="../../../js/jquery.mobile.widget.js"></script>
|
||||
<script type="text/javascript" src="../../../js/jquery.mobile.media.js"></script>
|
||||
<script type="text/javascript" src="../../../js/jquery.mobile.support.js"></script>
|
||||
<script type="text/javascript" src="../../../js/jquery.mobile.event.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/>
|
||||
<script type="text/javascript" src="../../../external/qunit.js"></script>
|
||||
|
||||
<script type="text/javascript" src="event_core.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1 id="qunit-header">jQuery Mobile Event Test Suite</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests">
|
||||
</ol>
|
||||
|
||||
<div id="main" style="position: absolute; top: -10000px; left: -10000px;">
|
||||
<div data-role="page">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in a new issue