File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ import Ajv from 'ajv' ;
2+ import betterAjvErrors from '../' ;
3+ import { getErrors } from '../utils.js' ;
4+
5+ describe ( 'utils' , ( ) => {
6+ it ( 'getErrors remaps ajv-errors custom messages' , async ( ) => {
7+ const node = {
8+ children : { } ,
9+ errors : [
10+ {
11+ keyword : 'errorMessage' ,
12+ dataPath : '/nested' ,
13+ schemaPath : '#/errorMessage' ,
14+ params : {
15+ errors : [
16+ {
17+ keyword : 'additionalProperties' ,
18+ dataPath : '/api/AbortController' ,
19+ schemaPath : '#/additionalProperties' ,
20+ params : { additionalProperty : 'AbortController$@*)$' } ,
21+ message : 'should NOT have additional properties' ,
22+ } ,
23+ ] ,
24+ } ,
25+ message : 'Hello world!' ,
26+ } ,
27+ ] ,
28+ } ;
29+
30+ const errors = getErrors ( node ) ;
31+ expect ( errors ) . toStrictEqual ( [
32+ {
33+ keyword : 'additionalProperties' ,
34+ dataPath : '/api/AbortController' ,
35+ schemaPath : '#/additionalProperties' ,
36+ params : { additionalProperty : 'AbortController$@*)$' } ,
37+ message : 'Hello world!' ,
38+ } ,
39+ ] ) ;
40+ } ) ;
41+ } ) ;
You can’t perform that action at this time.
0 commit comments