tempalte strings & bugfixes

This commit is contained in:
2020-01-20 04:21:18 +01:00
parent 98b271758b
commit d36f2053c3
3 changed files with 65 additions and 65 deletions
+25 -15
View File
@@ -48,13 +48,12 @@ function makeServer(){
describe('RPCServer', () => {
let server: RPCServer<{ topic: string }, any>
before((done) => {
before(() => {
server = makeServer()
done()
})
after(async() => {
await server.destroy()
after(() => {
server.destroy()
})
it('should be able to use all kinds of RPC definitions', (done) => {
@@ -239,7 +238,7 @@ describe('Sesame should unlock the socket', () => {
let server: RPCServer
let cb = (...args) => {}
before(async() => {
before((done) => {
server = new RPCServer(21004, [{
name: "test",
exportRPCs: () => [
@@ -261,7 +260,10 @@ describe('Sesame should unlock the socket', () => {
sesame: (_sesame) => _sesame === 'sesame!'
})
const sock = new RPCSocket(21004, "localhost")
client = await sock.connect<SesameTestIfc>('sesame!')
sock.connect<SesameTestIfc>('sesame!').then(cli => {
client = cli
done()
})
})
after(() => {
@@ -282,13 +284,14 @@ describe('Sesame should unlock the socket', () => {
it('should not work without sesame', (done) => {
const sock = new RPCSocket(21004, "localhost")
sock.connect<SesameTestIfc>( /* no sesame */).then(async (c) => {
c.test.checkCandy().then(d => {
done()
sock.connect<SesameTestIfc>( /* no sesame */).then(async (cli) => {
cli.test.checkCandy().then(d => {
done(d)
}).catch(e => {
//console.log("EXPECTED CLIENT EXCEPTION", String(e));
done()
}).finally(() => {
cli.destroy()
sock.destroy()
})
})
@@ -296,14 +299,15 @@ describe('Sesame should unlock the socket', () => {
it('should fail with wrong sesame', (done) => {
const sock = new RPCSocket(21004, "localhost")
sock.connect<SesameTestIfc>('abasd').then(async (c) => {
c.test.checkCandy().then(d => {
sock.connect<SesameTestIfc>('abasd').then(async (cli) => {
cli.test.checkCandy().then(d => {
done("should not be able to get candy")
}).catch(e => {
//console.log("EXPECTED CLIENT EXCEPTION", String(e));
done()
}).finally(() => {
sock.destroy()
cli.destroy()
})
})
})
@@ -323,8 +327,8 @@ describe('Sesame should unlock the socket', () => {
it('callback should not work without sesame', (done) => {
const sock = new RPCSocket(21004, "localhost")
sock.connect<SesameTestIfc>( /* no sesame */).then(async (c) => {
c.test.subscribe((c) => {
sock.connect<SesameTestIfc>( /* no sesame */).then(async (cli) => {
cli.test.subscribe((c) => {
console.log("CALLBACK TRIGGERED UNEXPECTED");
if(c === candy)
@@ -333,16 +337,17 @@ describe('Sesame should unlock the socket', () => {
await client.test.checkCandy()
if(d == null){
done()
}else
done('unexpected valid response '+(d) )
c.destroy()
}).finally(() => {
sock.destroy()
})
})
})
})
describe('Error handling', ()=>{
let createUser = async( user: {a:any,b:any}) => {
@@ -374,6 +379,7 @@ describe('Error handling', ()=>{
done()
})
.finally(() => {
cli.destroy()
sock.destroy()
server.destroy()
})
@@ -407,6 +413,7 @@ describe('Error handling', ()=>{
done(e)
})
.finally(() => {
cli.destroy()
sock.destroy()
server.destroy()
})
@@ -414,6 +421,7 @@ describe('Error handling', ()=>{
})
})
describe("Errorhandler functionality", ()=>{
let createUser = async( user: {a:any,b:any}) => {
throw new Error("BAD BAD BAD")
@@ -447,6 +455,7 @@ describe("Errorhandler functionality", ()=>{
done(e)
})
.finally(() => {
cli.destroy()
sock.destroy()
server.destroy()
})
@@ -484,6 +493,7 @@ describe("Errorhandler functionality", ()=>{
done(e)
})
.finally(() => {
cli.destroy()
sock.destroy()
server.destroy()
})