jQuery.subscribe now returns a handle that can be passed to jQuery.unsubscribe to... well... unsubscribe. Unit test amended.

This commit is contained in:
jaubourg 2011-05-24 21:18:08 +02:00
parent 4dce543ee6
commit 55df216125
2 changed files with 37 additions and 15 deletions

View file

@ -42,7 +42,7 @@ test( "jQuery.Channel - Named Channel", function() {
test( "jQuery.Channel - Helpers", function() {
expect( 2 );
expect( 4 );
function callback( value ) {
ok( true, "Callback called" );
@ -53,4 +53,16 @@ test( "jQuery.Channel - Helpers", function() {
jQuery.publish( "test" , "test" );
jQuery.unsubscribe( "test", callback );
jQuery.publish( "test" , "test" );
var test = true,
subscription = jQuery.subscribe( "test", function() {
ok( test, "first callback called" );
}, function() {
ok( test, "second callback called" );
});
jQuery.publish( "test" );
test = false;
jQuery.unsubscribe( subscription );
jQuery.publish( "test" );
});