fix(core): implement basic functionality
This commit is contained in:
44
test/test.ts
44
test/test.ts
@ -1,10 +1,48 @@
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import * as typedrequest from '@apiglobal/typedrequest';
|
||||
import * as typedrequestInterfaces from '@apiglobal/typedrequest-interfaces';
|
||||
|
||||
import * as typedsocket from '../ts/index';
|
||||
import { request } from 'http';
|
||||
|
||||
let testTypedSocket: typedsocket.TypedSocket;
|
||||
interface IRequest_Client_Server extends typedrequestInterfaces.implementsTR<
|
||||
typedrequestInterfaces.ITypedRequest,
|
||||
IRequest_Client_Server
|
||||
> {
|
||||
method: 'sayhi';
|
||||
request: {
|
||||
greeting: string;
|
||||
};
|
||||
response: {
|
||||
answer: string
|
||||
}
|
||||
}
|
||||
|
||||
tap.test('first test', async () => {
|
||||
testTypedSocket = new typedsocket.TypedSocket();
|
||||
let testTypedSocketServer: typedsocket.TypedSocket;
|
||||
let testTypedSocketClient: typedsocket.TypedSocket;
|
||||
|
||||
const testTypedRouter = new typedrequest.TypedRouter();
|
||||
|
||||
tap.test('should add some handlers', async () => {
|
||||
testTypedRouter.addTypedHandler<IRequest_Client_Server>(new typedrequest.TypedHandler('sayhi', async requestData => {
|
||||
return {
|
||||
answer: `ok, got it : ${requestData.greeting}`
|
||||
}
|
||||
}));
|
||||
})
|
||||
|
||||
tap.test('first test', async (tools) => {
|
||||
testTypedSocketServer = await typedsocket.TypedSocket.createServer(testTypedRouter);
|
||||
testTypedSocketClient = await typedsocket.TypedSocket.createClient(testTypedRouter, 'http://localhost');
|
||||
});
|
||||
|
||||
tap.test('should run without problems for a little bit', async tools => {
|
||||
await tools.delayFor(5000);
|
||||
})
|
||||
|
||||
tap.test('should disconnect', async () => {
|
||||
await testTypedSocketClient.stop();
|
||||
await testTypedSocketServer.stop();
|
||||
})
|
||||
|
||||
tap.start();
|
||||
|
Reference in New Issue
Block a user