From 7c05a483c412437fbb16d635a69d0d60b21bf475 Mon Sep 17 00:00:00 2001 From: Julien Barbay Date: Mon, 16 Sep 2024 22:34:23 +0700 Subject: [PATCH 1/2] remove publish definition (#784) --- packages/rabbitmq/src/amqp/connection.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/rabbitmq/src/amqp/connection.ts b/packages/rabbitmq/src/amqp/connection.ts index 149a6f5fc..3824eeaf3 100644 --- a/packages/rabbitmq/src/amqp/connection.ts +++ b/packages/rabbitmq/src/amqp/connection.ts @@ -624,10 +624,10 @@ export class AmqpConnection { return consumerTag; } - public publish( + public publish( exchange: string, routingKey: string, - message: T, + message: any, options?: Options.Publish ): Promise { let buffer: Buffer; From e9560d7f5f6da3ff215327127733e2d02e89002c Mon Sep 17 00:00:00 2001 From: VonRehberg Date: Mon, 16 Sep 2024 18:14:39 +0200 Subject: [PATCH 2/2] fix: fixed nullable mocks issue (#787) * fix(ts-jest): fixed nullable mocks issue closes #757 * fix: allow boolean return values in mocks closes #778 --------- Co-authored-by: Christian Jeschke Co-authored-by: Rodrigo --- packages/testing/ts-jest/src/mocks.spec.ts | 16 ++++++++++++++++ packages/testing/ts-jest/src/mocks.ts | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/testing/ts-jest/src/mocks.spec.ts b/packages/testing/ts-jest/src/mocks.spec.ts index a6678fcc7..f66db2073 100644 --- a/packages/testing/ts-jest/src/mocks.spec.ts +++ b/packages/testing/ts-jest/src/mocks.spec.ts @@ -183,6 +183,22 @@ describe('Mocks', () => { }); expect(mock.foo()).toEqual(undefined); }); + + it('should accept nullable values using mockReturnValueOnce and allow for chaining', async () => { + interface Test { + foo(): boolean; + } + const serviceMock = createMock(); + jest + .spyOn(serviceMock, 'foo') + .mockReturnValueOnce(true) + .mockReturnValueOnce(false) + .mockReturnValueOnce(true); + + expect(serviceMock.foo()).toEqual(true); + expect(serviceMock.foo()).toEqual(false); + expect(serviceMock.foo()).toEqual(true); + }); }); describe('auto mocked', () => { diff --git a/packages/testing/ts-jest/src/mocks.ts b/packages/testing/ts-jest/src/mocks.ts index 5a71757ed..6ef25deb2 100644 --- a/packages/testing/ts-jest/src/mocks.ts +++ b/packages/testing/ts-jest/src/mocks.ts @@ -101,7 +101,7 @@ const createProxy: { argsArray ) => { const result = Reflect.apply(target, thisArg, argsArray); - if (target.getMockImplementation() || result) { + if (target.getMockImplementation() || result !== undefined) { return result; } else { if (!cache.has('__apply')) {