@@ -586,7 +586,7 @@ describe('fetch', () => {
586586 expect ( resp . status ) . toBe ( 200 )
587587 } )
588588
589- it ( 'merges request headers with the authorization header' , async ( ) => {
589+ it ( 'merges an object of request headers with the authorization header' , async ( ) => {
590590 await saveSession ( window . localStorage ) ( fakeSession )
591591
592592 nock ( 'https://third-party.com' )
@@ -606,6 +606,28 @@ describe('fetch', () => {
606606 expect ( resp . status ) . toBe ( 200 )
607607 } )
608608
609+ it ( 'merges a Header object with the authorization header' , async ( ) => {
610+ await saveSession ( window . localStorage ) ( fakeSession )
611+
612+ nock ( 'https://third-party.com' )
613+ . get ( '/private-resource' )
614+ . reply ( 401 , '' , { 'www-authenticate' : 'Bearer scope="openid webid"' } )
615+ . get ( '/private-resource' )
616+ . matchHeader ( 'accept' , 'text/plain' )
617+ . matchHeader ( 'authorization' , matchAuthzHeader ( 'https://third-party.com' ) )
618+ . reply ( 200 )
619+
620+ const resp = await instance . fetch (
621+ 'https://third-party.com/private-resource' ,
622+ {
623+ headers : {
624+ entries : ( ) => [ [ 'accept' , 'text/plain' ] ]
625+ }
626+ }
627+ )
628+ expect ( resp . status ) . toBe ( 200 )
629+ } )
630+
609631 it ( 'does not resend with credentials if the www-authenticate header is missing' , async ( ) => {
610632 expect . assertions ( 1 )
611633 await saveSession ( window . localStorage ) ( fakeSession )
0 commit comments