All files / rpc-calls/src/dispatcher/__tests__ RxLogicalChannelBaseDispatcher.fixtures.ts

100% Statements 18/18
100% Branches 0/0
100% Functions 1/1
100% Lines 17/17

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 261x 1x 1x 1x 1x 1x 1x     1x 12x 12x 12x   12x 12x 12x 12x 12x         12x    
import {createRpcCallee, type SampleCtx} from '../../testing/Callee.fixtures';
import {RxLogicalChannelBaseDispatcher} from '../RxLogicalChannelBaseDispatcher';
import {MockServerWebSocketChannel} from './MockServerWebSocketChannel';
import {RxLogicalChannelBase} from '../../channel/RxLogicalChannelBase';
import {BufferedLogicalChannelBase} from '../../channel/BufferedLogicalChannelBase';
import {RpcCodec} from '@jsonjoy.com/rpc-codec';
import {createCodecs} from '@jsonjoy.com/rpc-codec/lib/build';
import type {Callee} from '../../callee/types';
 
export const createRxLogicalChannelBaseDispatcher = () => {
  const callee = createRpcCallee<SampleCtx>();
  const channel = new MockServerWebSocketChannel();
  const codecs = createCodecs();
  // const codec = new RpcCodec(codecs.msg.binary, codecs.val.cbor, codecs.val.cbor);
  const codec = new RpcCodec(codecs.msg.compact, codecs.val.json, codecs.val.json);
  const rxMessageChannel = new RxLogicalChannelBase(channel, codec);
  const rxMessageChannelBuffered = new BufferedLogicalChannelBase({channel: rxMessageChannel});
  const ctx: SampleCtx = {ip: '1.2.3.4'};
  const dispatcher = new RxLogicalChannelBaseDispatcher<SampleCtx>(
    rxMessageChannelBuffered,
    callee as Callee<SampleCtx>,
    ctx,
  );
  return {callee, channel, dispatcher, ctx};
};