Skip to content

Commit e44ea96

Browse files
author
Ruben Bridgewater
committed
Add nested array with chunks test
1 parent 61a4a0d commit e44ea96

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/parsers.spec.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,30 @@ describe('parsers', function () {
424424
assert.strictEqual(replyCount, 1)
425425
})
426426

427+
it('multiple chunks with nested partial arrays', function () {
428+
var predefinedData = [
429+
'abcdefghijabcdefghij',
430+
100,
431+
'1234567890',
432+
100
433+
]
434+
function checkReply (reply) {
435+
assert.strictEqual(reply.length, 1)
436+
for (var i = 0; i < reply[0].length; i++) {
437+
assert.strictEqual(reply[0][i], predefinedData[i])
438+
}
439+
replyCount++
440+
}
441+
var parser = newParser({
442+
returnReply: checkReply
443+
})
444+
parser.execute(new Buffer('*1\r\n*4\r\n+abcdefghijabcdefghij\r\n:100'))
445+
parser.execute(new Buffer('\r\n$10\r\n1234567890\r\n:100'))
446+
assert.strictEqual(replyCount, 0)
447+
parser.execute(new Buffer('\r\n'))
448+
assert.strictEqual(replyCount, 1)
449+
})
450+
427451
it('return normal errors', function () {
428452
function checkReply (reply) {
429453
assert.strictEqual(reply.message, 'Error message')

0 commit comments

Comments
 (0)