@@ -146,7 +146,7 @@ describe('params reached to function', () => {
146146 ) . toBe ( true )
147147 } )
148148
149- test ( 'invoke mirror with invoke header and valid region' , async ( ) => {
149+ test ( 'invoke mirror set valid region on request ' , async ( ) => {
150150 /**
151151 * @feature headers
152152 */
@@ -230,7 +230,7 @@ describe('params reached to function', () => {
230230 ) . toBe ( true )
231231 } )
232232
233- test ( 'invoke with region overrides region in the client ' , async ( ) => {
233+ test ( 'starts client with default region, invoke reverts to any (no x-region header) ' , async ( ) => {
234234 /**
235235 * @feature headers
236236 */
@@ -248,6 +248,7 @@ describe('params reached to function', () => {
248248 'custom-header' : customHeader ,
249249 Authorization : `Bearer ${ apiKey } ` ,
250250 } ,
251+ region : FunctionRegion . Any
251252 } )
252253
253254 log ( 'assert no error' )
@@ -268,32 +269,31 @@ describe('params reached to function', () => {
268269 console . log ( data ?. headers )
269270 expect (
270271 ( data ?. headers as [ Array < string > ] ) . filter ( ( [ k , v ] ) => k === 'x-region' && v === validRegion )
271- . length > 0
272+ . length == 0
272273 ) . toBe ( true )
273274 } )
274275
275- test ( 'invoke mirror with invoke header and valid region ' , async ( ) => {
276+ test ( 'invoke region set only on the constructor ' , async ( ) => {
276277 /**
277278 * @feature headers
278279 */
279280 log ( 'create FunctionsClient' )
280- const fclient = new FunctionsClient ( `http://localhost:${ relay . container . getMappedPort ( 8081 ) } ` )
281+ const fclient = new FunctionsClient ( `http://localhost:${ relay . container . getMappedPort ( 8081 ) } ` , { region : FunctionRegion . ApNortheast1 } )
281282
282283 log ( 'invoke mirror' )
283284 const customHeader = nanoid ( )
284- const validRegion = FunctionRegion . EuWest1
285+
285286
286287 const { data, error } = await fclient . invoke < MirrorResponse > ( 'mirror' , {
287288 headers : {
288289 'custom-header' : customHeader ,
289- Authorization : `Bearer ${ apiKey } ` ,
290- 'x-region' : validRegion ,
290+ Authorization : `Bearer ${ apiKey } `
291291 } ,
292292 } )
293293
294294 log ( 'assert no error' )
295295 expect (
296- ( data ?. headers as [ Array < string > ] ) . filter ( ( [ k , v ] ) => k === 'x-region' && v === FunctionRegion . EuWest1 )
296+ ( data ?. headers as [ Array < string > ] ) . filter ( ( [ k , v ] ) => k === 'x-region' && v === FunctionRegion . ApNortheast1 )
297297 . length > 0
298298 ) . toBe ( true )
299299 } )
0 commit comments