From 524008f5f3433e1b5f2810f54a9f960acc535504 Mon Sep 17 00:00:00 2001 From: John Bender Date: Mon, 29 Nov 2010 23:41:29 -0800 Subject: [PATCH] started mobile.event unit tests --- tests/unit/event/event_core.js | 42 ++++++++++++++++++++++++++++++++++ tests/unit/event/index.html | 34 +++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 tests/unit/event/event_core.js create mode 100644 tests/unit/event/index.html diff --git a/tests/unit/event/event_core.js b/tests/unit/event/event_core.js new file mode 100644 index 00000000..4a50301d --- /dev/null +++ b/tests/unit/event/event_core.js @@ -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); diff --git a/tests/unit/event/index.html b/tests/unit/event/index.html new file mode 100644 index 00000000..a4849907 --- /dev/null +++ b/tests/unit/event/index.html @@ -0,0 +1,34 @@ + + + + + jQuery Mobile Event Test Suite + + + + + + + + + + + + + + + + +

jQuery Mobile Event Test Suite

+

+

+
    +
+ +
+
+
+
+ + +