From a8c3675218e8c7fb2cc49403296135d8ba56fe72 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Mon, 23 Nov 2015 18:38:17 +0100 Subject: [PATCH] Add another parser test --- test/parser.spec.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/parser.spec.js b/test/parser.spec.js index 85f92f50de..b50d37322d 100644 --- a/test/parser.spec.js +++ b/test/parser.spec.js @@ -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); + }); }); }); });