diff options
author | Dave Methvin <dave.methvin@gmail.com> | 2015-10-01 16:03:10 -0400 |
---|---|---|
committer | Oleg Gaidarenko <markelog@gmail.com> | 2015-10-12 17:34:20 +0300 |
commit | 7e78c2ec81dbb7bac9222864c4981ed0a54b66e5 (patch) | |
tree | df28986985437b923471a7999792a350529dbdaa /test | |
parent | 15f79201c40fda064d184392da33b88a727720da (diff) | |
download | jquery-7e78c2ec81dbb7bac9222864c4981ed0a54b66e5.tar.gz jquery-7e78c2ec81dbb7bac9222864c4981ed0a54b66e5.zip |
Event: Move .bind() and .delegate() to deprecated
Cherry-picked from ee0854f85bd686b55757e8854a10480f23c928da
Fixes gh-2288
Closes gh-2624
Diffstat (limited to 'test')
-rw-r--r-- | test/data/testinit.js | 1 | ||||
-rw-r--r-- | test/unit/deprecated.js | 40 |
2 files changed, 41 insertions, 0 deletions
diff --git a/test/data/testinit.js b/test/data/testinit.js index 903bc9c34..1815d8f7b 100644 --- a/test/data/testinit.js +++ b/test/data/testinit.js @@ -286,6 +286,7 @@ this.loadTests = function() { "unit/core.js", "unit/callbacks.js", "unit/deferred.js", + "unit/deprecated.js", "unit/support.js", "unit/data.js", "unit/queue.js", diff --git a/test/unit/deprecated.js b/test/unit/deprecated.js index 52c137dc3..797290f3b 100644 --- a/test/unit/deprecated.js +++ b/test/unit/deprecated.js @@ -1,2 +1,42 @@ QUnit.module( "deprecated", { teardown: moduleTeardown } ); + +QUnit.test( "bind/unbind", function( assert ) { + assert.expect( 4 ); + + var markup = jQuery( + "<div><p><span><b>b</b></span></p></div>" + ); + + markup + .find( "b" ) + .bind( "click", { bindData: 19 }, function( e, trig ) { + assert.equal( e.type, "click", "correct event type" ); + assert.equal( e.data.bindData, 19, "correct trigger data" ); + assert.equal( trig, 42, "correct bind data" ); + assert.equal( e.target.nodeName.toLowerCase(), "b" , "correct element" ); + } ) + .trigger( "click", [ 42 ] ) + .unbind( "click" ) + .trigger( "click" ) + .remove(); +} ); + +QUnit.test( "delegate/undelegate", function( assert ) { + assert.expect( 2 ); + + var markup = jQuery( + "<div><p><span><b>b</b></span></p></div>" + ); + + markup + .delegate( "b", "click", function( e ) { + assert.equal( e.type, "click", "correct event type" ); + assert.equal( e.target.nodeName.toLowerCase(), "b" , "correct element" ); + } ) + .find( "b" ) + .trigger( "click" ) + .end() + .undelegate( "b", "click" ) + .remove(); +} );
\ No newline at end of file |