@@ -95,6 +95,11 @@ describe('parsers', function () {
95
95
}
96
96
97
97
describe ( Parser . name , function ( ) {
98
+ var replyCount = 0
99
+ beforeEach ( function ( ) {
100
+ replyCount = 0
101
+ } )
102
+
98
103
it ( 'should not set the bufferOffset to a negative value' , function ( done ) {
99
104
if ( Parser . name === 'HiredisReplyParser' ) {
100
105
return this . skip ( )
@@ -111,7 +116,6 @@ describe('parsers', function () {
111
116
} )
112
117
113
118
it ( 'multiple parsers do not interfere' , function ( ) {
114
- var replyCount = 0
115
119
var results = [ 1234567890 , 'foo bar baz' , 'hello world' ]
116
120
function checkReply ( reply ) {
117
121
assert . strictEqual ( results [ replyCount ] , reply )
@@ -132,7 +136,6 @@ describe('parsers', function () {
132
136
} )
133
137
134
138
it ( 'multiple parsers do not interfere with bulk strings in arrays' , function ( ) {
135
- var replyCount = 0
136
139
var results = [ [ 'foo' , 'foo bar baz' ] , [ 1234567890 , 'hello world' , 'the end' ] , 'ttttttttttttttttttttttttttttttttttttttttttttttt' ]
137
140
function checkReply ( reply ) {
138
141
assert . deepEqual ( results [ replyCount ] , reply )
@@ -156,7 +159,6 @@ describe('parsers', function () {
156
159
} )
157
160
158
161
it ( 'returned buffers do not get mutated' , function ( ) {
159
- var replyCount = 0
160
162
var results = [ new Buffer ( 'aaaaaaaaaa' ) , new Buffer ( 'zzzzzzzzzz' ) ]
161
163
function checkReply ( reply ) {
162
164
assert . deepEqual ( results [ replyCount ] , reply )
@@ -183,7 +185,6 @@ describe('parsers', function () {
183
185
'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ' +
184
186
'ut aliquip ex ea commodo consequat. Duis aute irure dolor in' // 256 chars
185
187
var bigString = ( new Array ( Math . pow ( 2 , 17 ) / lorem . length + 1 ) . join ( lorem ) ) // Math.pow(2, 17) chars long
186
- var replyCount = 0
187
188
var sizes = [ 4 , Math . pow ( 2 , 17 ) ]
188
189
function checkReply ( reply ) {
189
190
assert . strictEqual ( sizes [ replyCount ] , reply . length )
@@ -201,7 +202,6 @@ describe('parsers', function () {
201
202
} )
202
203
203
204
it ( 'handles multi-bulk reply and check context binding' , function ( ) {
204
- var replyCount = 0
205
205
function Abc ( ) { }
206
206
Abc . prototype . checkReply = function ( reply ) {
207
207
assert . strictEqual ( typeof this . log , 'function' )
@@ -226,11 +226,10 @@ describe('parsers', function () {
226
226
parser . execute ( new Buffer ( '*1\r\n*1\r\n' ) )
227
227
parser . execute ( new Buffer ( '$1\r\na\r\n' ) )
228
228
229
- assert . equal ( replyCount , 3 , 'check reply should have been called three times' )
229
+ assert . strictEqual ( replyCount , 3 , 'check reply should have been called three times' )
230
230
} )
231
231
232
232
it ( 'parser error' , function ( ) {
233
- var replyCount = 0
234
233
function Abc ( ) { }
235
234
Abc . prototype . checkReply = function ( err ) {
236
235
assert . strictEqual ( typeof this . log , 'function' )
@@ -249,11 +248,10 @@ describe('parsers', function () {
249
248
} )
250
249
251
250
parser . execute ( new Buffer ( 'a*1\r*1\r$1`zasd\r\na' ) )
252
- assert . equal ( replyCount , 1 )
251
+ assert . strictEqual ( replyCount , 1 )
253
252
} )
254
253
255
254
it ( 'parser error resets the buffer' , function ( ) {
256
- var replyCount = 0
257
255
var errCount = 0
258
256
function checkReply ( reply ) {
259
257
assert . strictEqual ( reply . length , 1 )
@@ -283,7 +281,6 @@ describe('parsers', function () {
283
281
} )
284
282
285
283
it ( 'parser error v3 without returnFatalError specified' , function ( ) {
286
- var replyCount = 0
287
284
var errCount = 0
288
285
function checkReply ( reply ) {
289
286
assert . strictEqual ( reply [ 0 ] , 'OK' )
@@ -305,7 +302,6 @@ describe('parsers', function () {
305
302
306
303
it ( 'should handle \\r and \\n characters properly' , function ( ) {
307
304
// If a string contains \r or \n characters it will always be send as a bulk string
308
- var replyCount = 0
309
305
var entries = [ 'foo\r' , 'foo\r\nbar' , '\r\nСанкт-Пет' , 'foo\r\n' , 'foo' , 'foobar' , 'foo\r' , 'äfooöü' , 'abc' ]
310
306
function checkReply ( reply ) {
311
307
assert . strictEqual ( reply , entries [ replyCount ] )
@@ -334,25 +330,23 @@ describe('parsers', function () {
334
330
} )
335
331
336
332
it ( 'line breaks in the beginning of the last chunk' , function ( ) {
337
- var replyCount = 0
338
333
function checkReply ( reply ) {
339
334
assert . deepEqual ( reply , [ [ 'a' ] ] , 'Expecting multi-bulk reply of [["a"]]' )
340
335
replyCount ++
341
336
}
342
337
var parser = newParser ( checkReply )
343
338
344
339
parser . execute ( new Buffer ( '*1\r\n*1\r\n$1\r\na' ) )
345
- assert . equal ( replyCount , 0 )
340
+ assert . strictEqual ( replyCount , 0 )
346
341
347
342
parser . execute ( new Buffer ( '\r\n*1\r\n*1\r' ) )
348
- assert . equal ( replyCount , 1 )
343
+ assert . strictEqual ( replyCount , 1 )
349
344
parser . execute ( new Buffer ( '\n$1\r\na\r\n*1\r\n*1\r\n$1\r\na\r\n' ) )
350
345
351
- assert . equal ( replyCount , 3 , 'check reply should have been called three times' )
346
+ assert . strictEqual ( replyCount , 3 , 'check reply should have been called three times' )
352
347
} )
353
348
354
349
it ( 'multiple chunks in a bulk string' , function ( ) {
355
- var replyCount = 0
356
350
function checkReply ( reply ) {
357
351
assert . strictEqual ( reply , 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij' )
358
352
replyCount ++
@@ -382,11 +376,10 @@ describe('parsers', function () {
382
376
assert . strictEqual ( replyCount , 3 )
383
377
parser . execute ( new Buffer ( '\n' ) )
384
378
385
- assert . equal ( replyCount , 4 , 'check reply should have been called three times' )
379
+ assert . strictEqual ( replyCount , 4 , 'check reply should have been called three times' )
386
380
} )
387
381
388
382
it ( 'multiple chunks with arrays different types' , function ( ) {
389
- var replyCount = 0
390
383
var predefinedData = [
391
384
'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij' ,
392
385
'test' ,
@@ -432,9 +425,8 @@ describe('parsers', function () {
432
425
} )
433
426
434
427
it ( 'return normal errors' , function ( ) {
435
- var replyCount = 0
436
428
function checkReply ( reply ) {
437
- assert . equal ( reply . message , 'Error message' )
429
+ assert . strictEqual ( reply . message , 'Error message' )
438
430
replyCount ++
439
431
}
440
432
var parser = newParser ( {
@@ -449,9 +441,8 @@ describe('parsers', function () {
449
441
} )
450
442
451
443
it ( 'return null for empty arrays and empty bulk strings' , function ( ) {
452
- var replyCount = 0
453
444
function checkReply ( reply ) {
454
- assert . equal ( reply , null )
445
+ assert . strictEqual ( reply , null )
455
446
replyCount ++
456
447
}
457
448
var parser = newParser ( checkReply )
@@ -465,9 +456,8 @@ describe('parsers', function () {
465
456
} )
466
457
467
458
it ( 'return value even if all chunks are only 1 character long' , function ( ) {
468
- var replyCount = 0
469
459
function checkReply ( reply ) {
470
- assert . equal ( reply , 1 )
460
+ assert . strictEqual ( reply , 1 )
471
461
replyCount ++
472
462
}
473
463
var parser = newParser ( checkReply )
@@ -483,9 +473,8 @@ describe('parsers', function () {
483
473
} )
484
474
485
475
it ( 'do not return before \\r\\n' , function ( ) {
486
- var replyCount = 0
487
476
function checkReply ( reply ) {
488
- assert . equal ( reply , 1 )
477
+ assert . strictEqual ( reply , 1 )
489
478
replyCount ++
490
479
}
491
480
var parser = newParser ( checkReply )
@@ -501,7 +490,6 @@ describe('parsers', function () {
501
490
} )
502
491
503
492
it ( 'return data as buffer if requested' , function ( ) {
504
- var replyCount = 0
505
493
function checkReply ( reply ) {
506
494
if ( Array . isArray ( reply ) ) {
507
495
reply = reply [ 0 ]
@@ -521,7 +509,6 @@ describe('parsers', function () {
521
509
} )
522
510
523
511
it ( 'handle special case buffer sizes properly' , function ( ) {
524
- var replyCount = 0
525
512
var entries = [ 'test test ' , 'test test test test ' , 1234 ]
526
513
function checkReply ( reply ) {
527
514
assert . strictEqual ( reply , entries [ replyCount ] )
@@ -540,7 +527,6 @@ describe('parsers', function () {
540
527
if ( Parser . name === 'HiredisReplyParser' ) {
541
528
return this . skip ( )
542
529
}
543
- var replyCount = 0
544
530
var entries = [ '123' , '590295810358705700002' , '-99999999999999999' , '4294967290' , '90071992547409920' , '10000040000000000000000000000000000000020' ]
545
531
function checkReply ( reply ) {
546
532
assert . strictEqual ( typeof reply , 'string' )
@@ -556,7 +542,6 @@ describe('parsers', function () {
556
542
} )
557
543
558
544
it ( 'handle big numbers' , function ( ) {
559
- var replyCount = 0
560
545
var number = 9007199254740991 // Number.MAX_SAFE_INTEGER
561
546
function checkReply ( reply ) {
562
547
assert . strictEqual ( reply , number ++ )
@@ -571,7 +556,6 @@ describe('parsers', function () {
571
556
572
557
it ( 'handle big data with buffers' , function ( done ) {
573
558
var chunks
574
- var replyCount = 0
575
559
var replies = [ ]
576
560
var jsParser = Parser . name === 'JavascriptRedisParser'
577
561
function checkReply ( reply ) {
@@ -603,7 +587,6 @@ describe('parsers', function () {
603
587
} )
604
588
605
589
it ( 'handle big data' , function ( ) {
606
- var replyCount = 0
607
590
function checkReply ( reply ) {
608
591
assert . strictEqual ( reply . length , 4 * 1024 * 1024 )
609
592
replyCount ++
@@ -617,7 +600,6 @@ describe('parsers', function () {
617
600
618
601
it ( 'handle big data 2 with buffers' , function ( done ) {
619
602
this . timeout ( 7500 )
620
- var replyCount = 0
621
603
var size = 120 * 1024 * 1024
622
604
var replyLen = [ size , size * 2 , 11 , 11 ]
623
605
function checkReply ( reply ) {
0 commit comments