diff --git a/index.js b/index.js index 45a437e..8e069d5 100644 --- a/index.js +++ b/index.js @@ -81,6 +81,8 @@ module.exports = function(serverConfig, sharedConfig, clientStreamHandler){ server = createWebSocketServer(clientStreamHandler); } else if(config.protocol == 'wss') { server = createSecureWebSocketServer(config.ssl, clientStreamHandler); + } else { + throw new Error('negative attach and unknow protocol'); } server._css_host = config.host; diff --git a/tests.js b/tests.js index 9097785..787859e 100644 --- a/tests.js +++ b/tests.js @@ -166,4 +166,24 @@ describe('create-stream-server', function(){ }); }); }); + + it('should throw error if negative attach and unknow protocol', function(done) { + try { + var servers = css({ + s1: { + attach: null, + protocol: 'unknow-protocol', + host: 'localhost', + port: 9010 + } + }, function() {}); + } catch(err) { + assert.deepStrictEqual( + err, + new Error('negative attach and unknow protocol'), + 'negative attach and unknow protocol should error' + ); + done(); + } + }) });