File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -340,20 +340,19 @@ describe('paginate', () => {
340340 expect ( result . data ) . toStrictEqual ( cats )
341341 } )
342342
343- it ( 'should limit to defaultLimit, if limit is differt FROM NO_PAGINATION ecc.... ' , async ( ) => {
343+ it ( 'should limit to query limit, even if maxLimit is set to NO_PAGINATION' , async ( ) => {
344344 const config : PaginateConfig < CatEntity > = {
345345 sortableColumns : [ 'id' ] ,
346346 maxLimit : PaginationLimit . NO_PAGINATION ,
347- defaultLimit : 1 ,
348347 }
349348 const query : PaginateQuery = {
350349 path : '' ,
351- limit : - 2 ,
350+ limit : 2 ,
352351 }
353352
354353 const result = await paginate < CatEntity > ( query , catRepo , config )
355354
356- expect ( result . data ) . toStrictEqual ( cats . slice ( 0 , 1 ) )
355+ expect ( result . meta . itemsPerPage ) . toBe ( 2 )
357356 } )
358357
359358 it ( 'should default to limit defaultLimit, if maxLimit is NO_PAGINATION' , async ( ) => {
Original file line number Diff line number Diff line change @@ -197,8 +197,10 @@ export async function paginate<T extends ObjectLiteral>(
197197 const limit =
198198 query . limit === PaginationLimit . COUNTER_ONLY
199199 ? PaginationLimit . COUNTER_ONLY
200- : isPaginated
201- ? query . limit === PaginationLimit . NO_PAGINATION || maxLimit === PaginationLimit . NO_PAGINATION
200+ : isPaginated === true
201+ ? maxLimit === PaginationLimit . NO_PAGINATION
202+ ? query . limit ?? defaultLimit
203+ : query . limit === PaginationLimit . NO_PAGINATION
202204 ? defaultLimit
203205 : Math . min ( query . limit ?? defaultLimit , maxLimit )
204206 : defaultLimit
You can’t perform that action at this time.
0 commit comments