@@ -12,19 +12,53 @@ describe('XPENDING', () => {
1212 } ) ;
1313 } ) ;
1414
15- testUtils . testWithClient ( 'client.xPending' , async client => {
16- await client . xGroupCreate ( 'key' , 'group' , '$' , {
17- MKSTREAM : true
18- } ) ;
15+ describe ( 'client.xPending' , ( ) => {
16+ testUtils . testWithClient ( 'simple' , async client => {
17+ await Promise . all ( [
18+ client . xGroupCreate ( 'key' , 'group' , '$' , {
19+ MKSTREAM : true
20+ } ) ,
21+ client . xGroupCreateConsumer ( 'key' , 'group' , 'consumer' )
22+ ] ) ;
23+
24+ assert . deepEqual (
25+ await client . xPending ( 'key' , 'group' ) ,
26+ {
27+ pending : 0 ,
28+ firstId : null ,
29+ lastId : null ,
30+ consumers : null
31+ }
32+ ) ;
33+ } , GLOBAL . SERVERS . OPEN ) ;
34+
35+ testUtils . testWithClient ( 'with consumers' , async client => {
36+ const [ , , id ] = await Promise . all ( [
37+ client . xGroupCreate ( 'key' , 'group' , '$' , {
38+ MKSTREAM : true
39+ } ) ,
40+ client . xGroupCreateConsumer ( 'key' , 'group' , 'consumer' ) ,
41+ client . xAdd ( 'key' , '*' , { field : 'value' } ) ,
42+ client . xReadGroup ( 'group' , 'consumer' , {
43+ key : 'key' ,
44+ id : '>'
45+ } )
46+ ] ) ;
47+
48+ assert . deepEqual (
49+ await client . xPending ( 'key' , 'group' ) ,
50+ {
51+ pending : 1 ,
52+ firstId : id ,
53+ lastId : id ,
54+ consumers : [ {
55+ name : 'consumer' ,
56+ deliveriesCounter : 1
57+ } ]
58+ }
59+ ) ;
60+ } , GLOBAL . SERVERS . OPEN ) ;
61+ } ) ;
62+
1963
20- assert . deepEqual (
21- await client . xPending ( 'key' , 'group' ) ,
22- {
23- pending : 0 ,
24- firstId : null ,
25- lastId : null ,
26- consumers : null
27- }
28- ) ;
29- } , GLOBAL . SERVERS . OPEN ) ;
3064} ) ;
0 commit comments