Fix typescript unit tests... maybe?

This commit is contained in:
Eric Harding committed 2018-04-24 21:22:55 -04:00
1 parent 49d16a3e03
commit 783a71217f
7 files changed
+17 -25

No files matched your search

+2 -2
View File
@@ -4,8 +4,8 @@ import { connect, ServiceContext } from '../src/ServiceContext'
import { HelloService } from '../src/HelloService'
// Fix websocket for running in js
import WebSocket from 'ws'
global["WebSocket"] = WebSocket
// import WebSocket from 'ws'
// global["WebSocket"] = WebSocket
test('log in and say hi', async () => {
let ctx = await connect("bts", "password");
+2 -2
View File
@@ -9,6 +9,6 @@ call npm run protogen
call npm run build
call npm run fable
::cd %~dp0\..\ui\src
::call dotnet fable webpack
cd %~dp0\..\ui\src
call dotnet fable webpack
+1 -1
View File
@@ -1,5 +1,5 @@
module.exports = {
testEnvironment: 'node',
// testEnvironment: 'node',
transform: {
"^.+\\.tsx?$": "ts-jest"
},
+2 -2
View File
@@ -1,7 +1,7 @@
// Future generated code
import root from 'proto'
import { ServiceContext } from 'ServiceContext'
// import { assertValid } from 'bts_assert';
import { assertValid } from 'bts_assert';
const HelloRequestProto = root.lookupType("bts.api.test.HelloRequest")
const HelloResponseProto = root.lookupType("bts.api.test.HelloResponse")
@@ -24,7 +24,7 @@ export class HelloService {
async say_hello(request : HelloRequest) : Promise<HelloResponse> {
const r = HelloRequestProto.create(request)
// assertValid(HelloRequestProto, r)
assertValid(HelloRequestProto, r)
const buffer = HelloRequestProto.encode(r).finish()
// result = Uint8Array
const result = await this.context.call(this.service_id, 0, buffer)
+1 -15
View File
@@ -1,5 +1,5 @@
import {root} from 'proto'
// import { assertValid } from 'bts_assert'
import { assertValid } from 'bts_assert'
const debug=true
@@ -15,20 +15,6 @@ function default_ws_uri() {
return ws_uri;
}
function assert(condition:boolean, message?:string) : void {
if (!condition) {
message = message || "Assertion failed"
throw new Error(message);
}
}
function assertValid(mtype, message) : void {
const r = mtype.verify(message)
assert(r != null, r)
}
// Message types
const GatewayLogin = root.lookupType("bts.api.gateway.GatewayLogin")
const GatewayRequest = root.lookupType("bts.api.gateway.GatewayRequest")
+2 -1
View File
@@ -7,6 +7,7 @@ export function assert(condition:boolean, message?:string) {
}
export function assertValid(mtype, message) {
const r = mtype.verify(message)
assert(r != null, r)
console.log(r)
assert(r == null, r)
}
+7 -2
View File
@@ -1,7 +1,12 @@
{
"compilerOptions": {
"target": "ES6",
"module": "ES6",
"target": "ES5",
"module": "commonjs",
"lib": [
"es2015",
"dom",
"es2016"
],
"allowSyntheticDefaultImports": true,
"allowJs": false,
"alwaysStrict": true,