File tree Expand file tree Collapse file tree 2 files changed +5
-6
lines changed Expand file tree Collapse file tree 2 files changed +5
-6
lines changed Original file line number Diff line number Diff line change 1
1
function pagination ( query , options ) {
2
2
const result = { }
3
-
4
3
result . limit = options . default . pagination . limit
5
4
6
5
if ( query . limit ) {
7
- result . limit = processQuery ( query . limit )
6
+ result . limit = processQuery ( query . limit ) || options . default . pagination . limit
8
7
}
9
8
10
9
if ( options . use_page ) {
11
10
result . page = options . default . pagination . page
12
11
if ( query . page ) {
13
- result . page = processQuery ( query . page )
12
+ result . page = processQuery ( query . page ) || options . default . pagination . page
14
13
}
15
14
} else {
16
15
result . skip = options . default . pagination . skip
17
16
if ( query . skip ) {
18
- result . skip = processQuery ( query . skip )
17
+ result . skip = processQuery ( query . skip ) || options . default . pagination . skip
19
18
}
20
19
}
21
20
Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ describe('queryFilter()', function () {
83
83
} )
84
84
} )
85
85
86
- context ( 'when use pagination with page and query page is not a number' , function ( ) {
86
+ context ( 'when use pagination with page and query page and limit is not a number' , function ( ) {
87
87
it ( 'should return pagination param with default limit' , function ( ) {
88
88
89
89
const expect_pagination = {
@@ -94,7 +94,7 @@ describe('queryFilter()', function () {
94
94
const options = JSON . parse ( JSON . stringify ( custom_options ) )
95
95
options . default . pagination = expect_pagination
96
96
97
- const query = '?limit=teen'
97
+ const query = '?page=current& limit=teen'
98
98
99
99
return request ( app )
100
100
. get ( query )
You can’t perform that action at this time.
0 commit comments