File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,12 +11,30 @@ export class ClientOptionsLoader implements IClientOptionsLoader {
1111
1212 async load ( ) : Promise < ClientOptions > {
1313 let { serverPort } = await this . storedOptionsLoader . load ( )
14+ const extensionId = this . manifestInfo . getId ( )
1415 let serverUrl = new URL ( `http://localhost:${ serverPort } /` )
15- let { host } = new URL ( `extension: //${ this . manifestInfo . getId ( ) } .localhost` )
16+ let { host } = new URL ( `extension://${ extensionId } .localhost` )
1617
1718 return {
1819 serverUrl,
1920 clientHostName : host ,
2021 }
2122 }
2223}
24+
25+ if ( import . meta. vitest ) {
26+ const { describe, expect, it, vi } = import . meta. vitest
27+
28+ describe ( ClientOptionsLoader , ( ) => {
29+ it ( "should build a ClientOption from storage and manifest info correctly" , async ( ) => {
30+ const storedOptionsLoader = { load : vi . fn ( ) . mockResolvedValue ( { serverPort : 1234 } ) }
31+ const manifestInfo = { getId : vi . fn ( ) . mockReturnValue ( "@test.extension" ) }
32+ const sut = new ClientOptionsLoader ( storedOptionsLoader , manifestInfo )
33+
34+ await expect ( sut . load ( ) ) . resolves . deep . equals ( {
35+ serverUrl : new URL ( "http://localhost:1234/" ) ,
36+ clientHostName : "test.extension.localhost" ,
37+ } )
38+ } )
39+ } )
40+ }
You can’t perform that action at this time.
0 commit comments