@@ -45,7 +45,7 @@ describe('ErrorMessage', () => {
45
45
expect ( asFragment ( ) ) . toMatchSnapshot ( ) ;
46
46
} ) ;
47
47
48
- it ( 'should render correctly with flat errors and as with component and render' , ( ) => {
48
+ it ( 'should render correctly with flat errors and as with element and render' , ( ) => {
49
49
const { asFragment } = render (
50
50
< ErrorMessage
51
51
as = { < span /> }
@@ -58,7 +58,7 @@ describe('ErrorMessage', () => {
58
58
expect ( asFragment ( ) ) . toMatchSnapshot ( ) ;
59
59
} ) ;
60
60
61
- it ( 'should render correctly with flat errors and as with component and className and render' , ( ) => {
61
+ it ( 'should render correctly with flat errors and as with element and className and render' , ( ) => {
62
62
const { asFragment } = render (
63
63
< ErrorMessage
64
64
as = { < span /> }
@@ -72,6 +72,37 @@ describe('ErrorMessage', () => {
72
72
expect ( asFragment ( ) ) . toMatchSnapshot ( ) ;
73
73
} ) ;
74
74
75
+ it ( 'should render correctly with flat errors and as with component' , ( ) => {
76
+ function CustErrComp ( { children } : { children : React . ReactNode } ) {
77
+ return < div > { children } </ div > ;
78
+ }
79
+ const { asFragment } = render (
80
+ < ErrorMessage
81
+ as = { CustErrComp }
82
+ errors = { { flat : { type : 'flat' , message : 'flat' } } }
83
+ name = "flat"
84
+ /> ,
85
+ ) ;
86
+
87
+ expect ( asFragment ( ) ) . toMatchSnapshot ( ) ;
88
+ } ) ;
89
+
90
+ it ( 'should render correctly with flat errors and as with component and render' , ( ) => {
91
+ function CustErrComp ( { children } : { children : React . ReactNode } ) {
92
+ return < div > { children } </ div > ;
93
+ }
94
+ const { asFragment } = render (
95
+ < ErrorMessage
96
+ as = { CustErrComp }
97
+ errors = { { flat : { type : 'flat' , message : 'flat' } } }
98
+ name = "flat"
99
+ render = { ( { message } ) => message }
100
+ /> ,
101
+ ) ;
102
+
103
+ expect ( asFragment ( ) ) . toMatchSnapshot ( ) ;
104
+ } ) ;
105
+
75
106
it ( 'should render correctly with flat multiple errors and render' , ( ) => {
76
107
const { asFragment } = render (
77
108
< ErrorMessage
@@ -99,7 +130,7 @@ describe('ErrorMessage', () => {
99
130
expect ( asFragment ( ) ) . toMatchSnapshot ( ) ;
100
131
} ) ;
101
132
102
- it ( 'should render correctly with flat multiple errors and as with component and render' , ( ) => {
133
+ it ( 'should render correctly with flat multiple errors and as with element and render' , ( ) => {
103
134
const { asFragment } = render (
104
135
< ErrorMessage
105
136
as = { < div /> }
@@ -204,7 +235,7 @@ describe('ErrorMessage', () => {
204
235
expect ( asFragment ( ) ) . toMatchSnapshot ( ) ;
205
236
} ) ;
206
237
207
- it ( 'should render correctly with nested multiple errors and as with component and render' , ( ) => {
238
+ it ( 'should render correctly with nested multiple errors and as with element and render' , ( ) => {
208
239
const { asFragment } = render (
209
240
< ErrorMessage
210
241
as = { < div /> }
@@ -269,7 +300,7 @@ describe('ErrorMessage', () => {
269
300
expect ( asFragment ( ) ) . toMatchSnapshot ( ) ;
270
301
} ) ;
271
302
272
- it ( 'should render correctly with nested errors array and as with component and render' , ( ) => {
303
+ it ( 'should render correctly with nested errors array and as with element and render' , ( ) => {
273
304
const { asFragment } = render (
274
305
< ErrorMessage
275
306
as = { < span /> }
@@ -319,7 +350,7 @@ describe('ErrorMessage', () => {
319
350
expect ( asFragment ( ) ) . toMatchSnapshot ( ) ;
320
351
} ) ;
321
352
322
- it ( 'should render correctly with nested multiple errors array and as with component and render' , ( ) => {
353
+ it ( 'should render correctly with nested multiple errors array and as with element and render' , ( ) => {
323
354
const { asFragment } = render (
324
355
< ErrorMessage
325
356
as = { < div /> }
0 commit comments