@@ -50,20 +50,28 @@ describe('All of the compatible tests', () => {
50
50
test ( `${ engine [ 1 ] } ${ JSON . stringify ( testCase . rule ) } ${ JSON . stringify (
51
51
testCase . data
52
52
) } `, async ( ) => {
53
- let result = await engine [ 0 ] . run ( testCase . rule , testCase . data )
54
- if ( ( result || 0 ) . toNumber ) result = Number ( result )
55
- if ( Array . isArray ( result ) ) result = result . map ( i => ( i || 0 ) . toNumber ? Number ( i ) : i )
56
- expect ( correction ( result ) ) . toStrictEqual ( testCase . result )
53
+ try {
54
+ let result = await engine [ 0 ] . run ( testCase . rule , testCase . data )
55
+ if ( ( result || 0 ) . toNumber ) result = Number ( result )
56
+ if ( Array . isArray ( result ) ) result = result . map ( i => ( i || 0 ) . toNumber ? Number ( i ) : i )
57
+ expect ( correction ( result ) ) . toStrictEqual ( testCase . result )
58
+ } catch ( err ) {
59
+ expect ( testCase . error ) . toStrictEqual ( true )
60
+ }
57
61
} )
58
62
59
63
test ( `${ engine [ 1 ] } ${ JSON . stringify ( testCase . rule ) } ${ JSON . stringify (
60
64
testCase . data
61
65
) } (built)`, async ( ) => {
62
- const f = await engine [ 0 ] . build ( testCase . rule )
63
- let result = await f ( testCase . data )
64
- if ( ( result || 0 ) . toNumber ) result = Number ( result )
65
- if ( Array . isArray ( result ) ) result = result . map ( i => i . toNumber ? Number ( i ) : i )
66
- expect ( correction ( result ) ) . toStrictEqual ( testCase . result )
66
+ try {
67
+ const f = await engine [ 0 ] . build ( testCase . rule )
68
+ let result = await f ( testCase . data )
69
+ if ( ( result || 0 ) . toNumber ) result = Number ( result )
70
+ if ( Array . isArray ( result ) ) result = result . map ( i => i . toNumber ? Number ( i ) : i )
71
+ expect ( correction ( result ) ) . toStrictEqual ( testCase . result )
72
+ } catch ( err ) {
73
+ expect ( testCase . error ) . toStrictEqual ( true )
74
+ }
67
75
} )
68
76
}
69
77
}
0 commit comments