Skip to content

Commit

Permalink
Merge branch 'master' into feature/702-build-and-release-ts-vitest
Browse files Browse the repository at this point in the history
  • Loading branch information
barraponto authored Sep 17, 2024
2 parents 5baf85e + e9560d7 commit 7ead77c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/rabbitmq/src/amqp/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -624,10 +624,10 @@ export class AmqpConnection {
return consumerTag;
}

public publish<T = any>(
public publish(
exchange: string,
routingKey: string,
message: T,
message: any,
options?: Options.Publish
): Promise<boolean> {
let buffer: Buffer;
Expand Down
16 changes: 16 additions & 0 deletions packages/testing/ts-jest/src/mocks.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Test>();
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', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/testing/ts-jest/src/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand Down

0 comments on commit 7ead77c

Please sign in to comment.