diff --git a/packages/third-parties/socketio/src/class/SocketHandlersBuilder.spec.ts b/packages/third-parties/socketio/src/class/SocketHandlersBuilder.spec.ts index a166c826cc1..0e606964693 100644 --- a/packages/third-parties/socketio/src/class/SocketHandlersBuilder.spec.ts +++ b/packages/third-parties/socketio/src/class/SocketHandlersBuilder.spec.ts @@ -925,7 +925,7 @@ describe("SocketHandlersBuilder", () => { }); }); describe("deserialize()", () => { - it("should call ConverterService.deserialize", () => { + it("should call deserialize on args", () => { const provider: any = { store: { get: jest.fn() @@ -953,5 +953,34 @@ describe("SocketHandlersBuilder", () => { args: [["any"]] }); }); + + it("should map ack callback without deserialization", () => { + const provider: any = { + store: { + get: jest.fn() + } + }; + const parameters: any[] = [ + { + filter: SocketFilters.ARGS, + useMapper: true, + mapIndex: 0, + type: Function + } + ]; + const ack = () => {}; + const scope: any = { + args: [ack] + }; + + const builder = new SocketHandlersBuilder(provider, PlatformTest.injector); + + // @ts-ignore + builder.deserialize({parameters} as any, scope as any); + + expect(scope).toEqual({ + args: [ack] + }); + }); }); }); diff --git a/packages/third-parties/socketio/src/class/SocketHandlersBuilder.ts b/packages/third-parties/socketio/src/class/SocketHandlersBuilder.ts index 617ff36b666..3b70008f6c4 100644 --- a/packages/third-parties/socketio/src/class/SocketHandlersBuilder.ts +++ b/packages/third-parties/socketio/src/class/SocketHandlersBuilder.ts @@ -168,12 +168,14 @@ export class SocketHandlersBuilder { const {filter, useMapper, mapIndex, type, collectionType} = parameters![index]; let value = scope.args[mapIndex!]; - if (filter === SocketFilters.ARGS && useMapper) { - value = deserialize(value, { - type, - collectionType, - useAlias: true - }); + if (filter === SocketFilters.ARGS) { + if (useMapper && typeof value !== "function") { + value = deserialize(value, { + type, + collectionType, + useAlias: true + }); + } scope.args[mapIndex!] = value; } });