rpc_ts
Version:
Remote Procedure Calls in TypeScript made simple
30 lines • 1.1 kB
JavaScript
/**
* @license
* Copyright (c) Aiden.ai
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
Object.defineProperty(exports, "__esModule", { value: true });
const mock_1 = require("../mock");
const client_1 = require("../../../client");
const chai_1 = require("chai");
describe('rpc_ts', () => {
describe('protocol mock', () => {
it('mocks a successful unary call', async () => {
const serviceDefinition = {
foo: { request: {}, response: {} },
};
const client = mock_1.getMockRpcClient(serviceDefinition, (method, request) => {
console.log('RPC:', method, request instanceof Function ? request() : request);
return client_1.ModuleRpcClient.streamFromArray([
{ response: { bar: 1 } },
]);
});
const { bar } = await client.methodMap().foo({});
chai_1.expect(bar).to.equal(1);
});
});
});
//# sourceMappingURL=mock.test.js.map
;