@@ -43,79 +43,84 @@ describe('atomic-field-condition', () => {
4343 } ;
4444
4545 it ( 'should render its content when no conditions are defined' , async ( ) => {
46- const { content} = await renderFieldCondition ( ) ;
46+ const { element, content} = await renderFieldCondition ( ) ;
47+ expect ( element ?. hidden ) . toBe ( false ) ;
4748 expect ( content ) . toBeInTheDocument ( ) ;
4849 } ) ;
4950
5051 it ( 'should render its content when an if-defined condition is met' , async ( ) => {
51- const { content} = await renderFieldCondition ( {
52+ const { element , content} = await renderFieldCondition ( {
5253 ifDefined : 'author' ,
5354 resultState : { raw : { author : 'John Doe' } } ,
5455 } ) ;
5556
57+ expect ( element ?. hidden ) . toBe ( false ) ;
5658 expect ( content ) . toBeInTheDocument ( ) ;
5759 } ) ;
5860
5961 it ( 'should not render its content when an if-defined condition is not met' , async ( ) => {
60- const { content } = await renderFieldCondition ( {
62+ const { element } = await renderFieldCondition ( {
6163 ifDefined : 'author' ,
6264 resultState : { raw : { } } ,
6365 } ) ;
6466
65- expect ( content ) . toBeUndefined ( ) ;
67+ expect ( element ?. hidden ) . toBe ( true ) ;
6668 } ) ;
6769
6870 it ( 'should render its content when an if-not-defined condition is met' , async ( ) => {
69- const { content} = await renderFieldCondition ( {
71+ const { element , content} = await renderFieldCondition ( {
7072 ifNotDefined : 'author' ,
7173 resultState : { raw : { } } ,
7274 } ) ;
7375
76+ expect ( element ?. hidden ) . toBe ( false ) ;
7477 expect ( content ) . toBeInTheDocument ( ) ;
7578 } ) ;
7679
7780 it ( 'should not render its content when an if-not-defined condition is not met' , async ( ) => {
78- const { content } = await renderFieldCondition ( {
81+ const { element } = await renderFieldCondition ( {
7982 ifNotDefined : 'author' ,
8083 resultState : { raw : { author : 'John Doe' } } ,
8184 } ) ;
8285
83- expect ( content ) . toBeUndefined ( ) ;
86+ expect ( element ?. hidden ) . toBe ( true ) ;
8487 } ) ;
8588
8689 it ( 'should render its content when a must-match condition is met' , async ( ) => {
87- const { content} = await renderFieldCondition ( {
90+ const { element , content} = await renderFieldCondition ( {
8891 mustMatch : { filetype : [ 'pdf' ] } ,
8992 resultState : { raw : { filetype : 'pdf' } } ,
9093 } ) ;
9194
95+ expect ( element ?. hidden ) . toBe ( false ) ;
9296 expect ( content ) . toBeInTheDocument ( ) ;
9397 } ) ;
9498
9599 it ( 'should not render its content when a must-match condition is not met' , async ( ) => {
96- const { content } = await renderFieldCondition ( {
100+ const { element } = await renderFieldCondition ( {
97101 mustMatch : { filetype : [ 'pdf' ] } ,
98102 resultState : { raw : { filetype : 'docx' } } ,
99103 } ) ;
100104
101- expect ( content ) . toBeUndefined ( ) ;
105+ expect ( element ?. hidden ) . toBe ( true ) ;
102106 } ) ;
103107
104108 it ( 'should render its content when a must-not-match condition is met' , async ( ) => {
105- const { content} = await renderFieldCondition ( {
109+ const { element , content} = await renderFieldCondition ( {
106110 mustNotMatch : { filetype : [ 'docx' ] } ,
107111 resultState : { raw : { filetype : 'pdf' } } ,
108112 } ) ;
109113
114+ expect ( element ?. hidden ) . toBe ( false ) ;
110115 expect ( content ) . toBeInTheDocument ( ) ;
111116 } ) ;
112117
113118 it ( 'should not render its content when a must-not-match condition is not met' , async ( ) => {
114- const { content } = await renderFieldCondition ( {
119+ const { element } = await renderFieldCondition ( {
115120 mustNotMatch : { filetype : [ 'docx' ] } ,
116121 resultState : { raw : { filetype : 'docx' } } ,
117122 } ) ;
118123
119- expect ( content ) . toBeUndefined ( ) ;
124+ expect ( element ?. hidden ) . toBe ( true ) ;
120125 } ) ;
121126} ) ;
0 commit comments