aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/deprecated.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit/deprecated.js')
-rw-r--r--test/unit/deprecated.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/unit/deprecated.js b/test/unit/deprecated.js
index 962cad4fa..9837b3bae 100644
--- a/test/unit/deprecated.js
+++ b/test/unit/deprecated.js
@@ -208,3 +208,51 @@ QUnit.test( "jQuery.now", function( assert ) {
assert.ok( typeof jQuery.now() === "number", "jQuery.now is a function" );
} );
+
+QUnit.test( "jQuery.proxy", function( assert ) {
+ assert.expect( 9 );
+
+ var test2, test3, test4, fn, cb,
+ test = function() {
+ assert.equal( this, thisObject, "Make sure that scope is set properly." );
+ },
+ thisObject = { foo: "bar", method: test };
+
+ // Make sure normal works
+ test.call( thisObject );
+
+ // Basic scoping
+ jQuery.proxy( test, thisObject )();
+
+ // Another take on it
+ jQuery.proxy( thisObject, "method" )();
+
+ // Make sure it doesn't freak out
+ assert.equal( jQuery.proxy( null, thisObject ), undefined, "Make sure no function was returned." );
+
+ // Partial application
+ test2 = function( a ) {
+ assert.equal( a, "pre-applied", "Ensure arguments can be pre-applied." );
+ };
+ jQuery.proxy( test2, null, "pre-applied" )();
+
+ // Partial application w/ normal arguments
+ test3 = function( a, b ) {
+ assert.equal( b, "normal", "Ensure arguments can be pre-applied and passed as usual." );
+ };
+ jQuery.proxy( test3, null, "pre-applied" )( "normal" );
+
+ // Test old syntax
+ test4 = { "meth": function( a ) {
+ assert.equal( a, "boom", "Ensure old syntax works." );
+ } };
+ jQuery.proxy( test4, "meth" )( "boom" );
+
+ // jQuery 1.9 improved currying with `this` object
+ fn = function() {
+ assert.equal( Array.prototype.join.call( arguments, "," ), "arg1,arg2,arg3", "args passed" );
+ assert.equal( this.foo, "bar", "this-object passed" );
+ };
+ cb = jQuery.proxy( fn, null, "arg1", "arg2" );
+ cb.call( thisObject, "arg3" );
+} );