@@ -395,7 +395,16 @@ describe.each(EACH_MATRIX)('%s:%s: integration tests', (eventSourceName, framewo
395395 } )
396396
397397 test ( 'set-cookie' , async ( ) => {
398+ const now = new Date ( 2022 , 7 , 11 , 3 , 30 , 30 )
399+ const maxAge = 3000
400+ const expires = new Date ( + now + maxAge )
401+ const expectedExpires = expires . toUTCString ( )
402+
403+ jest . useFakeTimers ( 'modern' )
404+ jest . setSystemTime ( now )
405+
398406 router . get ( '/cookie' , ( req , res ) => {
407+ res . cookie ( 'Zoo' , 'boo' , { domain : 'mafoo.com' , secure : true , httpOnly : true , sameSite : 'Strict' , maxAge } )
399408 res . cookie ( 'Foo' , 'bar' , { domain : 'example.com' , secure : true , httpOnly : true , sameSite : 'Strict' } )
400409 res . cookie ( 'Fizz' , 'buzz' )
401410 res . json ( { } )
@@ -408,6 +417,7 @@ describe.each(EACH_MATRIX)('%s:%s: integration tests', (eventSourceName, framewo
408417 const response = await serverlessExpressInstance ( event )
409418
410419 const expectedSetCookieHeaders = [
420+ `Zoo=boo; Max-Age=3; Domain=mafoo.com; Path=/; Expires=${ expectedExpires } ; HttpOnly; Secure; SameSite=Strict` ,
411421 'Foo=bar; Domain=example.com; Path=/; HttpOnly; Secure; SameSite=Strict' ,
412422 'Fizz=buzz; Path=/'
413423 ]
@@ -423,10 +433,23 @@ describe.each(EACH_MATRIX)('%s:%s: integration tests', (eventSourceName, framewo
423433 statusCode : 200
424434 } )
425435
436+ jest . useRealTimers ( )
437+
426438 switch ( eventSourceName ) {
427439 case 'azureHttpFunctionV4' :
428440 case 'azureHttpFunctionV3' :
429441 expectedResponse . cookies = [
442+ {
443+ domain : 'mafoo.com' ,
444+ httpOnly : true ,
445+ name : 'Zoo' ,
446+ path : '/' ,
447+ sameSite : 'Strict' ,
448+ secure : true ,
449+ value : 'boo' ,
450+ maxAge : maxAge / 1000 ,
451+ expires
452+ } ,
430453 {
431454 domain : 'example.com' ,
432455 httpOnly : true ,
0 commit comments