@@ -45,7 +45,7 @@ describe('ErrorMessage', () => {
4545 expect ( asFragment ( ) ) . toMatchSnapshot ( ) ;
4646 } ) ;
4747
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' , ( ) => {
4949 const { asFragment } = render (
5050 < ErrorMessage
5151 as = { < span /> }
@@ -58,7 +58,7 @@ describe('ErrorMessage', () => {
5858 expect ( asFragment ( ) ) . toMatchSnapshot ( ) ;
5959 } ) ;
6060
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' , ( ) => {
6262 const { asFragment } = render (
6363 < ErrorMessage
6464 as = { < span /> }
@@ -72,6 +72,37 @@ describe('ErrorMessage', () => {
7272 expect ( asFragment ( ) ) . toMatchSnapshot ( ) ;
7373 } ) ;
7474
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+
75106 it ( 'should render correctly with flat multiple errors and render' , ( ) => {
76107 const { asFragment } = render (
77108 < ErrorMessage
@@ -99,7 +130,7 @@ describe('ErrorMessage', () => {
99130 expect ( asFragment ( ) ) . toMatchSnapshot ( ) ;
100131 } ) ;
101132
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' , ( ) => {
103134 const { asFragment } = render (
104135 < ErrorMessage
105136 as = { < div /> }
@@ -204,7 +235,7 @@ describe('ErrorMessage', () => {
204235 expect ( asFragment ( ) ) . toMatchSnapshot ( ) ;
205236 } ) ;
206237
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' , ( ) => {
208239 const { asFragment } = render (
209240 < ErrorMessage
210241 as = { < div /> }
@@ -269,7 +300,7 @@ describe('ErrorMessage', () => {
269300 expect ( asFragment ( ) ) . toMatchSnapshot ( ) ;
270301 } ) ;
271302
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' , ( ) => {
273304 const { asFragment } = render (
274305 < ErrorMessage
275306 as = { < span /> }
@@ -319,7 +350,7 @@ describe('ErrorMessage', () => {
319350 expect ( asFragment ( ) ) . toMatchSnapshot ( ) ;
320351 } ) ;
321352
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' , ( ) => {
323354 const { asFragment } = render (
324355 < ErrorMessage
325356 as = { < div /> }
0 commit comments