Permalink
Browse files

Added pub/sub tests

  • Loading branch information...
1 parent c9f5a11 commit 2cbebba8e9099a94b8a8b5fc45f098c618ee660f @tj tj committed Oct 19, 2011
Showing with 33 additions and 0 deletions.
  1. +33 −0 test/test.socket.pub-sub.js
  2. 0 test/{test.socket.req.js → test.socket.req-rep.js}
View
33 test/test.socket.pub-sub.js
@@ -0,0 +1,33 @@
+
+var zmq = require('../')
+ , should = require('should');
+
+var pub = zmq.socket('pub')
+ , sub = zmq.socket('sub');
+
+var n = 0;
+
+sub.subscribe('');
+sub.on('message', function(msg){
+ msg.should.be.an.instanceof(Buffer);
+ switch (n++) {
+ case 0:
+ msg.toString().should.equal('foo');
+ break;
+ case 1:
+ msg.toString().should.equal('bar');
+ break;
+ case 2:
+ msg.toString().should.equal('baz');
+ sub.close();
+ pub.close();
+ break;
+ }
+});
+
+sub.bind('inproc://stuff', function(){
+ pub.connect('inproc://stuff');
+ pub.send('foo');
+ pub.send('bar');
+ pub.send('baz');
+});
View
0 test/test.socket.req.js → test/test.socket.req-rep.js
File renamed without changes.

0 comments on commit 2cbebba

Please sign in to comment.