aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorjaubourg <j@ubourg.net>2012-04-25 15:50:26 +0200
committerjaubourg <j@ubourg.net>2012-04-25 15:50:26 +0200
commit97210d4e700aba1b67ac3652303bb685d129aced (patch)
tree113a0352929c47a74ffacd1863f55a21684c73a1 /test
parentf30744354f9dd0966b728ea48576612c4354a64b (diff)
downloadjquery-97210d4e700aba1b67ac3652303bb685d129aced.tar.gz
jquery-97210d4e700aba1b67ac3652303bb685d129aced.zip
How about we save 62 bytes? Also ensure that the arguments array given to fireWith is copied internally.
Diffstat (limited to 'test')
-rw-r--r--test/unit/callbacks.js24
1 files changed, 19 insertions, 5 deletions
diff --git a/test/unit/callbacks.js b/test/unit/callbacks.js
index d1e8fbd6d..6fca16be9 100644
--- a/test/unit/callbacks.js
+++ b/test/unit/callbacks.js
@@ -209,15 +209,29 @@ test( "jQuery.Callbacks( options ) - options are copied", function() {
expect( 1 );
var options = {
- memory: true
+ unique: true
},
- cb = jQuery.Callbacks( options );
+ cb = jQuery.Callbacks( options ),
+ count = 0,
+ fn = function() {
+ ok( !( count++ ), "called once" );
+ };
+ options.unique = false;
+ cb.add( fn, fn );
+ cb.fire();
+});
+
+test( "jQuery.Callbacks.fireWith - arguments are copied", function() {
+
+ expect( 1 );
- options.memory = false;
+ var cb = jQuery.Callbacks( "memory" ),
+ args = [ "hello" ];
- cb.fire( "hello" );
+ cb.fireWith( null, args );
+ args[ 0 ] = "world";
cb.add(function( hello ) {
- strictEqual( hello, "hello", "options are copied internally" );
+ strictEqual( hello, "hello", "arguments are copied internally" );
});
});