@@ -16,6 +16,7 @@ function teardown () {
1616 createHttpClientRewireApi . __ResetDependency__ ( 'rateLimit' )
1717 mock . reset ( )
1818 axios . create . restore ( )
19+ logHandlerStub . resetHistory ( )
1920}
2021
2122test ( 'Calls axios with expected default URL' , t => {
@@ -97,3 +98,31 @@ test('Fails with missing access token', t => {
9798 t . end ( )
9899 }
99100} )
101+
102+ test ( 'Calls axios based on passed hostname with basePath' , t => {
103+ setup ( )
104+ createHttpClient ( axios , {
105+ accessToken : 'clientAccessToken' ,
106+ host : 'some.random.example.com' ,
107+ basePath : '/foo/bar'
108+ } )
109+
110+ t . equals ( axios . create . args [ 0 ] [ 0 ] . baseURL , 'https://some.random.example.com:443/foo/bar/spaces/' )
111+ t . equals ( logHandlerStub . callCount , 0 , 'does not log anything' )
112+ teardown ( )
113+ t . end ( )
114+ } )
115+
116+ test ( 'Calls axios based on passed hostname with invalid basePath and fixes the invalid one' , t => {
117+ setup ( )
118+ createHttpClient ( axios , {
119+ accessToken : 'clientAccessToken' ,
120+ host : 'some.random.example.com' ,
121+ basePath : 'foo/bar'
122+ } )
123+
124+ t . equals ( axios . create . args [ 0 ] [ 0 ] . baseURL , 'https://some.random.example.com:443/foo/bar/spaces/' )
125+ t . equals ( logHandlerStub . callCount , 0 , 'does not log anything' )
126+ teardown ( )
127+ t . end ( )
128+ } )
0 commit comments