11import { describe , test , expect } from 'vitest'
22import { getComponentMeta } from '../src/parser'
33import { propsToJsonSchema } from '../src/utils/schema'
4- import { jsonSchemaToZod } from 'json-schema-to-zod'
54
65describe ( 'ComponentMetaParser' , ( ) => {
76 test ( 'should be able to fetch component meta' , async ( ) => {
@@ -17,50 +16,6 @@ describe('ComponentMetaParser', () => {
1716 expect ( propsNames ) . toContain ( 'numberProp' )
1817 } )
1918
20- test ( 'whole' , async ( ) => {
21- const meta = getComponentMeta ( 'playground/components/TestComponent.vue' )
22- const jsonSchema = propsToJsonSchema ( meta . props )
23- const zod = jsonSchemaToZod ( jsonSchema , { module : "cjs" } )
24-
25- const data = [
26- {
27- match : true ,
28- data : {
29- name : 'nuxt-component-meta' ,
30- foo : 'bar' ,
31- hello : 'world' ,
32- booleanProp : true ,
33- numberProp : 42 ,
34- data : {
35- gello : "Gello"
36- }
37- }
38- } ,
39- {
40- match : false ,
41- data : {
42- name : 'nuxt-component-meta' ,
43- foo : 12 ,
44- hello : 'world' ,
45- booleanProp : true ,
46- numberProp : 42 ,
47- data : {
48- gello : "Gello"
49- }
50- }
51- }
52- ]
53-
54- for ( const item of data ) {
55- const schema = eval ( zod )
56- if ( item . match ) {
57- schema . parse ( item . data )
58- } else {
59- expect ( ( ) => schema . parse ( data ) ) . toThrow ( )
60- }
61- }
62- } )
63-
6419 test ( 'propsToJsonSchema should convert props to JSON Schema format' , async ( ) => {
6520 const meta = getComponentMeta ( 'playground/components/TestComponent.vue' )
6621 const jsonSchema = propsToJsonSchema ( meta . props )
@@ -138,7 +93,7 @@ describe('ComponentMetaParser', () => {
13893 expect ( jsonSchema . required ) . toEqual ( [ 'name' ] )
13994 } )
14095
141- test ( 'manual ' , ( ) => {
96+ test ( 'TestD.vue ' , ( ) => {
14297 const meta = getComponentMeta ( 'playground/components/TestD.vue' )
14398 const result = propsToJsonSchema ( meta . props )
14499
0 commit comments