@@ -10,21 +10,18 @@ describe('assertInput', () => {
1010 it . each ( [
1111 {
1212 description : 'basic string validation' ,
13- param : '' ,
14- condition : ( value : any ) => typeof value === 'string' && value . trim ( ) . length > 0
13+ condition : ' ' . trim ( ) . length > 0
1514 } ,
1615 {
17- description : 'pattern in string validation' ,
18- param : 'patternfly://lorem-ipsum' ,
19- condition : ( value : any ) => new RegExp ( 'patternfly://' , 'i' ) . test ( value )
16+ description : 'pattern in string validation with callback format' ,
17+ condition : ( ) => new RegExp ( 'patternfly://' , 'i' ) . test ( 'fly://lorem-ipsum' )
2018 } ,
2119 {
2220 description : 'array entry length validation' ,
23- param : [ 'lorem' , 'ipsum' ] ,
24- condition : ( value : any ) => Array . isArray ( value ) && value . length > 2
21+ condition : Array . isArray ( [ 'lorem' ] ) && [ 'lorem' ] . length > 2
2522 }
26- ] ) ( 'should throw an error for validation, $description' , ( { param , condition } ) => {
27- const errorMessage = `Lorem ipsum error message for ${ param } validation.` ;
23+ ] ) ( 'should throw an error for validation, $description' , ( { condition } ) => {
24+ const errorMessage = `Lorem ipsum error message for validation.` ;
2825
2926 expect ( ( ) => assertInput (
3027 condition ,
@@ -37,25 +34,25 @@ describe('assertInputString', () => {
3734 it . each ( [
3835 {
3936 description : 'empty string' ,
40- param : ''
37+ input : ''
4138 } ,
4239 {
4340 description : 'undefined' ,
44- param : undefined
41+ input : undefined
4542 } ,
4643 {
4744 description : 'number' ,
48- param : 1
45+ input : 1
4946 } ,
5047 {
5148 description : 'null' ,
52- param : null
49+ input : null
5350 }
54- ] ) ( 'should throw an error for validation, $description' , ( { param } ) => {
51+ ] ) ( 'should throw an error for validation, $description' , ( { input } ) => {
5552 const errorMessage = '"Input" must be a string' ;
5653
5754 expect ( ( ) => assertInputString (
58- param
55+ input
5956 ) ) . toThrow ( errorMessage ) ;
6057 } ) ;
6158} ) ;
@@ -64,50 +61,50 @@ describe('assertInputStringLength', () => {
6461 it . each ( [
6562 {
6663 description : 'empty string' ,
67- param : ''
64+ input : ''
6865 } ,
6966 {
7067 description : 'undefined' ,
71- param : undefined
68+ input : undefined
7269 } ,
7370 {
7471 description : 'number' ,
75- param : 1
72+ input : 1
7673 } ,
7774 {
7875 description : 'null' ,
79- param : null
76+ input : null
8077 } ,
8178 {
8279 description : 'max' ,
83- param : 'lorem ipsum' ,
80+ input : 'lorem ipsum' ,
8481 options : { max : 5 }
8582 } ,
8683 {
8784 description : 'min' ,
88- param : 'lorem ipsum' ,
85+ input : 'lorem ipsum' ,
8986 options : { min : 15 }
9087 } ,
9188 {
9289 description : 'max and min' ,
93- param : 'lorem ipsum' ,
90+ input : 'lorem ipsum' ,
9491 options : { min : 1 , max : 10 }
9592 } ,
9693 {
9794 description : 'max and min and display name' ,
98- param : 'lorem ipsum' ,
95+ input : 'lorem ipsum' ,
9996 options : { min : 1 , max : 10 , inputDisplayName : 'lorem ipsum' }
10097 } ,
10198 {
10299 description : 'max and min and description' ,
103- param : 'lorem ipsum' ,
100+ input : 'lorem ipsum' ,
104101 options : { min : 1 , max : 10 , message : 'dolor sit amet, consectetur adipiscing elit.' }
105102 }
106- ] ) ( 'should throw an error for validation, $description' , ( { param , options } ) => {
103+ ] ) ( 'should throw an error for validation, $description' , ( { input , options } ) => {
107104 const errorMessage = options ?. message || `"${ options ?. inputDisplayName || 'Input' } " must be a string` ;
108105
109106 expect ( ( ) => assertInputStringLength (
110- param ,
107+ input ,
111108 { min : 1 , max : 100 , ...options } as any
112109 ) ) . toThrow ( errorMessage ) ;
113110 } ) ;
@@ -117,50 +114,50 @@ describe('assertInputStringArrayEntryLength', () => {
117114 it . each ( [
118115 {
119116 description : 'empty string' ,
120- param : ''
117+ input : ''
121118 } ,
122119 {
123120 description : 'undefined' ,
124- param : undefined
121+ input : undefined
125122 } ,
126123 {
127124 description : 'number' ,
128- param : 1
125+ input : 1
129126 } ,
130127 {
131128 description : 'null' ,
132- param : null
129+ input : null
133130 } ,
134131 {
135132 description : 'max' ,
136- param : [ 'lorem ipsum' ] ,
133+ input : [ 'lorem ipsum' ] ,
137134 options : { max : 5 }
138135 } ,
139136 {
140137 description : 'min' ,
141- param : [ 'lorem ipsum' ] ,
138+ input : [ 'lorem ipsum' ] ,
142139 options : { min : 15 }
143140 } ,
144141 {
145142 description : 'max and min' ,
146- param : [ 'lorem ipsum' ] ,
143+ input : [ 'lorem ipsum' ] ,
147144 options : { min : 1 , max : 10 }
148145 } ,
149146 {
150147 description : 'max and min and display name' ,
151- param : [ 'lorem ipsum' ] ,
148+ input : [ 'lorem ipsum' ] ,
152149 options : { min : 1 , max : 10 , inputDisplayName : 'lorem ipsum' }
153150 } ,
154151 {
155152 description : 'max and min and description' ,
156- param : [ 'lorem ipsum' ] ,
153+ input : [ 'lorem ipsum' ] ,
157154 options : { min : 1 , max : 10 , message : 'dolor sit amet, consectetur adipiscing elit.' }
158155 }
159- ] ) ( 'should throw an error for validation, $description' , ( { param , options } ) => {
156+ ] ) ( 'should throw an error for validation, $description' , ( { input , options } ) => {
160157 const errorMessage = options ?. message || `"${ options ?. inputDisplayName || 'Input' } " array must contain strings` ;
161158
162159 expect ( ( ) => assertInputStringArrayEntryLength (
163- param as any ,
160+ input as any ,
164161 { min : 1 , max : 100 , ...options } as any
165162 ) ) . toThrow ( errorMessage ) ;
166163 } ) ;
@@ -170,46 +167,46 @@ describe('assertInputStringNumberEnumLike', () => {
170167 it . each ( [
171168 {
172169 description : 'empty string' ,
173- param : '' ,
170+ input : '' ,
174171 compare : [ 2 , 3 ]
175172 } ,
176173 {
177174 description : 'undefined' ,
178- param : undefined ,
175+ input : undefined ,
179176 compare : [ 2 , 3 ]
180177 } ,
181178 {
182179 description : 'null' ,
183- param : null ,
180+ input : null ,
184181 compare : [ 2 , 3 ]
185182 } ,
186183 {
187184 description : 'number' ,
188- param : 1 ,
185+ input : 1 ,
189186 compare : [ 2 , 3 ]
190187 } ,
191188 {
192189 description : 'string' ,
193- param : 'lorem ipsum' ,
190+ input : 'lorem ipsum' ,
194191 compare : [ 'amet' , 'dolor sit' ]
195192 } ,
196193 {
197194 description : 'string and display name' ,
198- param : 'lorem ipsum' ,
195+ input : 'lorem ipsum' ,
199196 compare : [ 'amet' , 'dolor sit' ] ,
200197 options : { inputDisplayName : 'lorem ipsum' }
201198 } ,
202199 {
203200 description : 'string and description' ,
204- param : 'lorem ipsum' ,
201+ input : 'lorem ipsum' ,
205202 compare : [ 1 , 2 ] ,
206203 options : { message : 'dolor sit amet, consectetur adipiscing elit.' }
207204 }
208- ] ) ( 'should throw an error for validation, $description' , ( { param , compare, options } ) => {
205+ ] ) ( 'should throw an error for validation, $description' , ( { input , compare, options } ) => {
209206 const errorMessage = options ?. message || `"${ options ?. inputDisplayName || 'Input' } " must be one of the following values` ;
210207
211208 expect ( ( ) => assertInputStringNumberEnumLike (
212- param as any ,
209+ input as any ,
213210 compare as any ,
214211 { ...options } as any
215212 ) ) . toThrow ( errorMessage ) ;
0 commit comments