X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;ds=inline;f=test%2Funit%2Fevent.js;h=1e40e0f3e6024cfb2c74d57d78c11e0ae57acfb6;hb=735a949a0649f0299e8e4d87b259290970a68ddf;hp=1d9e2e110a85c8090b2372aa544e960d590e9693;hpb=78fc79fad47ce2991c0a7148b65acd7221223eb9;p=jquery.git
diff --git a/test/unit/event.js b/test/unit/event.js
index 1d9e2e1..1e40e0f 100644
--- a/test/unit/event.js
+++ b/test/unit/event.js
@@ -409,7 +409,7 @@ test("bind(), namespaced events, cloned events", 18, function() {
}).trigger("tester");
// Make sure events stick with appendTo'd elements (which are cloned) #2027
- jQuery("test").click(function(){ return false; }).appendTo("p");
+ jQuery("test").click(function(){ return false; }).appendTo("#main");
ok( jQuery("a.test:first").triggerHandler("click") === false, "Handler is bound to appendTo'd elements" );
});
@@ -615,18 +615,18 @@ test("unbind(type)", function() {
message = "unbind many with function";
$elem.bind('error1 error2',error)
- .unbind('error1 error2', error )
- .trigger('error1').triggerHandler('error2');
+ .unbind('error1 error2', error )
+ .trigger('error1').triggerHandler('error2');
message = "unbind many"; // #3538
$elem.bind('error1 error2',error)
- .unbind('error1 error2')
- .trigger('error1').triggerHandler('error2');
+ .unbind('error1 error2')
+ .trigger('error1').triggerHandler('error2');
message = "unbind without a type or handler";
$elem.bind("error1 error2.test",error)
- .unbind()
- .trigger("error1").triggerHandler("error2");
+ .unbind()
+ .trigger("error1").triggerHandler("error2");
});
test("unbind(eventObject)", function() {
@@ -683,6 +683,20 @@ test("hover()", function() {
equals( times, 4, "hover handlers fired" );
});
+test("mouseover triggers mouseenter", function() {
+ expect(1);
+
+ var count = 0,
+ elem = jQuery("");
+ elem.mouseenter(function () {
+ count++;
+ });
+ elem.trigger('mouseover');
+ equals(count, 1, "make sure mouseover triggers a mouseenter" );
+
+ elem.remove();
+});
+
test("trigger() shortcuts", function() {
expect(6);
@@ -1455,6 +1469,8 @@ test("live with change", function(){
});
test("live with submit", function() {
+ expect(5);
+
var count1 = 0, count2 = 0;
jQuery("#testForm").live("submit", function(ev) {
@@ -1471,7 +1487,16 @@ test("live with submit", function() {
equals( count1, 1, "Verify form submit." );
equals( count2, 1, "Verify body submit." );
+ jQuery("#testForm input[name=sub1]").live("click", function(ev) {
+ ok( true, "cancelling submit still calls click handler" );
+ });
+
+ jQuery("#testForm input[name=sub1]")[0].click();
+ equals( count1, 2, "Verify form submit." );
+ equals( count2, 2, "Verify body submit." );
+
jQuery("#testForm").die("submit");
+ jQuery("#testForm input[name=sub1]").die("click");
jQuery("body").die("submit");
});
@@ -1955,6 +1980,31 @@ test("window resize", function() {
ok( !jQuery._data(window, "__events__"), "Make sure all the events are gone." );
});
+test("focusin bubbles", function() {
+ expect(4);
+
+ var input = jQuery( '' ).prependTo( "body" ),
+ order = 0;
+
+ jQuery( "body" ).bind( "focusin.focusinBubblesTest", function(){
+ equals( 1, order++, "focusin on the body second" );
+ });
+
+ input.bind( "focusin.focusinBubblesTest", function(){
+ equals( 0, order++, "focusin on the element first" );
+ });
+
+ // DOM focus method
+ input[0].focus();
+ // jQuery trigger, which calls DOM focus
+ order = 0;
+ input[0].blur();
+ input.trigger( "focus" );
+
+ input.remove();
+ jQuery( "body" ).unbind( "focusin.focusinBubblesTest" );
+});
+
/*
test("jQuery(function($) {})", function() {
stop();