Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add a test for unsubscribing requests.

  • Loading branch information...
commit f5b48f22ee5c05debfc22bdab82f065dd56aca81 1 parent b5ef3c4
@jvoorhis authored
Showing with 29 additions and 1 deletion.
  1. +29 −1 test/basics.js
View
30 test/basics.js
@@ -94,6 +94,34 @@ describe('Basics', function() {
});
+ it('should return a sub id for requests', function(done) {
+ var nc = NATS.connect(PORT);
+ var initMsg = 'Hello World';
+ var replyMsg = 'Hello Back!';
+ var expected = 1;
+ var received = 0;
+
+ // Add two subscribers. We will only receive a reply from one.
+ nc.subscribe('foo', function(msg, reply) {
+ nc.publish(reply, replyMsg);
+ });
+
+ nc.subscribe('foo', function(msg, reply) {
+ nc.publish(reply, replyMsg);
+ });
+
+ var sub = nc.request('foo', initMsg, function(reply) {
+ received += 1;
+ nc.unsubscribe(sub);
+
+ setTimeout(function() {

Make this a flush, so no worries about timing issues..

 nc.flush(function() {
   received.should.equal(expected);
    nc.close();
    done();
  });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ received.should.equal(expected);
+ nc.close();
+ done();
+ }, 0);
+ });
+ });
+
it('should do single partial wildcard subscriptions correctly', function(done) {
var nc = NATS.connect(PORT);
var expected = 3;
@@ -192,4 +220,4 @@ describe('Basics', function() {
});
});
-});
+});
@derekcollison

Make this a flush, so no worries about timing issues..

 nc.flush(function() {
   received.should.equal(expected);
    nc.close();
    done();
  });
Please sign in to comment.
Something went wrong with that request. Please try again.