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){
|
2016-01-08 10:55:06 +11:00
|
|
|
|
2016-01-10 22:38:19 +11:00
|
|
|
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(
|
2016-01-10 22:38:19 +11:00
|
|
|
'/tmp/app.testWorld',
|
2016-01-10 20:03:05 +11:00
|
|
|
function serverStarted(){
|
|
|
|
ipc.server.on(
|
2016-01-10 22:38:19 +11:00
|
|
|
'connect',
|
2016-01-10 23:57:08 +11:00
|
|
|
function connected(){
|
2016-01-10 20:03:05 +11:00
|
|
|
clientCounter++;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2016-01-10 22:38:19 +11:00
|
|
|
setTimeout(
|
2016-01-10 23:57:08 +11:00
|
|
|
function clientCountDelay(){
|
2016-01-10 22:38:19 +11:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|