@@ -67,6 +67,21 @@ describe('res', function(){
67
67
. expect ( 200 , done )
68
68
} )
69
69
70
+ describe ( 'expires' , function ( ) {
71
+ it ( 'should throw on invalid date' , function ( done ) {
72
+ var app = express ( )
73
+
74
+ app . use ( function ( req , res ) {
75
+ res . cookie ( 'name' , 'tobi' , { expires : new Date ( NaN ) } )
76
+ res . end ( )
77
+ } )
78
+
79
+ request ( app )
80
+ . get ( '/' )
81
+ . expect ( 500 , / o p t i o n e x p i r e s i s i n v a l i d / , done )
82
+ } )
83
+ } )
84
+
70
85
describe ( 'maxAge' , function ( ) {
71
86
it ( 'should set relative expires' , function ( done ) {
72
87
var app = express ( ) ;
@@ -155,6 +170,63 @@ describe('res', function(){
155
170
} )
156
171
} )
157
172
173
+ describe ( 'priority' , function ( ) {
174
+ it ( 'should set low priority' , function ( done ) {
175
+ var app = express ( )
176
+
177
+ app . use ( function ( req , res ) {
178
+ res . cookie ( 'name' , 'tobi' , { priority : 'low' } )
179
+ res . end ( )
180
+ } )
181
+
182
+ request ( app )
183
+ . get ( '/' )
184
+ . expect ( 'Set-Cookie' , / P r i o r i t y = L o w / )
185
+ . expect ( 200 , done )
186
+ } )
187
+
188
+ it ( 'should set medium priority' , function ( done ) {
189
+ var app = express ( )
190
+
191
+ app . use ( function ( req , res ) {
192
+ res . cookie ( 'name' , 'tobi' , { priority : 'medium' } )
193
+ res . end ( )
194
+ } )
195
+
196
+ request ( app )
197
+ . get ( '/' )
198
+ . expect ( 'Set-Cookie' , / P r i o r i t y = M e d i u m / )
199
+ . expect ( 200 , done )
200
+ } )
201
+
202
+ it ( 'should set high priority' , function ( done ) {
203
+ var app = express ( )
204
+
205
+ app . use ( function ( req , res ) {
206
+ res . cookie ( 'name' , 'tobi' , { priority : 'high' } )
207
+ res . end ( )
208
+ } )
209
+
210
+ request ( app )
211
+ . get ( '/' )
212
+ . expect ( 'Set-Cookie' , / P r i o r i t y = H i g h / )
213
+ . expect ( 200 , done )
214
+ } )
215
+
216
+ it ( 'should throw with invalid priority' , function ( done ) {
217
+ var app = express ( )
218
+
219
+ app . use ( function ( req , res ) {
220
+ res . cookie ( 'name' , 'tobi' , { priority : 'foobar' } )
221
+ res . end ( )
222
+ } )
223
+
224
+ request ( app )
225
+ . get ( '/' )
226
+ . expect ( 500 , / o p t i o n p r i o r i t y i s i n v a l i d / , done )
227
+ } )
228
+ } )
229
+
158
230
describe ( 'signed' , function ( ) {
159
231
it ( 'should generate a signed JSON cookie' , function ( done ) {
160
232
var app = express ( ) ;
0 commit comments