@@ -2,6 +2,10 @@ import assert from 'assert';
2
2
import { format } from 'util' ;
3
3
import validator from '../src/index' ;
4
4
5
+ function stringifyArgs ( argsArr ) {
6
+ return argsArr . map ( arg => JSON . stringify ( arg ) ) . join ( ', ' ) ;
7
+ }
8
+
5
9
export default function test ( options ) {
6
10
const args = options . args || [ ] ;
7
11
@@ -16,7 +20,7 @@ export default function test(options) {
16
20
} catch ( err ) {
17
21
const warning = format (
18
22
'validator.%s(%s) passed but should error' ,
19
- options . validator , args . join ( ', ' )
23
+ options . validator , stringifyArgs ( args )
20
24
) ;
21
25
22
26
throw new Error ( warning ) ;
@@ -31,7 +35,7 @@ export default function test(options) {
31
35
if ( validator [ options . validator ] ( ...args ) !== true ) {
32
36
const warning = format (
33
37
'validator.%s(%s) failed but should have passed' ,
34
- options . validator , args . join ( ', ' )
38
+ options . validator , stringifyArgs ( args )
35
39
) ;
36
40
37
41
throw new Error ( warning ) ;
@@ -46,7 +50,7 @@ export default function test(options) {
46
50
if ( validator [ options . validator ] ( ...args ) !== false ) {
47
51
const warning = format (
48
52
'validator.%s(%s) passed but should have failed' ,
49
- options . validator , args . join ( ', ' )
53
+ options . validator , stringifyArgs ( args )
50
54
) ;
51
55
52
56
throw new Error ( warning ) ;
0 commit comments