@@ -6,6 +6,7 @@ import FormRenderer from '../../form-renderer';
6
6
import { widgets , uiWidgets } from '../../demo-schemas/mozilla-schemas' ;
7
7
import { components , layoutComponents } from '../../constants' ;
8
8
import FormControls from '../../form-renderer/form-controls' ;
9
+ import SchemaErrorComponent from '../../form-renderer/schema-error-component' ;
9
10
10
11
describe ( '<FormRenderer />' , ( ) => {
11
12
let layoutMapper ;
@@ -50,6 +51,32 @@ describe('<FormRenderer />', () => {
50
51
expect ( toJson ( wrapper ) ) . toMatchSnapshot ( ) ;
51
52
} ) ;
52
53
54
+ it ( 'should render errorComponent form from schema' , ( ) => {
55
+ const _console = console ;
56
+
57
+ const spy = jest . fn ( ) ;
58
+ const logSpy = jest . fn ( ) ;
59
+ // eslint-disable-next-line no-console
60
+ console . error = spy ;
61
+ // eslint-disable-next-line no-console
62
+ console . log = logSpy ;
63
+
64
+ const schemaWithError = {
65
+ fields : [ {
66
+ name : 'field without component key' ,
67
+ } ] ,
68
+ } ;
69
+
70
+ const wrapper = mount ( < FormRenderer { ...initialProps } schema = { schemaWithError } schemaType = { undefined } /> ) ;
71
+
72
+ expect ( wrapper . find ( SchemaErrorComponent ) ) ;
73
+ expect ( spy ) . toHaveBeenCalled ( ) ;
74
+ expect ( logSpy ) . toHaveBeenCalledWith ( 'error: ' , expect . any ( String ) ) ;
75
+
76
+ // eslint-disable-next-line no-global-assign
77
+ console = _console ;
78
+ } ) ;
79
+
53
80
it ( 'should call form reset callback' , ( ) => {
54
81
const wrapper = mount ( < FormRenderer { ...initialProps } canReset /> ) ;
55
82
const form = wrapper . find ( Form ) ;
0 commit comments