@@ -4,7 +4,7 @@ import type { Config } from '../../types/config';
4
4
import { getPaginationKeywordsRegExp } from '../pagination' ;
5
5
6
6
describe ( 'paginationKeywordsRegExp' , ( ) => {
7
- const scenarios : Array < {
7
+ const defaultScenarios : Array < {
8
8
result : boolean ;
9
9
value : string ;
10
10
} > = [
@@ -42,7 +42,7 @@ describe('paginationKeywordsRegExp', () => {
42
42
} ,
43
43
] ;
44
44
45
- it . each ( scenarios ) (
45
+ it . each ( defaultScenarios ) (
46
46
'is $value pagination param? $output' ,
47
47
async ( { result, value } ) => {
48
48
const paginationRegExp = getPaginationKeywordsRegExp ( ) ;
@@ -51,27 +51,30 @@ describe('paginationKeywordsRegExp', () => {
51
51
} ,
52
52
) ;
53
53
54
- it ( 'uses custom keywords from config' , async ( ) => {
55
- const config : Config = {
56
- input : {
57
- pagination : {
58
- keywords : [ 'customPagination' , 'pageSize' , 'perPage' ] ,
59
- } ,
60
- } ,
61
- } as Config ;
62
-
63
- const paginationRegExp = getPaginationKeywordsRegExp ( config ) ;
54
+ const customScenarios : Array < {
55
+ result : boolean ;
56
+ value : string ;
57
+ } > = [
58
+ { result : true , value : 'customPagination' } ,
59
+ { result : true , value : 'pageSize' } ,
60
+ { result : true , value : 'perPage' } ,
61
+ { result : false , value : 'page' } ,
62
+ ] ;
64
63
65
- // Should match custom keywords
66
- paginationRegExp . lastIndex = 0 ;
67
- expect ( paginationRegExp . test ( 'customPagination' ) ) . toEqual ( true ) ;
68
- paginationRegExp . lastIndex = 0 ;
69
- expect ( paginationRegExp . test ( 'pageSize' ) ) . toEqual ( true ) ;
70
- paginationRegExp . lastIndex = 0 ;
71
- expect ( paginationRegExp . test ( 'perPage' ) ) . toEqual ( true ) ;
64
+ it . each ( customScenarios ) (
65
+ 'with custom config, $value should match? $result' ,
66
+ async ( { result, value } ) => {
67
+ const config : Config = {
68
+ input : {
69
+ pagination : {
70
+ keywords : [ 'customPagination' , 'pageSize' , 'perPage' ] ,
71
+ } ,
72
+ } ,
73
+ } as Config ;
72
74
73
- // Should not match default keywords
74
- paginationRegExp . lastIndex = 0 ;
75
- expect ( paginationRegExp . test ( 'page' ) ) . toEqual ( false ) ;
76
- } ) ;
75
+ const paginationRegExp = getPaginationKeywordsRegExp ( config ) ;
76
+ paginationRegExp . lastIndex = 0 ;
77
+ expect ( paginationRegExp . test ( value ) ) . toEqual ( result ) ;
78
+ } ,
79
+ ) ;
77
80
} ) ;
0 commit comments