Skip to content

Commit

Permalink
Merge pull request redis#1342 from Salakar/master
Browse files Browse the repository at this point in the history
[tests] fix broken utils tests
  • Loading branch information
Salakar authored May 22, 2018
2 parents 04a09aa + c159815 commit 7e945bb
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions test/utils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,22 @@ describe('utils.js', function () {
});

it('elements in the offline queue. Reply after the offline queue is empty and respect the command_obj callback', function (done) {
clientMock.offline_queue.push(create_command_obj(), create_command_obj());
clientMock.offline_queue.push(create_command_obj());
clientMock.offline_queue.push(create_command_obj());
utils.reply_in_order(clientMock, function () {
assert.strictEqual(clientMock.offline_queue.length, 0);
assert.strictEqual(res_count, 2);
done();
}, null, null);
while (clientMock.offline_queue.length) clientMock.offline_queue.shift().callback(null, 'foo');
while (clientMock.offline_queue.length) {
clientMock.offline_queue.shift().callback(null, 'foo');
}
});

it('elements in the offline queue. Reply after the offline queue is empty and respect the command_obj error emit', function (done) {
clientMock.command_queue.push({}, create_command_obj(), {});
clientMock.command_queue.push({});
clientMock.command_queue.push(create_command_obj());
clientMock.command_queue.push({});
utils.reply_in_order(clientMock, function () {
assert.strictEqual(clientMock.command_queue.length, 0);
assert(emitted);
Expand All @@ -158,8 +163,10 @@ describe('utils.js', function () {
});

it('elements in the offline queue and the command_queue. Reply all other commands got handled respect the command_obj', function (done) {
clientMock.command_queue.push(create_command_obj(), create_command_obj());
clientMock.offline_queue.push(create_command_obj(), {});
clientMock.command_queue.push(create_command_obj());
clientMock.command_queue.push(create_command_obj());
clientMock.command_queue.push(create_command_obj());
clientMock.offline_queue.push({});
utils.reply_in_order(clientMock, function (err, res) {
assert.strictEqual(clientMock.command_queue.length, 0);
assert.strictEqual(clientMock.offline_queue.length, 0);
Expand Down

0 comments on commit 7e945bb

Please sign in to comment.