@@ -81,6 +81,29 @@ describe('setMetadataOptions', () => {
8181 expect ( content ) . toContain ( '# Test Config Metadata' ) ;
8282 } ) ;
8383
84+ it ( 'should merge values from multiple complete callbacks' , async ( ) => {
85+ const completeVersion = jest . fn ( ) . mockResolvedValue ( [ 'v1' ] ) ;
86+ const completeCategory = jest . fn ( ) . mockResolvedValue ( [ 'cat1' ] ) ;
87+ const options = setMetadataOptions ( {
88+ name : 'test' ,
89+ baseUri : 'test://uri' ,
90+ searchParams : [ ] ,
91+ config : { title : 'Test Multiple Callbacks' } as any ,
92+ metaConfig : { } ,
93+ complete : { version : completeVersion , category : completeCategory } ,
94+ registerAllSearchCombinations : undefined
95+ } ) ;
96+
97+ const content = await options . metaHandler ( { } ) ;
98+
99+ expect ( completeVersion ) . toHaveBeenCalledTimes ( 1 ) ;
100+ expect ( completeCategory ) . toHaveBeenCalledTimes ( 1 ) ;
101+ expect ( content ) . toContain ( 'version' ) ;
102+ expect ( content ) . toContain ( 'category' ) ;
103+ expect ( content ) . toContain ( 'v1' ) ;
104+ expect ( content ) . toContain ( 'cat1' ) ;
105+ } ) ;
106+
84107 it ( 'should fall back to empty values when a complete callback throws' , async ( ) => {
85108 const throwingComplete = jest . fn ( ) . mockRejectedValue ( new Error ( 'network error' ) ) ;
86109 const options = setMetadataOptions ( {
@@ -252,6 +275,7 @@ describe('setMetaResources', () => {
252275
253276 expect ( callback ) . toHaveBeenCalledTimes ( 1 ) ;
254277 expect ( result . contents ) . toHaveLength ( 2 ) ;
278+ expect ( result . contents [ 0 ] ) . toBe ( originalContent . contents [ 0 ] ) ;
255279 expect ( result . contents [ 0 ] . text ) . toBe ( 'original' ) ;
256280 expect ( result . contents [ 1 ] . text ) . toContain ( 'Test Metadata' ) ;
257281 } ) ;
0 commit comments