29 lines
815 B
TypeScript
29 lines
815 B
TypeScript
|
|
import {root} from 'proto'
|
|
import { connect, ServiceContext } from '../src/ServiceContext'
|
|
import { HelloService } from '../src/HelloService'
|
|
|
|
// Fix websocket for running in js
|
|
// import WebSocket from 'ws'
|
|
// global["WebSocket"] = WebSocket
|
|
|
|
test('log in and say hi', async () => {
|
|
let ctx = await connect("bts", "password");
|
|
expect(ctx instanceof ServiceContext).toBe(true)
|
|
const hello = new HelloService(<ServiceContext>ctx)
|
|
const reply = await hello.say_hello({ name: "name" })
|
|
});
|
|
|
|
|
|
test('api_errors_updated', () => {
|
|
const ResponseHeader = root.lookupType("bts.api.ResponseHeader")
|
|
const rh = ResponseHeader.encode({
|
|
request_id: 42,
|
|
code: 3
|
|
}).finish()
|
|
const round = ResponseHeader.decode(rh)
|
|
expect(round).toBeDefined()
|
|
});
|
|
|
|
|