@@ -2,6 +2,10 @@ import assert from 'assert';
22import { format } from 'util' ;
33import validator from '../src/index' ;
44
5+ function stringifyArgs ( argsArr ) {
6+ return argsArr . map ( arg => JSON . stringify ( arg ) ) . join ( ', ' ) ;
7+ }
8+
59export default function test ( options ) {
610 const args = options . args || [ ] ;
711
@@ -16,7 +20,7 @@ export default function test(options) {
1620 } catch ( err ) {
1721 const warning = format (
1822 'validator.%s(%s) passed but should error' ,
19- options . validator , args . join ( ', ' )
23+ options . validator , stringifyArgs ( args )
2024 ) ;
2125
2226 throw new Error ( warning ) ;
@@ -31,7 +35,7 @@ export default function test(options) {
3135 if ( validator [ options . validator ] ( ...args ) !== true ) {
3236 const warning = format (
3337 'validator.%s(%s) failed but should have passed' ,
34- options . validator , args . join ( ', ' )
38+ options . validator , stringifyArgs ( args )
3539 ) ;
3640
3741 throw new Error ( warning ) ;
@@ -46,7 +50,7 @@ export default function test(options) {
4650 if ( validator [ options . validator ] ( ...args ) !== false ) {
4751 const warning = format (
4852 'validator.%s(%s) passed but should have failed' ,
49- options . validator , args . join ( ', ' )
53+ options . validator , stringifyArgs ( args )
5054 ) ;
5155
5256 throw new Error ( warning ) ;
0 commit comments