@@ -12,13 +12,24 @@ describe('reader', () => {
1212
1313 describe ( 'max attempts' , ( ) =>
1414 describe ( 'exceeded' , ( ) => {
15+ it ( 'should process msg while attempts do not exceed max' , done => {
16+ const maxAttempts = 1
17+ const reader = readerWithAttempts ( maxAttempts )
18+
19+ reader . on ( nsq . Reader . DISCARD , ( ) => {
20+ done ( new Error ( 'should not be discarded' ) )
21+ } )
22+ reader . on ( nsq . Reader . MESSAGE , ( ) => done ( ) )
23+ reader . handleMessage ( { attempts : 1 , finish : ( ) => { } } )
24+ } )
25+
1526 it ( 'should finish after exceeding specified max attempts' , done => {
1627 const maxAttempts = 2
1728 const reader = readerWithAttempts ( maxAttempts )
1829
1930 // Message that has exceed the maximum number of attempts
2031 const message = {
21- attempts : maxAttempts ,
32+ attempts : maxAttempts + 1 ,
2233 finish : sinon . spy ( )
2334 }
2435
@@ -35,7 +46,7 @@ describe('reader', () => {
3546 const reader = readerWithAttempts ( maxAttempts )
3647
3748 const message = {
38- attempts : maxAttempts ,
49+ attempts : maxAttempts + 1 ,
3950 finish ( ) { }
4051 }
4152
@@ -48,7 +59,7 @@ describe('reader', () => {
4859 const reader = readerWithAttempts ( maxAttempts )
4960
5061 const message = {
51- attempts : maxAttempts ,
62+ attempts : maxAttempts + 1 ,
5263 finish ( ) { }
5364 }
5465
0 commit comments