Skip to content

Commit

Permalink
feat: Add ChannelWrapper.ackAll() and ChannelWrapper.nackAll().
Browse files Browse the repository at this point in the history
fix #60
  • Loading branch information
Jason Walton committed Nov 20, 2018
1 parent 440c387 commit 0246695
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/ChannelWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,18 @@ export default class ChannelWrapper extends EventEmitter {
return this._channel && this._channel.ack.apply(this._channel, arguments);
}

// Send an `ackAll` to the underlying channel.
ackAll() {
return this._channel && this._channel.ackAll.apply(this._channel, arguments);
}

// Send a `nack` to the underlying channel.
nack() {
return this._channel && this._channel.nack.apply(this._channel, arguments);
}

// Send a `nackAll` to the underlying channel.
nackAll() {
return this._channel && this._channel.nackAll.apply(this._channel, arguments);
}
}
10 changes: 9 additions & 1 deletion test/ChannelWrapperTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,17 @@ describe('ChannelWrapper', function() {
expect(channel.ack.calledTwice).to.be.true;
expect(channel.ack.lastCall.args).to.eql(['b']);

channelWrapper.ackAll();
expect(channel.ackAll.calledOnce).to.be.true;

channelWrapper.nack('c', false, true);
expect(channel.nack.calledOnce).to.be.true;
return expect(channel.nack.lastCall.args).to.eql(['c', false, true]);
expect(channel.nack.lastCall.args).to.eql(['c', false, true]);

channelWrapper.nackAll(true);
expect(channel.nackAll.calledOnce).to.be.true;
expect(channel.nackAll.lastCall.args).to.eql([true]);

});
});

Expand Down
4 changes: 4 additions & 0 deletions test/fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,12 @@ export class FakeConfirmChannel extends EventEmitter {

this.ack = sinon.spy(function(message, allUpTo) {}); // eslint-disable-line

this.ackAll = sinon.spy(function() {}); // eslint-disable-line

this.nack = sinon.spy(function(message, allUpTo, requeue) {}); ; // eslint-disable-line

this.nackAll = sinon.spy(function(requeue) {}); // eslint-disable-line

this.close = sinon.spy(() => this.emit('close'));
}
}
Expand Down

0 comments on commit 0246695

Please sign in to comment.