@@ -94,6 +94,88 @@ describe("normalizeDeprecatedRequestOptions", () => {
9494 } ) ;
9595 } ) ;
9696
97+ test ( "should normalize tuple-based fetch headers" , ( ) => {
98+ const normalized = normalizeDeprecatedRequestOptions ( {
99+ headers : {
100+ "X-Deprecated" : "legacy"
101+ } ,
102+ fetchOptions : {
103+ headers : [ [ "X-Fetch-Tuple" , "tuple-value" ] ]
104+ }
105+ } ) ;
106+
107+ expect ( normalized . fetchOptions ?. headers ) . toEqual ( {
108+ "X-Deprecated" : "legacy" ,
109+ "X-Fetch-Tuple" : "tuple-value"
110+ } ) ;
111+ } ) ;
112+
113+ test ( "should prefer tuple-based fetch headers over deprecated top-level headers" , ( ) => {
114+ const normalized = normalizeDeprecatedRequestOptions ( {
115+ headers : {
116+ "X-Test" : "legacy-value" ,
117+ "X-Deprecated-Only" : "legacy"
118+ } ,
119+ fetchOptions : {
120+ headers : [
121+ [ "X-Test" , "tuple-value" ] ,
122+ [ "X-Fetch-Only" , "tuple-only" ]
123+ ]
124+ }
125+ } ) ;
126+
127+ expect ( normalized . fetchOptions ?. headers ) . toEqual ( {
128+ "X-Test" : "tuple-value" ,
129+ "X-Deprecated-Only" : "legacy" ,
130+ "X-Fetch-Only" : "tuple-only"
131+ } ) ;
132+ } ) ;
133+
134+ test ( "should normalize Headers instance in fetchOptions.headers" , ( ) => {
135+ if ( typeof Headers === "undefined" ) {
136+ return ;
137+ }
138+
139+ const normalized = normalizeDeprecatedRequestOptions ( {
140+ headers : {
141+ "X-Deprecated" : "legacy"
142+ } ,
143+ fetchOptions : {
144+ headers : new Headers ( [ [ "X-Fetch-Headers" , "headers-value" ] ] )
145+ }
146+ } ) ;
147+
148+ expect ( normalized . fetchOptions ?. headers ) . toEqual ( {
149+ "X-Deprecated" : "legacy" ,
150+ "x-fetch-headers" : "headers-value"
151+ } ) ;
152+ } ) ;
153+
154+ test ( "should prefer Headers instance values over deprecated top-level headers" , ( ) => {
155+ if ( typeof Headers === "undefined" ) {
156+ return ;
157+ }
158+
159+ const normalized = normalizeDeprecatedRequestOptions ( {
160+ headers : {
161+ "x-test" : "legacy-value" ,
162+ "X-Deprecated-Only" : "legacy"
163+ } ,
164+ fetchOptions : {
165+ headers : new Headers ( [
166+ [ "X-Test" , "headers-value" ] ,
167+ [ "X-Fetch-Only" , "headers-only" ]
168+ ] )
169+ }
170+ } ) ;
171+
172+ expect ( normalized . fetchOptions ?. headers ) . toEqual ( {
173+ "x-test" : "headers-value" ,
174+ "X-Deprecated-Only" : "legacy" ,
175+ "x-fetch-only" : "headers-only"
176+ } ) ;
177+ } ) ;
178+
97179 test ( "should drop legacy options without v2 replacements" , ( ) => {
98180 const normalized = normalizeDeprecatedRequestOptions ( {
99181 maxUrlLength : 3000 ,
0 commit comments