@@ -106,6 +106,15 @@ describe('SubscriptionsService', () => {
106106 }
107107 } ) ,
108108 findAllForReconciler : jest . fn ( async ( ) => currentSubs ) ,
109+ findWithCursor : jest . fn ( async ( fan , status , sort , cursorId , limit ) => {
110+ let filtered = currentSubs . filter (
111+ ( sub ) => sub . fan === fan && ( status ? sub . status === status : true ) ,
112+ ) ;
113+ if ( cursorId ) {
114+ filtered = filtered . filter ( ( sub ) => sub . id > cursorId ) ;
115+ }
116+ return filtered . slice ( 0 , limit + 1 ) ;
117+ } ) ,
109118 } as unknown as jest . Mocked < SubscriptionIndexRepository > ;
110119
111120 const module : TestingModule = await Test . createTestingModule ( {
@@ -154,8 +163,38 @@ describe('SubscriptionsService', () => {
154163 ) ;
155164
156165 expect ( result . data ) . toHaveLength ( 1 ) ;
157- expect ( result . total ) . toBe ( 1 ) ;
158- expect ( repo . findAndCountForFan ) . toHaveBeenCalled ( ) ;
166+ expect ( repo . findWithCursor ) . toHaveBeenCalledWith (
167+ 'GFANADDRESS333333333333333333333333333333333333333333333333' ,
168+ undefined ,
169+ undefined ,
170+ undefined ,
171+ 20 ,
172+ ) ;
173+ } ) ;
174+
175+ it ( 'passes status and cursor to findWithCursor' , async ( ) => {
176+ await service . addSubscription (
177+ 'GFANADDRESS666666666666666666666666666666666666666666666666' ,
178+ 'GAAAAAAAAAAAAAAA' ,
179+ 1 ,
180+ Math . floor ( Date . now ( ) / 1000 ) + 60 ,
181+ ) ;
182+
183+ await service . listSubscriptions (
184+ 'GFANADDRESS666666666666666666666666666666666666666666666666' ,
185+ SubscriptionStatus . ACTIVE ,
186+ 'created' ,
187+ 'some-cursor' ,
188+ 10 ,
189+ ) ;
190+
191+ expect ( repo . findWithCursor ) . toHaveBeenCalledWith (
192+ 'GFANADDRESS666666666666666666666666666666666666666666666666' ,
193+ SubscriptionStatus . ACTIVE ,
194+ 'created' ,
195+ 'some-cursor' ,
196+ 10 ,
197+ ) ;
159198 } ) ;
160199
161200 it ( 'publishes a renewal event when confirming an existing subscription' , async ( ) => {
0 commit comments