@@ -250,6 +250,67 @@ describe('PaginationUtils', () => {
250250 expect ( result . hasNextPage ) . toBe ( true ) ;
251251 } ) ;
252252
253+ it ( 'includes known newer actions before the first page for the default chain' , ( ) => {
254+ const input = createItems ( [
255+ // Given these sortedItems
256+ '18' ,
257+ '17' ,
258+ '16' ,
259+ '15' ,
260+ '14' ,
261+ // Gap
262+ '12' ,
263+ '11' ,
264+ '10' ,
265+ '9' ,
266+ ] ) ;
267+
268+ const pages = [
269+ // Given these pages
270+ [ '17' , '16' , '15' , '14' ] ,
271+ [ '12' , '11' , '10' , '9' ] ,
272+ ] ;
273+
274+ const expectedResult = createItems ( [
275+ // Expect these sortedItems
276+ '18' ,
277+ '17' ,
278+ '16' ,
279+ '15' ,
280+ '14' ,
281+ ] ) ;
282+ const result = getContinuousChain ( input , pages , getID , '' ) ;
283+ expect ( result . data ) . toStrictEqual ( expectedResult ) ;
284+ expect ( result . hasPreviousPage ) . toBe ( true ) ;
285+ expect ( result . hasNextPage ) . toBe ( true ) ;
286+ } ) ;
287+
288+ it ( 'when linked to an item newer than the newest page boundary, returns the newest chain instead of a single item' , ( ) => {
289+ const input = createItems ( [
290+ '18' ,
291+ '17' ,
292+ '16' ,
293+ '15' ,
294+ '14' ,
295+ // Gap
296+ '12' ,
297+ '11' ,
298+ '10' ,
299+ '9' ,
300+ ] ) ;
301+
302+ const pages = [
303+ [ '17' , '16' , '15' , '14' ] ,
304+ [ '12' , '11' , '10' , '9' ] ,
305+ ] ;
306+
307+ const expectedResult = createItems ( [ '18' , '17' , '16' , '15' , '14' ] ) ;
308+ const result = getContinuousChain ( input , pages , getID , '18' ) ;
309+ expect ( result . data ) . toStrictEqual ( expectedResult ) ;
310+ expect ( result . hasPreviousPage ) . toBe ( true ) ;
311+ expect ( result . hasNextPage ) . toBe ( true ) ;
312+ } ) ;
313+
253314 it ( 'given a page with an empty firstItemID include actions until the start' , ( ) => {
254315 const input = createItems ( [
255316 // Given these sortedItems
0 commit comments