node-ipc/test/Unix/unixSocketServer.spec.js

46 lines
1.3 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:35:02 +10:00
const ipc = from '../../node-ipc');
2016-01-10 20:03:05 +11:00
describe(
'Test Cases for server: ',
function testDescribe(){
// Unix server verification //
it(
'Verify unix server detects only 1 client out of 2 clients and receives message.',
function testIt(done){
ipc.config.id ='testWorld';
ipc.config.retry = 1000;
ipc.config.silent=false;
let clientCounter=0;
2016-01-10 20:03:05 +11:00
ipc.config.maxConnections=1;
ipc.serve(
'/tmp/app.testWorld',
2016-01-10 20:03:05 +11:00
function serverStarted(){
ipc.server.on(
'connect',
2016-01-10 23:57:08 +11:00
function connected(){
2016-01-10 20:03:05 +11:00
clientCounter++;
}
);
}
);
setTimeout(
2016-01-10 23:57:08 +11:00
function clientCountDelay(){
expect(clientCounter).toBe(ipc.config.maxConnections);
ipc.server.stop();
done();
},
ipc.config.retry+ipc.config.retry
);
2016-01-10 20:03:05 +11:00
ipc.server.start();
}
);
}
);