@@ -38,4 +38,57 @@ describe("get-component-meta", () => {
38
38
expect ( meta . props . length ) . toEqual ( 4 ) ;
39
39
expect ( ( meta as unknown as Record < string , unknown > ) . cachedAt ) . toBeDefined ( ) ;
40
40
} ) ;
41
+
42
+ test ( "parse ExtendMetaComponent with extendComponentMeta" , { timeout : 10000 } , ( ) => {
43
+ const meta = getComponentMeta ( "components/ExtendMetaComponent.vue" , {
44
+ rootDir,
45
+ } )
46
+
47
+ // Check basic component metadata from defineProps/defineEmits
48
+ expect ( meta . props . length ) . toEqual ( 2 ) ; // title, enabled
49
+ expect ( meta . props . find ( p => p . name === 'title' ) ) . toBeDefined ( ) ;
50
+ expect ( meta . props . find ( p => p . name === 'enabled' ) ) . toBeDefined ( ) ;
51
+ expect ( meta . events . length ) . toEqual ( 1 ) ;
52
+ expect ( meta . events [ 0 ] . name ) . toEqual ( 'updated' ) ;
53
+
54
+ // Check that extendComponentMeta adds custom metadata fields
55
+ const extendedMeta = meta as unknown as Record < string , unknown > ;
56
+ expect ( extendedMeta . description ) . toEqual ( 'A component that demonstrates extendComponentMeta functionality' ) ;
57
+ expect ( extendedMeta . version ) . toEqual ( '1.0.0' ) ;
58
+ expect ( extendedMeta . tags ) . toEqual ( [ 'test' , 'meta' ] ) ;
59
+ expect ( extendedMeta . customData ) . toEqual ( {
60
+ for : 'Test Suite' ,
61
+ category : 'utility'
62
+ } ) ;
63
+ } ) ;
64
+
65
+ test ( "parse ExtendMetaComponent with extendComponentMeta (cached)" , { timeout : 10000 } , ( ) => {
66
+ const meta = getComponentMeta ( "components/ExtendMetaComponent.vue" , {
67
+ rootDir,
68
+ cache : true
69
+ } )
70
+
71
+ // Check that extendComponentMeta custom fields persist through caching
72
+ const extendedMeta = meta as unknown as Record < string , unknown > ;
73
+ expect ( extendedMeta . description ) . toEqual ( 'A component that demonstrates extendComponentMeta functionality' ) ;
74
+ expect ( extendedMeta . version ) . toEqual ( '1.0.0' ) ;
75
+ expect ( extendedMeta . tags ) . toEqual ( [ 'test' , 'meta' ] ) ;
76
+ expect ( extendedMeta . customData ) . toEqual ( {
77
+ for : 'Test Suite' ,
78
+ category : 'utility'
79
+ } ) ;
80
+ expect ( extendedMeta . cachedAt ) . toBeUndefined ( ) ;
81
+ } ) ;
82
+
83
+ test ( "parse ExtendMetaComponent cached retrieval" , { timeout : 10000 } , ( ) => {
84
+ const meta = getComponentMeta ( "components/ExtendMetaComponent.vue" , {
85
+ rootDir,
86
+ cache : true
87
+ } )
88
+
89
+ // Check that extendComponentMeta custom fields are preserved in cached version
90
+ const extendedMeta = meta as unknown as Record < string , unknown > ;
91
+ expect ( extendedMeta . description ) . toEqual ( 'A component that demonstrates extendComponentMeta functionality' ) ;
92
+ expect ( extendedMeta . cachedAt ) . toBeDefined ( ) ;
93
+ } ) ;
41
94
} ) ;
0 commit comments