@@ -276,6 +276,7 @@ test("req.session.destroy", () => {
276
276
} ,
277
277
{
278
278
setHeader : jest . fn ( ) ,
279
+ getHeader : jest . fn ( ) ,
279
280
} ,
280
281
) ;
281
282
} ) ;
@@ -647,7 +648,7 @@ test("it handles previously set cookies (single value)", () => {
647
648
} ) ;
648
649
} ) ;
649
650
650
- test ( "it handles previously set cookies (multiple values)" , ( ) => {
651
+ test ( "it handles previously set cookies (multiple values) on save() " , ( ) => {
651
652
return new Promise ( ( done ) => {
652
653
const handler = async ( req , res ) => {
653
654
await req . session . save ( ) ;
@@ -672,3 +673,35 @@ test("it handles previously set cookies (multiple values)", () => {
672
673
) ;
673
674
} ) ;
674
675
} ) ;
676
+
677
+ test ( "it handles previously set cookies (multiple values) on destroy()" , ( ) => {
678
+ return new Promise ( ( done ) => {
679
+ const handler = async ( req , res ) => {
680
+ await req . session . destroy ( ) ;
681
+
682
+ expect ( res . setHeader . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
683
+ Array [
684
+ "set-cookie",
685
+ Array [
686
+ "existingCookie=value",
687
+ "anotherCookie=value2",
688
+ "test=; Max-Age=0; Path=/; HttpOnly; Secure; SameSite=Lax",
689
+ ],
690
+ ]
691
+ ` ) ;
692
+ done ( ) ;
693
+ } ;
694
+ const wrappedHandler = withIronSession ( handler , { password, cookieName } ) ;
695
+ wrappedHandler (
696
+ {
697
+ headers : { cookie : "" } ,
698
+ } ,
699
+ {
700
+ setHeader : jest . fn ( ) ,
701
+ getHeader : function ( ) {
702
+ return [ "existingCookie=value" , "anotherCookie=value2" ] ;
703
+ } ,
704
+ } ,
705
+ ) ;
706
+ } ) ;
707
+ } ) ;
0 commit comments