Skip to content

Commit

Permalink
fix(rpc): tests with controller path resolution based on reflection
Browse files Browse the repository at this point in the history
  • Loading branch information
marcj committed Dec 5, 2023
1 parent acb2d72 commit 6909fa8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/rpc/src/decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
} from '@deepkit/type';
import { ControllerDefinition } from './model.js';

class RpcController {
export class RpcController {
// Defaults to the name of the class
name: string = '';

Expand Down
10 changes: 6 additions & 4 deletions packages/rpc/tests/controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assertType, entity, Positive, ReflectionClass, ReflectionKind } from '@deepkit/type';
import { expect, test } from '@jest/globals';
import { DirectClient } from '../src/client/client-direct.js';
import { getActions, rpc, rpcClass } from '../src/decorators.js';
import { getActions, rpc, rpcClass, RpcController } from '../src/decorators.js';
import { RpcKernel, RpcKernelConnection } from '../src/server/kernel.js';
import { Session, SessionState } from '../src/server/security.js';
import { BehaviorSubject } from 'rxjs';
Expand All @@ -12,9 +12,11 @@ test('default name', () => {
@rpc.controller()
class Controller {}

expect(rpcClass._fetch(Controller)).toMatchObject({
name: 'Controller',
});
const controller = new RpcController();

controller.classType = Controller;

expect(controller.getPath()).toBe('Controller');
});

test('decorator', async () => {
Expand Down

0 comments on commit 6909fa8

Please sign in to comment.