diff --git a/src/ChannelWrapper.ts b/src/ChannelWrapper.ts index ba28e35..241b41d 100644 --- a/src/ChannelWrapper.ts +++ b/src/ChannelWrapper.ts @@ -878,6 +878,14 @@ export default class ChannelWrapper extends EventEmitter { } } + /** Send a `unbindQueue` to the underlying channel. */ + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types + async unbindQueue(queue: string, source: string, pattern: string, args?: any): Promise { + if (this._channel) { + await this._channel.unbindQueue(queue, source, pattern, args); + } + } + /** Send a `deleteQueue` to the underlying channel. */ async deleteQueue( queue: string, diff --git a/test/ChannelWrapperTest.ts b/test/ChannelWrapperTest.ts index 67ac3a7..73cb4de 100644 --- a/test/ChannelWrapperTest.ts +++ b/test/ChannelWrapperTest.ts @@ -585,6 +585,32 @@ describe('ChannelWrapper', function () { channelWrapper.checkExchange('fish'); expect(channel.checkExchange).to.have.beenCalledTimes(1); expect(channel.checkExchange).to.have.beenCalledWith('fish'); + + }); + }); + + it('should proxy assertQueue, assertExchange, bindQueue and unbindQueue to the underlying channel', function () { + connectionManager.simulateConnect(); + const channelWrapper = new ChannelWrapper(connectionManager); + return channelWrapper.waitForConnect().then(function () { + // get the underlying channel + const channel = getUnderlyingChannel(channelWrapper); + + channelWrapper.assertQueue('dog'); + expect(channel.assertQueue).to.have.beenCalledTimes(1); + expect(channel.assertQueue).to.have.beenCalledWith('dog', undefined); + + channelWrapper.assertExchange('bone', 'topic'); + expect(channel.assertExchange).to.have.beenCalledTimes(1); + expect(channel.assertExchange).to.have.beenCalledWith('bone', 'topic', undefined); + + channelWrapper.bindQueue('dog', 'bone', 'legs'); + expect(channel.bindQueue).to.have.beenCalledTimes(1); + expect(channel.bindQueue).to.have.beenCalledWith('dog', 'bone', 'legs', undefined); + + channelWrapper.unbindQueue('dog', 'bone', 'legs'); + expect(channel.unbindQueue).to.have.beenCalledTimes(1); + expect(channel.unbindQueue).to.have.beenCalledWith('dog', 'bone', 'legs', undefined); }); }); diff --git a/test/fixtures.ts b/test/fixtures.ts index 9345119..e79512d 100644 --- a/test/fixtures.ts +++ b/test/fixtures.ts @@ -131,6 +131,17 @@ export class FakeChannel extends EventEmitter { return {}; }); + unbindQueue = jest + .fn() + .mockImplementation(async function ( + _queue: string, + _source: string, + _pattern: string, + _args?: any + ): Promise { + return {}; + }); + assertExchange = jest .fn() .mockImplementation(async function (