@@ -308,6 +308,94 @@ describe('condition test', () => {
308308 } ) ;
309309 } ) ;
310310
311+ it ( 'should render when condition is fulfill - not' , async ( ) => {
312+ schema = {
313+ fields : [
314+ {
315+ component : componentTypes . TEXT_FIELD ,
316+ name : 'field-1' ,
317+ } ,
318+ {
319+ component : componentTypes . TEXT_FIELD ,
320+ name : 'field-2' ,
321+ condition : [
322+ {
323+ not : {
324+ when : 'field-1' ,
325+ is : 'show' ,
326+ } ,
327+ } ,
328+ ] ,
329+ } ,
330+ ] ,
331+ } ;
332+
333+ render ( < FormRenderer { ...initialProps } schema = { schema } /> ) ;
334+
335+ expect ( screen . getByLabelText ( 'field-2' ) ) . toBeInTheDocument ( ) ;
336+
337+ userEvent . type ( screen . getByLabelText ( 'field-1' ) , 'show' ) ;
338+
339+ expect ( ( ) => screen . getByLabelText ( 'field-2' ) ) . toThrow ( ) ;
340+
341+ userEvent . type ( screen . getByLabelText ( 'field-1' ) , 'dont' ) ;
342+
343+ expect ( screen . getByLabelText ( 'field-2' ) ) . toBeInTheDocument ( ) ;
344+ } ) ;
345+
346+ it ( 'should render when condition is fulfill - not - array' , async ( ) => {
347+ schema = {
348+ fields : [
349+ {
350+ component : componentTypes . TEXT_FIELD ,
351+ name : 'field-1' ,
352+ } ,
353+ {
354+ component : componentTypes . TEXT_FIELD ,
355+ name : 'field-3' ,
356+ } ,
357+ {
358+ component : componentTypes . TEXT_FIELD ,
359+ name : 'field-2' ,
360+ condition : [
361+ {
362+ not : [
363+ {
364+ when : 'field-1' ,
365+ is : 'show' ,
366+ } ,
367+ {
368+ when : 'field-3' ,
369+ is : 'show' ,
370+ } ,
371+ ] ,
372+ } ,
373+ ] ,
374+ } ,
375+ ] ,
376+ } ;
377+
378+ render ( < FormRenderer { ...initialProps } schema = { schema } /> ) ;
379+
380+ expect ( screen . getByLabelText ( 'field-2' ) ) . toBeInTheDocument ( ) ;
381+
382+ userEvent . type ( screen . getByLabelText ( 'field-1' ) , 'show' ) ; // (show == show && '' == show) = FALSE => TRUE
383+
384+ expect ( screen . getByLabelText ( 'field-2' ) ) . toBeInTheDocument ( ) ;
385+
386+ userEvent . type ( screen . getByLabelText ( 'field-1' ) , 'dont' ) ; // (show == dontshow && '' == show) = FALSE => TRUE
387+
388+ expect ( screen . getByLabelText ( 'field-2' ) ) . toBeInTheDocument ( ) ;
389+
390+ userEvent . type ( screen . getByLabelText ( 'field-3' ) , 'show' ) ; // (show == dontshow && show == show) = FALSE => TRUE
391+
392+ expect ( screen . getByLabelText ( 'field-2' ) ) . toBeInTheDocument ( ) ;
393+
394+ userEvent . type ( screen . getByLabelText ( 'field-1' ) , '{selectall}{backspace}show' ) ; // (show == show && show == show) = TRUE => FALSE
395+
396+ expect ( ( ) => screen . getByLabelText ( 'field-2' ) ) . toThrow ( ) ;
397+ } ) ;
398+
311399 describe ( 'reducer' , ( ) => {
312400 it ( 'returns default' , ( ) => {
313401 const initialState = {
0 commit comments