1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-09 00:22:08 +03:00

Add another parser test

This commit is contained in:
Ruben Bridgewater
2015-11-23 18:38:17 +01:00
parent 32a5e1d148
commit a8c3675218

View File

@@ -236,6 +236,26 @@ describe('parsers', function () {
parser.execute(new Buffer('\n'));
assert.strictEqual(reply_count, 2);
});
it('return data as buffer if requested', function () {
var parser = new Parser(true);
var reply_count = 0;
function check_reply(reply) {
if (Array.isArray(reply)) {
reply = reply[0];
}
assert(Buffer.isBuffer(reply));
assert.strictEqual(reply.inspect(), new Buffer('test').inspect());
reply_count++;
}
parser.send_reply = check_reply;
parser.execute(new Buffer('+test\r\n'));
assert.strictEqual(reply_count, 1);
parser.execute(new Buffer('$4\r\ntest\r\n'));
assert.strictEqual(reply_count, 2);
parser.execute(new Buffer('*1\r\n$4\r\ntest\r\n'));
assert.strictEqual(reply_count, 3);
});
});
});
});