@@ -34,17 +34,17 @@ it('reflect .set into `set-cookie`', async () => {
34
34
35
35
const response = new NextResponse ( )
36
36
37
- response . cookies . set ( 'foo' , 'bar' )
37
+ response . cookies . set ( 'foo' , 'bar' , { path : '/test' } )
38
38
expect ( Object . fromEntries ( response . headers . entries ( ) ) [ 'set-cookie' ] ) . toBe (
39
- 'foo=bar; Path=/'
39
+ 'foo=bar; Path=/test '
40
40
)
41
- expect ( response . cookies . get ( 'foo' ) ) . toBe ( 'foo=bar; Path=/' )
41
+ expect ( response . cookies . getRaw ( 'foo' ) ) . toBe ( 'foo=bar; Path=/test ' )
42
42
43
43
response . cookies . set ( 'foo' , 'barz' )
44
44
expect ( Object . fromEntries ( response . headers . entries ( ) ) [ 'set-cookie' ] ) . toBe (
45
45
'foo=barz; Path=/'
46
46
)
47
- expect ( response . cookies . get ( 'foo' ) ) . toBe ( 'foo=barz; Path=/' )
47
+ expect ( response . cookies . getRaw ( 'foo' ) ) . toBe ( 'foo=barz; Path=/' )
48
48
49
49
response . cookies . set ( 'fooz' , 'barz' )
50
50
expect ( Object . fromEntries ( response . headers . entries ( ) ) [ 'set-cookie' ] ) . toBe (
@@ -68,28 +68,32 @@ it('reflect .delete into `set-cookie`', async () => {
68
68
expect ( Object . fromEntries ( response . headers . entries ( ) ) [ 'set-cookie' ] ) . toBe (
69
69
'foo=bar; Path=/'
70
70
)
71
- expect ( response . cookies . get ( 'foo' ) ) . toBe ( 'foo=bar; Path=/' )
71
+ expect ( response . cookies . get ( 'foo' ) ) . toEqual ( { Path : '/' , foo : 'bar' } )
72
+ expect ( response . cookies . getRaw ( 'foo' ) ) . toBe ( 'foo=bar; Path=/' )
72
73
73
74
response . cookies . set ( 'fooz' , 'barz' )
74
75
expect ( Object . fromEntries ( response . headers . entries ( ) ) [ 'set-cookie' ] ) . toBe (
75
76
'foo=bar; Path=/, fooz=barz; Path=/'
76
77
)
77
- expect ( response . cookies . get ( 'fooz' ) ) . toBe ( 'fooz=barz; Path=/' )
78
+ expect ( response . cookies . get ( 'fooz' ) ) . toEqual ( { Path : '/' , fooz : 'barz' } )
79
+ expect ( response . cookies . getRaw ( 'fooz' ) ) . toBe ( 'fooz=barz; Path=/' )
78
80
79
81
const firstDelete = response . cookies . delete ( 'foo' )
80
82
expect ( firstDelete ) . toBe ( true )
81
83
expect ( Object . fromEntries ( response . headers . entries ( ) ) [ 'set-cookie' ] ) . toBe (
82
84
'foo=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT, fooz=barz; Path=/'
83
85
)
84
86
85
- expect ( response . cookies . get ( 'foo' ) ) . toBe ( undefined )
87
+ expect ( response . cookies . get ( 'foo' ) ) . toEqual ( undefined )
88
+ expect ( response . cookies . getRaw ( 'foo' ) ) . toBe ( undefined )
86
89
87
90
const secondDelete = response . cookies . delete ( 'fooz' )
88
91
expect ( secondDelete ) . toBe ( true )
89
92
expect ( Object . fromEntries ( response . headers . entries ( ) ) [ 'set-cookie' ] ) . toBe (
90
93
'fooz=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT, foo=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT'
91
94
)
92
- expect ( response . cookies . get ( 'fooz' ) ) . toBe ( undefined )
95
+ expect ( response . cookies . get ( 'fooz' ) ) . toEqual ( undefined )
96
+ expect ( response . cookies . getRaw ( 'fooz' ) ) . toBe ( undefined )
93
97
expect ( response . cookies . size ) . toBe ( 0 )
94
98
} )
95
99
@@ -109,7 +113,8 @@ it('reflect .clear into `set-cookie`', async () => {
109
113
expect ( Object . fromEntries ( response . headers . entries ( ) ) [ 'set-cookie' ] ) . toBe (
110
114
'foo=bar; Path=/'
111
115
)
112
- expect ( response . cookies . get ( 'foo' ) ) . toBe ( 'foo=bar; Path=/' )
116
+ expect ( response . cookies . get ( 'foo' ) ) . toEqual ( { Path : '/' , foo : 'bar' } )
117
+ expect ( response . cookies . getRaw ( 'foo' ) ) . toBe ( 'foo=bar; Path=/' )
113
118
114
119
response . cookies . set ( 'fooz' , 'barz' )
115
120
expect ( Object . fromEntries ( response . headers . entries ( ) ) [ 'set-cookie' ] ) . toBe (
0 commit comments