1
1
import { describe , test , expect } from 'vitest'
2
2
import { getComponentMeta } from '../src/parser'
3
3
import { propsToJsonSchema } from '../src/utils/schema'
4
- import { jsonSchemaToZod } from 'json-schema-to-zod'
5
4
6
5
describe ( 'ComponentMetaParser' , ( ) => {
7
6
test ( 'should be able to fetch component meta' , async ( ) => {
@@ -17,50 +16,6 @@ describe('ComponentMetaParser', () => {
17
16
expect ( propsNames ) . toContain ( 'numberProp' )
18
17
} )
19
18
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
-
64
19
test ( 'propsToJsonSchema should convert props to JSON Schema format' , async ( ) => {
65
20
const meta = getComponentMeta ( 'playground/components/TestComponent.vue' )
66
21
const jsonSchema = propsToJsonSchema ( meta . props )
@@ -138,7 +93,7 @@ describe('ComponentMetaParser', () => {
138
93
expect ( jsonSchema . required ) . toEqual ( [ 'name' ] )
139
94
} )
140
95
141
- test ( 'manual ' , ( ) => {
96
+ test ( 'TestD.vue ' , ( ) => {
142
97
const meta = getComponentMeta ( 'playground/components/TestD.vue' )
143
98
const result = propsToJsonSchema ( meta . props )
144
99
0 commit comments