@@ -81,11 +81,6 @@ describe('component tests', () => {
8181 } ) ;
8282
8383 it ( 'renders with error' , ( ) => {
84- if ( [ componentTypes . RADIO , componentTypes . SWITCH , componentTypes . CHECKBOX ] . includes ( component ) ) {
85- // 'skipped because this component does not support this';
86- return ;
87- }
88-
8984 const errorField = {
9085 ...field ,
9186 validate : [ { type : validatorTypes . REQUIRED } ]
@@ -95,26 +90,15 @@ describe('component tests', () => {
9590
9691 if ( wrapper . find ( '#field-name-error-msg' ) . length ) {
9792 expect ( wrapper . find ( '#field-name-error-msg' ) . text ( ) ) . toEqual ( errorText ) ;
93+ expect ( wrapper . find ( '[invalid=true]' ) . length ) . toBeGreaterThanOrEqual ( 1 ) ;
9894 }
9995
100- expect ( wrapper . find ( '[invalid=true]' ) . length ) . toBeGreaterThanOrEqual ( 1 ) ;
96+ if ( wrapper . find ( '.ddorg__carbon-error-helper-text' ) . length ) {
97+ expect ( wrapper . find ( '.ddorg__carbon-error-helper-text' ) . text ( ) ) . toEqual ( errorText ) ;
98+ }
10199 } ) ;
102100
103101 it ( 'renders with helperText' , ( ) => {
104- if (
105- [
106- componentTypes . RADIO ,
107- componentTypes . SWITCH ,
108- componentTypes . CHECKBOX ,
109- componentTypes . DATE_PICKER ,
110- componentTypes . TIME_PICKER ,
111- componentTypes . SLIDER
112- ] . includes ( component )
113- ) {
114- // 'skipped because this component does not support this';
115- return ;
116- }
117-
118102 const helpertextField = {
119103 ...field ,
120104 helperText
@@ -143,60 +127,36 @@ describe('component tests', () => {
143127 const descriptionField = {
144128 ...field ,
145129 description,
146- ...( ! [
147- componentTypes . RADIO ,
148- componentTypes . SWITCH ,
149- componentTypes . CHECKBOX ,
150- componentTypes . DATE_PICKER ,
151- componentTypes . TIME_PICKER ,
152- componentTypes . SLIDER
153- ] . includes ( component )
154- ? { helperText }
155- : { } )
130+ helperText
156131 } ;
157132 const wrapper = mount ( < RendererWrapper schema = { { fields : [ descriptionField ] } } /> ) ;
158133
159134 expect ( wrapper . find ( WithDescription ) ) . toHaveLength ( 1 ) ;
160135
161- if (
162- ! [
163- componentTypes . RADIO ,
164- componentTypes . SWITCH ,
165- componentTypes . CHECKBOX ,
166- componentTypes . DATE_PICKER ,
167- componentTypes . TIME_PICKER ,
168- componentTypes . SLIDER
169- ] . includes ( component )
170- ) {
171- expect (
172- wrapper
173- . find ( '.bx--form__helper-text' )
174- . last ( )
175- . text ( )
176- ) . toEqual ( helperText ) ;
177- }
136+ expect (
137+ wrapper
138+ . find ( '.bx--form__helper-text' )
139+ . last ( )
140+ . text ( )
141+ ) . toEqual ( helperText ) ;
178142 } ) ;
179143
180144 it ( 'renders with error and helperText' , ( ) => {
181145 const errorFields = {
182146 ...field ,
183- ...( ! [
184- componentTypes . RADIO ,
185- componentTypes . SWITCH ,
186- componentTypes . CHECKBOX ,
187- componentTypes . DATE_PICKER ,
188- componentTypes . TIME_PICKER ,
189- componentTypes . SLIDER
190- ] . includes ( component )
191- ? { helperText }
192- : { } ) ,
147+ helperText,
193148 validate : [ { type : validatorTypes . REQUIRED } ]
194149 } ;
195150 const wrapper = mount ( < RendererWrapper schema = { { fields : [ errorFields ] } } /> ) ;
196151 wrapper . find ( 'form' ) . simulate ( 'submit' ) ;
197152
198153 if ( wrapper . find ( '#field-name-error-msg' ) . length ) {
199154 expect ( wrapper . find ( '#field-name-error-msg' ) . text ( ) ) . toEqual ( errorText ) ;
155+ expect ( wrapper . find ( '[invalid=true]' ) . length ) . toBeGreaterThanOrEqual ( 1 ) ;
156+ }
157+
158+ if ( wrapper . find ( '.ddorg__carbon-error-helper-text' ) . length ) {
159+ expect ( wrapper . find ( '.ddorg__carbon-error-helper-text' ) . text ( ) ) . toEqual ( errorText ) ;
200160 }
201161
202162 expect ( wrapper . find ( '.bx--form__helper-text' ) ) . toHaveLength ( 0 ) ;
0 commit comments