From 5f8ef3e689dbc1561cd877e3007b36ac993f5d16 Mon Sep 17 00:00:00 2001 From: lsm Date: Tue, 5 Apr 2016 00:35:16 -0700 Subject: [PATCH] More test for hub pubsub. --- test/hub.test.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/test/hub.test.js b/test/hub.test.js index 5ef442e..bbf0ebf 100644 --- a/test/hub.test.js +++ b/test/hub.test.js @@ -20,10 +20,10 @@ module.exports = function() { var tlsEndpoint = 'tls://localhost:46364' // Servers - smqHub.bind(eioEndpoint) - smqHub.bind(tcpEndpoint, function(stream) { - t.ok(stream) + smqHub.bind(eioEndpoint, function(stream) { + t.ok(stream, 'eio stream') }) + smqHub.bind(tcpEndpoint) smqHub.bind(tlsEndpoint, { key: fs.readFileSync(certPath + '/server-key.pem'), cert: fs.readFileSync(certPath + '/server-cert.pem'), @@ -40,20 +40,26 @@ module.exports = function() { eioClient = socketmq.connect(eioEndpoint) tcpClient = socketmq.connect(tcpEndpoint) tlsClient = socketmq.connect(tlsEndpoint, tlsClientOptions) + + eioClient.pub('eio pub', ['eio', 3]) }) test('hub: pub/sub', function(t) { - t.plan(2) + t.plan(4) var msg = 'hub pub sub' eioClient.sub('pub sub', function(arg1) { - t.equal(arg1, msg) + t.equal(arg1, msg, 'eio get pub from tls') }) tcpClient.sub('pub sub', function(arg1) { - t.equal(arg1, msg) + t.equal(arg1, msg, 'tcp get pub from tls') }) tlsClient.sub('pub sub', function() { - t.notOk(true) + t.notOk(true, 'tls should not get pub msg from itself') + }) + tlsClient.sub('eio pub', function(arr) { + t.equal(arr[0], 'eio', 'eio->tls arr[0] match') + t.equal(arr[1], 3, 'eio->tls arr[1] match') }) tlsClient.pub('pub sub', msg)