11import { describe , expect , it } from 'vitest'
22import { useFormKitSchema } from '../src/composables'
33
4+ interface FormKitComponent {
5+ $cmp ?: string
6+ props ?: Record < string , any >
7+ validation ?: string
8+ validationVisibility ?: string
9+ validationLabel ?: string
10+ [ key : string ] : any
11+ }
12+
13+ interface FormKitElement {
14+ $el : string
15+ attrs ?: {
16+ class ?: string
17+ style ?: string
18+ [ key : string ] : any
19+ }
20+ children ?: any [ ]
21+ validation ?: string
22+ validationVisibility ?: string
23+ }
24+
425it ( 'add list group' , ( ) => {
526 const { addListGroup } = useFormKitSchema ( )
627
@@ -21,14 +42,14 @@ it('add element with non-boolean render value', () => {
2142it ( 'add component with props' , ( ) => {
2243 const { addComponent } = useFormKitSchema ( )
2344 const props = { label : 'Save' , severity : 'primary' }
24- const component = addComponent ( 'Button' , props )
45+ const component = addComponent ( 'Button' , props ) as FormKitComponent
2546 expect ( component ?. props ) . toEqual ( props )
2647} )
2748
2849describe ( 'addElementsInOuterDiv' , ( ) => {
2950 it ( 'creates default structure with minimal params' , ( ) => {
3051 const { addElementsInOuterDiv } = useFormKitSchema ( )
31- const outerDiv = addElementsInOuterDiv ( )
52+ const outerDiv = addElementsInOuterDiv ( ) as FormKitElement
3253
3354 expect ( outerDiv ?. $el ) . toBe ( 'div' )
3455 expect ( outerDiv ?. attrs ?. class ) . toBe ( 'formkit-outer ' )
@@ -48,7 +69,7 @@ describe('addElementsInOuterDiv', () => {
4869
4970 it ( 'applies custom classes' , ( ) => {
5071 const { addElementsInOuterDiv } = useFormKitSchema ( )
51- const outerDiv = addElementsInOuterDiv ( [ ] , 'custom-inner' , 'custom-outer' )
72+ const outerDiv = addElementsInOuterDiv ( [ ] , 'custom-inner' , 'custom-outer' ) as FormKitElement
5273
5374 expect ( outerDiv ?. attrs ?. class ) . toBe ( 'formkit-outer custom-outer' )
5475
@@ -60,7 +81,7 @@ describe('addElementsInOuterDiv', () => {
6081it ( 'combines formKitAttrs with element properties' , ( ) => {
6182 const { addElement } = useFormKitSchema ( )
6283 const formKitAttrs = { validation : 'required' , validationVisibility : 'dirty' }
63- const element = addElement ( 'div' , [ ] , { } , true , formKitAttrs )
84+ const element = addElement ( 'div' , [ ] , { } , true , formKitAttrs ) as FormKitElement
6485
6586 expect ( element ?. $el ) . toBe ( 'div' )
6687 expect ( element ?. validation ) . toBe ( 'required' )
@@ -70,7 +91,7 @@ it('combines formKitAttrs with element properties', () => {
7091it ( 'combines formKitAttrs with component properties' , ( ) => {
7192 const { addComponent } = useFormKitSchema ( )
7293 const formKitAttrs = { validation : 'required' , validationLabel : 'Button' }
73- const component = addComponent ( 'Button' , { } , true , formKitAttrs )
94+ const component = addComponent ( 'Button' , { } , true , formKitAttrs ) as FormKitComponent
7495
7596 expect ( component ?. $cmp ) . toBe ( 'Button' )
7697 expect ( component ?. validation ) . toBe ( 'required' )
0 commit comments