+test("bind(name, false), unbind(name, false)", function() {
+ expect(3);
+
+ var main = 0;
+ jQuery("#main").bind("click", function(e){ main++; });
+ jQuery("#ap").trigger("click");
+ equals( main, 1, "Verify that the trigger happened correctly." );
+
+ main = 0;
+ jQuery("#ap").bind("click", false);
+ jQuery("#ap").trigger("click");
+ equals( main, 0, "Verify that no bubble happened." );
+
+ main = 0;
+ jQuery("#ap").unbind("click", false);
+ jQuery("#ap").trigger("click");
+ equals( main, 1, "Verify that the trigger happened correctly." );
+});
+
+test("bind()/trigger()/unbind() on plain object", function() {
+ expect( 8 );
+
+ var obj = {};
+
+ // Make sure it doesn't complain when no events are found
+ jQuery(obj).trigger("test");
+
+ // Make sure it doesn't complain when no events are found
+ jQuery(obj).unbind("test");
+
+ jQuery(obj).bind({
+ test: function() {
+ ok( true, "Custom event run." );
+ },
+ submit: function() {
+ ok( true, "Custom submit event run." );
+ }
+ });
+
+ var events = jQuery(obj).data("__events__");
+ ok( events, "Object has events bound." );
+ equals( obj.events, undefined, "Events object on plain objects is not events" );
+ equals( typeof events, "function", "'events' expando is a function on plain objects." );
+ equals( obj.test, undefined, "Make sure that test event is not on the plain object." );
+ equals( obj.handle, undefined, "Make sure that the event handler is not on the plain object." );
+
+ // Should trigger 1
+ jQuery(obj).trigger("test");
+ jQuery(obj).trigger("submit");
+
+ jQuery(obj).unbind("test");
+ jQuery(obj).unbind("submit");
+
+ // Should trigger 0
+ jQuery(obj).trigger("test");
+
+ // Make sure it doesn't complain when no events are found
+ jQuery(obj).unbind("test");
+
+ equals( obj.__events__, undefined, "Make sure events object is removed" );
+});
+