Skip to content

Commit a8c3675

Browse files
author
Ruben Bridgewater
committed
Add another parser test
1 parent 32a5e1d commit a8c3675

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/parser.spec.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,26 @@ describe('parsers', function () {
236236
parser.execute(new Buffer('\n'));
237237
assert.strictEqual(reply_count, 2);
238238
});
239+
240+
it('return data as buffer if requested', function () {
241+
var parser = new Parser(true);
242+
var reply_count = 0;
243+
function check_reply(reply) {
244+
if (Array.isArray(reply)) {
245+
reply = reply[0];
246+
}
247+
assert(Buffer.isBuffer(reply));
248+
assert.strictEqual(reply.inspect(), new Buffer('test').inspect());
249+
reply_count++;
250+
}
251+
parser.send_reply = check_reply;
252+
parser.execute(new Buffer('+test\r\n'));
253+
assert.strictEqual(reply_count, 1);
254+
parser.execute(new Buffer('$4\r\ntest\r\n'));
255+
assert.strictEqual(reply_count, 2);
256+
parser.execute(new Buffer('*1\r\n$4\r\ntest\r\n'));
257+
assert.strictEqual(reply_count, 3);
258+
});
239259
});
240260
});
241261
});

0 commit comments

Comments
 (0)