node-ipc/test/TCP/tcpSocketServer.spec.js
2021-07-02 14:35:02 -07:00

41 lines
1.2 KiB
JavaScript

/*global describe, expect, it*/
const ipc = from '../node-ipc');
describe('TCP Socket verification of server',
function TCPSocketSpec(){
it(
'Verify TCP server detects only 1 client out of 2 clients and receives message.',
function testIt(done){
ipc.config.id ='testWorld';
ipc.config.retry = 1000;
let clientCounter=0;
ipc.config.maxConnections=1;
ipc.config.networkPort=8500;
ipc.serveNet(
function serverStarted(){
ipc.server.on(
'connect',
function connected(){
clientCounter++;
}
);
}
);
setTimeout(
function timerDelay(){
expect(clientCounter).toBe(ipc.config.maxConnections);
ipc.server.stop();
done();
},
ipc.config.retry+ipc.config.retry
);
ipc.server.start();
}
);
}
);