@@ -291,7 +291,7 @@ describe('GhostAdminAPI general', function () {
291
291
should . equal ( generateTokenSpy . args [ 0 ] [ 1 ] , '/admin/' ) ;
292
292
} ) ;
293
293
294
- it ( 'does not set "User-Agent" header when disabled' , async function ( ) {
294
+ it ( 'does not set "User-Agent" header when disabled' , async function ( ) {
295
295
const makeRequestStub = sinon . stub ( ) . returns ( Promise . resolve ( {
296
296
config : { }
297
297
} ) ) ;
@@ -314,5 +314,29 @@ describe('GhostAdminAPI general', function () {
314
314
should . equal ( generateTokenSpy . args [ 0 ] [ 0 ] , '5c73def7a21ad85eda5d4faa:d9a3e5b2d6c2a4afb094655c4dc543220be60b3561fa9622e3891213cb4357d0' ) ;
315
315
should . equal ( generateTokenSpy . args [ 0 ] [ 1 ] , '/admin/' ) ;
316
316
} ) ;
317
+
318
+ it ( 'sets a custom value for "User-Agent" header' , async function ( ) {
319
+ const makeRequestStub = sinon . stub ( ) . returns ( Promise . resolve ( {
320
+ config : { }
321
+ } ) ) ;
322
+ const generateTokenSpy = sinon . spy ( ) ;
323
+
324
+ const api = new GhostAdminAPI ( {
325
+ version : true ,
326
+ url : `http://ghost.local` ,
327
+ key : '5c73def7a21ad85eda5d4faa:d9a3e5b2d6c2a4afb094655c4dc543220be60b3561fa9622e3891213cb4357d0' ,
328
+ makeRequest : makeRequestStub ,
329
+ generateToken : generateTokenSpy ,
330
+ userAgent : 'Custom Value'
331
+ } ) ;
332
+
333
+ await api . config . read ( ) ;
334
+
335
+ makeRequestStub . calledOnce . should . be . true ( ) ;
336
+ should . equal ( makeRequestStub . args [ 0 ] [ 0 ] . headers [ 'Accept-Version' ] , 'v5.0' ) ;
337
+ should . equal ( makeRequestStub . args [ 0 ] [ 0 ] . headers [ 'User-Agent' ] , 'Custom Value' ) ;
338
+ should . equal ( generateTokenSpy . args [ 0 ] [ 0 ] , '5c73def7a21ad85eda5d4faa:d9a3e5b2d6c2a4afb094655c4dc543220be60b3561fa9622e3891213cb4357d0' ) ;
339
+ should . equal ( generateTokenSpy . args [ 0 ] [ 1 ] , '/admin/' ) ;
340
+ } ) ;
317
341
} ) ;
318
342
} ) ;
0 commit comments