Use a key name less likely to result in collisions for events on plain JS objects...
[jquery.git] / test / unit / event.js
index 6d0fd9b..b37b253 100644 (file)
@@ -210,7 +210,7 @@ test("live/die(Object), delegate/undelegate(String, Object)", function() {
        expect(6);
        
        var clickCounter = 0, mouseoverCounter = 0,
-               $p = jQuery("#firstp"), $a = $p.find("a").first();
+               $p = jQuery("#firstp"), $a = $p.find("a:first");
        
        var events = {
                click: function( event ) {
@@ -255,7 +255,7 @@ test("bind(), iframes", function() {
 });
 
 test("bind(), trigger change on select", function() {
-       expect(3);
+       expect(5);
        var counter = 0;
        function selectOnChange(event) {
                equals( event.data, counter++, "Event.data is not a global event object" );
@@ -443,7 +443,7 @@ test("bind(name, false), unbind(name, false)", function() {
 });
 
 test("bind()/trigger()/unbind() on plain object", function() {
-       expect( 2 );
+       expect( 5 );
 
        var obj = {};
 
@@ -457,7 +457,11 @@ test("bind()/trigger()/unbind() on plain object", function() {
                ok( true, "Custom event run." );
        });
 
-       ok( jQuery(obj).data("events"), "Object has events bound." );
+       var events = jQuery(obj).data("__events__");
+       ok( events, "Object has events bound." );
+       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");
@@ -1825,6 +1829,18 @@ test("Non DOM element events", function() {
        jQuery(o).trigger('nonelementobj');
 });
 
+test("window resize", function() {
+       expect(2);
+
+       jQuery(window).unbind();
+
+       jQuery(window).bind("resize", function(){
+               ok( true, "Resize event fired." );
+       }).resize().unbind("resize");
+
+       ok( !jQuery(window).data("events"), "Make sure all the events are gone." );
+});
+
 /*
 test("jQuery(function($) {})", function() {
        stop();