node-ipc/test/TCP/tcpSocketServer.spec.js

42 lines
1.2 KiB
JavaScript
Raw Normal View History

2016-01-10 23:32:46 +11:00
/*global describe, expect, it*/
2016-01-10 20:03:05 +11:00
2021-07-03 07:53:41 +10:00
const ipc = from '../node-ipc');
2016-01-10 20:03:05 +11:00
describe('TCP Socket verification of server',
function TCPSocketSpec(){
it(
'Verify TCP server detects only 1 client out of 2 clients and receives message.',
2016-01-10 23:18:14 +11:00
function testIt(done){
ipc.config.id ='testWorld';
ipc.config.retry = 1000;
2016-01-10 23:18:14 +11:00
let clientCounter=0;
ipc.config.maxConnections=1;
ipc.config.networkPort=8500;
ipc.serveNet(
2016-01-10 23:18:14 +11:00
function serverStarted(){
ipc.server.on(
'connect',
2016-01-11 00:10:48 +11:00
function connected(){
clientCounter++;
}
);
}
);
setTimeout(
2016-01-10 23:18:14 +11:00
function timerDelay(){
expect(clientCounter).toBe(ipc.config.maxConnections);
ipc.server.stop();
done();
},
ipc.config.retry+ipc.config.retry
);
ipc.server.start();
}
);
}
);