Comparing version 1.3.6 to 1.3.7
{ | ||
"name": "PubSubJS", | ||
"version": "1.3.6", | ||
"version": "1.3.7", | ||
"main": "src/pubsub.js", | ||
@@ -5,0 +5,0 @@ "ignore": [ |
{ | ||
"name": "pubsub-js", | ||
"version": "1.3.6", | ||
"version": "1.3.7", | ||
"description": "Dependency free publish/subscribe library", | ||
@@ -5,0 +5,0 @@ "main": "./src/pubsub.js", |
@@ -236,2 +236,4 @@ # PubSubJS | ||
## Changelog | ||
* v1.3.7 | ||
* Fix issue #18 - Make publish method return false when all subscribers have been removed | ||
* v1.3.6 | ||
@@ -238,0 +240,0 @@ * Add [bower](http://bower.io) support |
@@ -37,3 +37,3 @@ /* | ||
name: 'PubSubJS', | ||
version: '1.3.6' | ||
version: '1.3.7' | ||
}, | ||
@@ -107,3 +107,3 @@ messages = {}, | ||
return found; | ||
return found && messages[topic].length > 0; | ||
} | ||
@@ -110,0 +110,0 @@ |
@@ -13,3 +13,3 @@ /*jslint white:true, plusplus:true */ | ||
var PubSub = global.PubSub || require("../src/pubsub"), | ||
EXPECTED_VERSION = "1.3.6"; | ||
EXPECTED_VERSION = "1.3.7"; | ||
@@ -16,0 +16,0 @@ buster.testCase( "PubSub module", { |
@@ -12,3 +12,3 @@ /*jslint white:true, stupid:true*/ | ||
"use strict"; | ||
var PubSub = global.PubSub || require("../src/pubsub"), | ||
@@ -22,4 +22,4 @@ TestHelper = global.TestHelper || require("../test/helper"); | ||
assert.equals( PubSub.publish( message ), false ); | ||
}, | ||
}, | ||
"publish method should return true if there are subscribers to a message" : function(){ | ||
@@ -33,2 +33,11 @@ var message = TestHelper.getUniqueString(), | ||
"should return false, when there are no longer any subscribers to a message" : function(){ | ||
var message = TestHelper.getUniqueString(), | ||
func = function(){}, | ||
token = PubSub.subscribe(message, func); | ||
PubSub.unsubscribe(token); | ||
assert.equals( PubSub.publish(message), false ); | ||
}, | ||
"publish method should call all subscribers for a message exactly once" : function(){ | ||
@@ -45,3 +54,3 @@ var message = TestHelper.getUniqueString(), | ||
assert( spy1.calledOnce ); | ||
assert( spy2.calledOnce ); | ||
assert( spy2.calledOnce ); | ||
}, | ||
@@ -54,3 +63,3 @@ | ||
spy2 = this.spy(); | ||
PubSub.subscribe( message1, spy1 ); | ||
@@ -66,3 +75,3 @@ PubSub.subscribe( message2, spy2 ); | ||
}, | ||
"publish method should call subscribers with message as first argument" : function(){ | ||
@@ -72,6 +81,6 @@ var message = TestHelper.getUniqueString(), | ||
PubSub.subscribe( message, spy ); | ||
PubSub.subscribe( message, spy ); | ||
PubSub.publishSync( message, 'some payload' ); | ||
assert( spy.calledWith( message ) ); | ||
assert( spy.calledWith( message ) ); | ||
}, | ||
@@ -84,8 +93,8 @@ | ||
PubSub.subscribe( message, spy ); | ||
PubSub.subscribe( message, spy ); | ||
PubSub.publishSync( message, data ); | ||
assert( spy.calledWith( message, data ) ); | ||
assert( spy.calledWith( message, data ) ); | ||
}, | ||
"publish method should publish method asyncronously" : function( done ){ | ||
@@ -96,14 +105,14 @@ var message = TestHelper.getUniqueString(), | ||
clock = this.useFakeTimers(); | ||
PubSub.subscribe( message, spy ); | ||
PubSub.subscribe( message, spy ); | ||
PubSub.publish( message, data ); | ||
assert.equals( spy.callCount, 0 ); | ||
clock.tick(1); | ||
clock.tick(1); | ||
assert.equals( spy.callCount, 1 ); | ||
done(); | ||
clock.restore(); | ||
}, | ||
"publishSync method should allow syncronous publication" : function(){ | ||
@@ -114,3 +123,3 @@ var message = TestHelper.getUniqueString(), | ||
PubSub.subscribe( message, spy ); | ||
PubSub.subscribe( message, spy ); | ||
PubSub.publishSync( message, data ); | ||
@@ -120,3 +129,3 @@ | ||
}, | ||
"publish method should call all subscribers, even if there are exceptions" : function( done ){ | ||
@@ -140,4 +149,4 @@ var message = TestHelper.getUniqueString(), | ||
assert( spy1.called ); | ||
assert( spy2.called ); | ||
assert( spy1.called ); | ||
assert( spy2.called ); | ||
@@ -166,4 +175,4 @@ done(); | ||
refute( spy1.called ); | ||
refute( spy2.called ); | ||
refute( spy1.called ); | ||
refute( spy2.called ); | ||
@@ -170,0 +179,0 @@ // make sure we restore PubSub to it's original state |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
295740
8629
281