some extra test
This commit is contained in:
@@ -65,6 +65,35 @@ describe('RPCServer', () => {
|
||||
await server.destroy()
|
||||
})
|
||||
|
||||
it('should be able to use all kinds of RPC definitions', (done) => {
|
||||
const echo = (x) => x
|
||||
const server = new RPCServer(20003, [{
|
||||
name: 'HelloWorldRPCGroup',
|
||||
exportRPCs: () => [
|
||||
echo, //named function variable
|
||||
function echof(x){ return x }, //named function
|
||||
{
|
||||
name: 'echoExplicit', //describing object
|
||||
call: async (x) => x
|
||||
}
|
||||
]
|
||||
}])
|
||||
|
||||
const client = new RPCSocket(20003, 'localhost')
|
||||
|
||||
client.connect().then(async () => {
|
||||
const r0 = await client['HelloWorldRPCGroup'].echo('Hello')
|
||||
const r1 = await client['HelloWorldRPCGroup'].echof('World')
|
||||
const r2 = await client['HelloWorldRPCGroup'].echoExplicit('RPC!')
|
||||
|
||||
if(r0 === 'Hello' && r1 === 'World' && r2 ==='RPC!'){
|
||||
client.destroy()
|
||||
server.destroy()
|
||||
done()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('new RPCServer() should fail on bad RPC', (done) => {
|
||||
try{
|
||||
new RPCServer(20001, [{
|
||||
|
||||
Reference in New Issue
Block a user