Add verification and value stripping
This commit is contained in:
@ -4,6 +4,7 @@ import { AddValueRequest, AddValueResponse, Logging } from "./out/index";
|
||||
|
||||
import * as Client from "./out/index_client";
|
||||
import * as Server from "./out/index_server";
|
||||
import { VerificationError } from "./out/ts_base";
|
||||
|
||||
const client = new Client.ServiceProvider((msg) => {
|
||||
session.onMessage(msg);
|
||||
@ -41,7 +42,7 @@ class TestService extends Server.TestService<undefined> {
|
||||
}
|
||||
|
||||
async FunctionWithArrayAsParamAndReturn(vals1, vals2) {
|
||||
return [...vals1, ...vals2];
|
||||
return [...vals1, ...vals2];
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,23 +73,49 @@ async function run() {
|
||||
console.log("!!!!This should have failed!!!!");
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log("Found expected error!", err.message);
|
||||
if (err instanceof VerificationError)
|
||||
console.log(
|
||||
"Found expected error!",
|
||||
{
|
||||
type: err.type,
|
||||
field: err.field,
|
||||
value: err.value
|
||||
}
|
||||
);
|
||||
else {
|
||||
console.error(err);
|
||||
throw new Error("Unexpected Error");
|
||||
}
|
||||
});
|
||||
|
||||
console.log("Test with arrays:");
|
||||
console.log(await test
|
||||
//@ts-ignore
|
||||
.FunctionWithArrayAsParamAndReturn([1,2,3], [4,5,6]));
|
||||
console.log(
|
||||
await test
|
||||
//@ts-ignore
|
||||
.FunctionWithArrayAsParamAndReturn([1, 2, 3], [4, 5, 6])
|
||||
);
|
||||
|
||||
console.log("Let with Array fail!");
|
||||
await test
|
||||
//@ts-ignore
|
||||
.FunctionWithArrayAsParamAndReturn([1,2,3], [4,"asd",6])
|
||||
.FunctionWithArrayAsParamAndReturn([1, 2, 3], [4, "asd", 6])
|
||||
.then(() => {
|
||||
console.log("!!!!This should have failed!!!!");
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log("Found expected error!", err.message);
|
||||
if (err instanceof VerificationError)
|
||||
console.log(
|
||||
"Found expected error!",
|
||||
{
|
||||
type: err.type,
|
||||
field: err.field,
|
||||
value: err.value
|
||||
}
|
||||
);
|
||||
else {
|
||||
console.error(err);
|
||||
throw new Error("Unexpected Error");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user