js-cookie 2.1.1 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/test/encoding.js DELETED
@@ -1,628 +0,0 @@
1
- QUnit.module('cookie-value', lifecycle);
2
-
3
- QUnit.test('cookie-value with double quotes', function (assert) {
4
- assert.expect(1);
5
- using(assert)
6
- .setCookie('c', '"')
7
- .then(function (decodedValue) {
8
- assert.strictEqual(decodedValue, '"', 'should print the quote character');
9
- });
10
- });
11
-
12
- QUnit.test('cookie-value with double quotes in the left', function (assert) {
13
- assert.expect(1);
14
- using(assert)
15
- .setCookie('c', '"content')
16
- .then(function (decodedValue) {
17
- assert.strictEqual(decodedValue, '"content', 'should print the quote character');
18
- });
19
- });
20
-
21
- QUnit.test('cookie-value with double quotes in the right', function (assert) {
22
- assert.expect(1);
23
- using(assert)
24
- .setCookie('c', 'content"')
25
- .then(function (decodedValue) {
26
- assert.strictEqual(decodedValue, 'content"', 'should print the quote character');
27
- });
28
- });
29
-
30
- QUnit.test('RFC 6265 - character not allowed in the cookie-value " "', function (assert) {
31
- assert.expect(2);
32
- using(assert)
33
- .setCookie('c', ' ')
34
- .then(function (decodedValue, plainValue) {
35
- assert.strictEqual(decodedValue, ' ', 'should handle the whitespace character');
36
- assert.strictEqual(plainValue, 'c=%20', 'whitespace is not allowed, need to encode');
37
- });
38
- });
39
-
40
- QUnit.test('RFC 6265 - character not allowed in the cookie-value ","', function (assert) {
41
- assert.expect(2);
42
- using(assert)
43
- .setCookie('c', ',')
44
- .then(function (decodedValue, plainValue) {
45
- assert.strictEqual(decodedValue, ',', 'should handle the comma character');
46
- assert.strictEqual(plainValue, 'c=%2C', 'comma is not allowed, need to encode');
47
- });
48
- });
49
-
50
- QUnit.test('RFC 6265 - character not allowed in the cookie-value ";"', function (assert) {
51
- assert.expect(2);
52
- using(assert)
53
- .setCookie('c', ';')
54
- .then(function (decodedValue, plainValue) {
55
- assert.strictEqual(decodedValue, ';', 'should handle the semicolon character');
56
- assert.strictEqual(plainValue, 'c=%3B', 'semicolon is not allowed, need to encode');
57
- });
58
- });
59
-
60
- QUnit.test('RFC 6265 - character not allowed in the cookie-value "\\"', function (assert) {
61
- assert.expect(2);
62
- using(assert)
63
- .setCookie('c', '\\')
64
- .then(function (decodedValue, plainValue) {
65
- assert.strictEqual(decodedValue, '\\', 'should handle the backslash character');
66
- assert.strictEqual(plainValue, 'c=%5C', 'backslash is not allowed, need to encode');
67
- });
68
- });
69
-
70
- QUnit.test('RFC 6265 - characters not allowed in the cookie-value should be replaced globally', function (assert) {
71
- assert.expect(2);
72
- using(assert)
73
- .setCookie('c', ';;')
74
- .then(function (decodedValue, plainValue) {
75
- assert.strictEqual(decodedValue, ';;', 'should handle multiple not allowed characters');
76
- assert.strictEqual(plainValue, 'c=%3B%3B', 'should replace multiple not allowed characters');
77
- });
78
- });
79
-
80
- QUnit.test('RFC 6265 - character allowed in the cookie-value "#"', function (assert) {
81
- assert.expect(2);
82
- using(assert)
83
- .setCookie('c', '#')
84
- .then(function (decodedValue, plainValue) {
85
- assert.strictEqual(decodedValue, '#', 'should handle the sharp character');
86
- assert.strictEqual(plainValue, 'c=#', 'sharp is allowed, should not encode');
87
- });
88
- });
89
-
90
- QUnit.test('RFC 6265 - character allowed in the cookie-value "$"', function (assert) {
91
- assert.expect(2);
92
- using(assert)
93
- .setCookie('c', '$')
94
- .then(function (decodedValue, plainValue) {
95
- assert.strictEqual(decodedValue, '$', 'should handle the dollar sign character');
96
- assert.strictEqual(plainValue, 'c=$', 'dollar sign is allowed, should not encode');
97
- });
98
- });
99
-
100
- QUnit.test('RFC 6265 - character allowed in the cookie-value "%"', function (assert) {
101
- assert.expect(2);
102
- using(assert)
103
- .setCookie('c', '%')
104
- .then(function (decodedValue, plainValue) {
105
- assert.strictEqual(decodedValue, '%', 'should handle the percent character');
106
- assert.strictEqual(plainValue, 'c=%25', 'percent is allowed, but need to be escaped');
107
- });
108
- });
109
-
110
- QUnit.test('RFC 6265 - character allowed in the cookie-value "&"', function (assert) {
111
- assert.expect(2);
112
- using(assert)
113
- .setCookie('c', '&')
114
- .then(function (decodedValue, plainValue) {
115
- assert.strictEqual(decodedValue, '&', 'should handle the ampersand character');
116
- assert.strictEqual(plainValue, 'c=&', 'ampersand is allowed, should not encode');
117
- });
118
- });
119
-
120
- // github.com/carhartl/jquery-cookie/pull/62
121
- QUnit.test('RFC 6265 - character allowed in the cookie-value "+"', function (assert) {
122
- assert.expect(2);
123
- using(assert)
124
- .setCookie('c', '+')
125
- .then(function (decodedValue, plainValue) {
126
- assert.strictEqual(decodedValue, '+', 'should handle the plus character');
127
- assert.strictEqual(plainValue, 'c=+', 'plus is allowed, should not encode');
128
- });
129
- });
130
-
131
- QUnit.test('RFC 6265 - character allowed in the cookie-value ":"', function (assert) {
132
- assert.expect(2);
133
- using(assert)
134
- .setCookie('c', ':')
135
- .then(function (decodedValue, plainValue) {
136
- assert.strictEqual(decodedValue, ':', 'should handle the colon character');
137
- assert.strictEqual(plainValue, 'c=:', 'colon is allowed, should not encode');
138
- });
139
- });
140
-
141
- QUnit.test('RFC 6265 - character allowed in the cookie-value "<"', function (assert) {
142
- assert.expect(2);
143
- using(assert)
144
- .setCookie('c', '<')
145
- .then(function (decodedValue, plainValue) {
146
- assert.strictEqual(decodedValue, '<', 'should handle the less-than character');
147
- assert.strictEqual(plainValue, 'c=<', 'less-than is allowed, should not encode');
148
- });
149
- });
150
-
151
- QUnit.test('RFC 6265 - character allowed in the cookie-value ">"', function (assert) {
152
- assert.expect(2);
153
- using(assert)
154
- .setCookie('c', '>')
155
- .then(function (decodedValue, plainValue) {
156
- assert.strictEqual(decodedValue, '>', 'should handle the greater-than character');
157
- assert.strictEqual(plainValue, 'c=>', 'greater-than is allowed, should not encode');
158
- });
159
- });
160
-
161
- QUnit.test('RFC 6265 - character allowed in the cookie-value "="', function (assert) {
162
- assert.expect(2);
163
- using(assert)
164
- .setCookie('c', '=')
165
- .then(function (decodedValue, plainValue) {
166
- assert.strictEqual(decodedValue, '=', 'should handle the equal sign character');
167
- assert.strictEqual(plainValue, 'c==', 'equal sign is allowed, should not encode');
168
- });
169
- });
170
-
171
- QUnit.test('RFC 6265 - character allowed in the cookie-value "/"', function (assert) {
172
- assert.expect(2);
173
- using(assert)
174
- .setCookie('c', '/')
175
- .then(function (decodedValue, plainValue) {
176
- assert.strictEqual(decodedValue, '/', 'should handle the slash character');
177
- assert.strictEqual(plainValue, 'c=/', 'slash is allowed, should not encode');
178
- });
179
- });
180
-
181
- QUnit.test('RFC 6265 - character allowed in the cookie-value "?"', function (assert) {
182
- assert.expect(2);
183
- using(assert)
184
- .setCookie('c', '?')
185
- .then(function (decodedValue, plainValue) {
186
- assert.strictEqual(decodedValue, '?', 'should handle the question mark character');
187
- assert.strictEqual(plainValue, 'c=?', 'question mark is allowed, should not encode');
188
- });
189
- });
190
-
191
- QUnit.test('RFC 6265 - character allowed in the cookie-value "@"', function (assert) {
192
- assert.expect(2);
193
- using(assert)
194
- .setCookie('c', '@')
195
- .then(function (decodedValue, plainValue) {
196
- assert.strictEqual(decodedValue, '@', 'should handle the at character');
197
- assert.strictEqual(plainValue, 'c=@', 'at is allowed, should not encode');
198
- });
199
- });
200
-
201
- QUnit.test('RFC 6265 - character allowed in the cookie-value "["', function (assert) {
202
- assert.expect(2);
203
- using(assert)
204
- .setCookie('c', '[')
205
- .then(function (decodedValue, plainValue) {
206
- assert.strictEqual(decodedValue, '[', 'should handle the opening square bracket character');
207
- assert.strictEqual(plainValue, 'c=[', 'opening square bracket is allowed, should not encode');
208
- });
209
- });
210
-
211
- QUnit.test('RFC 6265 - character allowed in the cookie-value "]"', function (assert) {
212
- assert.expect(2);
213
- using(assert)
214
- .setCookie('c', ']')
215
- .then(function (decodedValue, plainValue) {
216
- assert.strictEqual(decodedValue, ']', 'should handle the closing square bracket character');
217
- assert.strictEqual(plainValue, 'c=]', 'closing square bracket is allowed, should not encode');
218
- });
219
- });
220
-
221
- QUnit.test('RFC 6265 - character allowed in the cookie-value "^"', function (assert) {
222
- assert.expect(2);
223
- using(assert)
224
- .setCookie('c', '^')
225
- .then(function (decodedValue, plainValue) {
226
- assert.strictEqual(decodedValue, '^', 'should handle the caret character');
227
- assert.strictEqual(plainValue, 'c=^', 'caret is allowed, should not encode');
228
- });
229
- });
230
-
231
- QUnit.test('RFC 6265 - character allowed in the cookie-value "`"', function (assert) {
232
- assert.expect(2);
233
- using(assert)
234
- .setCookie('c', '`')
235
- .then(function (decodedValue, plainValue) {
236
- assert.strictEqual(decodedValue, '`', 'should handle the grave accent character');
237
- assert.strictEqual(plainValue, 'c=`', 'grave accent is allowed, should not encode');
238
- });
239
- });
240
-
241
- QUnit.test('RFC 6265 - character allowed in the cookie-value "{"', function (assert) {
242
- assert.expect(2);
243
- using(assert)
244
- .setCookie('c', '{')
245
- .then(function (decodedValue, plainValue) {
246
- assert.strictEqual(decodedValue, '{', 'should handle the opening curly bracket character');
247
- assert.strictEqual(plainValue, 'c={', 'opening curly bracket is allowed, should not encode');
248
- });
249
- });
250
-
251
- QUnit.test('RFC 6265 - character allowed in the cookie-value "}"', function (assert) {
252
- assert.expect(2);
253
- using(assert)
254
- .setCookie('c', '}')
255
- .then(function (decodedValue, plainValue) {
256
- assert.strictEqual(decodedValue, '}', 'should handle the closing curly bracket character');
257
- assert.strictEqual(plainValue, 'c=}', 'closing curly bracket is allowed, should not encode');
258
- });
259
- });
260
-
261
- QUnit.test('RFC 6265 - character allowed in the cookie-value "|"', function (assert) {
262
- assert.expect(2);
263
- using(assert)
264
- .setCookie('c', '|')
265
- .then(function (decodedValue, plainValue) {
266
- assert.strictEqual(decodedValue, '|', 'should handle the pipe character');
267
- assert.strictEqual(plainValue, 'c=|', 'pipe is allowed, should not encode');
268
- });
269
- });
270
-
271
- QUnit.test('RFC 6265 - characters allowed in the cookie-value should globally not be encoded', function (assert) {
272
- assert.expect(1);
273
- using(assert)
274
- .setCookie('c', '{{')
275
- .then(function (decodedValue, plainValue) {
276
- assert.strictEqual(plainValue, 'c={{', 'should not encode all the character occurrences');
277
- });
278
- });
279
-
280
- QUnit.test('cookie-value - 2 bytes character (ã)', function (assert) {
281
- assert.expect(2);
282
- using(assert)
283
- .setCookie('c', 'ã')
284
- .then(function (decodedValue, plainValue) {
285
- assert.strictEqual(decodedValue, 'ã', 'should handle the ã character');
286
- assert.strictEqual(plainValue, 'c=%C3%A3', 'should encode the ã character');
287
- });
288
- });
289
-
290
- QUnit.test('cookie-value - 3 bytes character (₯)', function (assert) {
291
- assert.expect(2);
292
- using(assert)
293
- .setCookie('c', '₯')
294
- .then(function (decodedValue, plainValue) {
295
- assert.strictEqual(decodedValue, '₯', 'should handle the ₯ character');
296
- assert.strictEqual(plainValue, 'c=%E2%82%AF', 'should encode the ₯ character');
297
- });
298
- });
299
-
300
- QUnit.test('cookie-value - 4 bytes character (𩸽)', function (assert) {
301
- assert.expect(2);
302
- using(assert)
303
- .setCookie('c', '𩸽')
304
- .then(function (decodedValue, plainValue) {
305
- assert.strictEqual(decodedValue, '𩸽', 'should handle the 𩸽 character');
306
- assert.strictEqual(plainValue, 'c=%F0%A9%B8%BD', 'should encode the 𩸽 character');
307
- });
308
- });
309
-
310
- QUnit.module('cookie-name', lifecycle);
311
-
312
- QUnit.test('RFC 6265 - character not allowed in the cookie-name "("', function (assert) {
313
- assert.expect(2);
314
- using(assert)
315
- .setCookie('(', 'v')
316
- .then(function (decodedValue, plainValue) {
317
- assert.strictEqual(decodedValue, 'v', 'should handle the opening parens character');
318
- assert.strictEqual(plainValue, '%28=v', 'opening parens is not allowed, need to encode');
319
- });
320
- });
321
-
322
- QUnit.test('RFC 6265 - character not allowed in the cookie-name ")"', function (assert) {
323
- assert.expect(2);
324
- using(assert)
325
- .setCookie(')', 'v')
326
- .then(function (decodedValue, plainValue) {
327
- assert.strictEqual(decodedValue, 'v', 'should handle the closing parens character');
328
- assert.strictEqual(plainValue, '%29=v', 'closing parens is not allowed, need to encode');
329
- });
330
- });
331
-
332
- QUnit.test('RFC 6265 - should replace parens globally', function (assert) {
333
- assert.expect(1);
334
- using(assert)
335
- .setCookie('(())', 'v')
336
- .then(function (decodedValue, plainValue) {
337
- assert.strictEqual(plainValue, '%28%28%29%29=v', 'encode with global replace');
338
- });
339
- });
340
-
341
- QUnit.test('RFC 6265 - character not allowed in the cookie-name "<"', function (assert) {
342
- assert.expect(2);
343
- using(assert)
344
- .setCookie('<', 'v')
345
- .then(function (decodedValue, plainValue) {
346
- assert.strictEqual(decodedValue, 'v', 'should handle the less-than character');
347
- assert.strictEqual(plainValue, '%3C=v', 'less-than is not allowed, need to encode');
348
- });
349
- });
350
-
351
- QUnit.test('RFC 6265 - character not allowed in the cookie-name ">"', function (assert) {
352
- assert.expect(2);
353
- using(assert)
354
- .setCookie('>', 'v')
355
- .then(function (decodedValue, plainValue) {
356
- assert.strictEqual(decodedValue, 'v', 'should handle the greater-than character');
357
- assert.strictEqual(plainValue, '%3E=v', 'greater-than is not allowed, need to encode');
358
- });
359
- });
360
-
361
- QUnit.test('RFC 6265 - character not allowed in the cookie-name "@"', function (assert) {
362
- assert.expect(2);
363
- using(assert)
364
- .setCookie('@', 'v')
365
- .then(function (decodedValue, plainValue) {
366
- assert.strictEqual(decodedValue, 'v', 'should handle the at character');
367
- assert.strictEqual(plainValue, '%40=v', 'at is not allowed, need to encode');
368
- });
369
- });
370
-
371
- QUnit.test('RFC 6265 - character not allowed in the cookie-name ","', function (assert) {
372
- assert.expect(2);
373
- using(assert)
374
- .setCookie(',', 'v')
375
- .then(function (decodedValue, plainValue) {
376
- assert.strictEqual(decodedValue, 'v', 'should handle the comma character');
377
- assert.strictEqual(plainValue, '%2C=v', 'comma is not allowed, need to encode');
378
- });
379
- });
380
-
381
- QUnit.test('RFC 6265 - character not allowed in the cookie-name ";"', function (assert) {
382
- assert.expect(2);
383
- using(assert)
384
- .setCookie(';', 'v')
385
- .then(function (decodedValue, plainValue) {
386
- assert.strictEqual(decodedValue, 'v', 'should handle the semicolon character');
387
- assert.strictEqual(plainValue, '%3B=v', 'semicolon is not allowed, need to encode');
388
- });
389
- });
390
-
391
- QUnit.test('RFC 6265 - character not allowed in the cookie-name ":"', function (assert) {
392
- assert.expect(2);
393
- using(assert)
394
- .setCookie(':', 'v')
395
- .then(function (decodedValue, plainValue) {
396
- assert.strictEqual(decodedValue, 'v', 'should handle the colon character');
397
- assert.strictEqual(plainValue, '%3A=v', 'colon is not allowed, need to encode');
398
- });
399
- });
400
-
401
- QUnit.test('RFC 6265 - character not allowed in the cookie-name "\\"', function (assert) {
402
- assert.expect(2);
403
- using(assert)
404
- .setCookie('\\', 'v')
405
- .then(function (decodedValue, plainValue) {
406
- assert.strictEqual(decodedValue, 'v', 'should handle the backslash character');
407
- assert.strictEqual(plainValue, '%5C=v', 'backslash is not allowed, need to encode');
408
- });
409
- });
410
-
411
- QUnit.test('RFC 6265 - character not allowed in the cookie-name "\""', function (assert) {
412
- assert.expect(2);
413
- using(assert)
414
- .setCookie('"', 'v')
415
- .then(function (decodedValue, plainValue) {
416
- assert.strictEqual(decodedValue, 'v', 'should handle the double quote character');
417
- assert.strictEqual(plainValue, '%22=v', 'double quote is not allowed, need to encode');
418
- });
419
- });
420
-
421
- QUnit.test('RFC 6265 - character not allowed in the cookie-name "/"', function (assert) {
422
- assert.expect(2);
423
- using(assert)
424
- .setCookie('/', 'v')
425
- .then(function (decodedValue, plainValue) {
426
- assert.strictEqual(decodedValue, 'v', 'should handle the slash character');
427
- assert.strictEqual(plainValue, '%2F=v', 'slash is not allowed, need to encode');
428
- });
429
- });
430
-
431
- QUnit.test('RFC 6265 - character not allowed in the cookie-name "["', function (assert) {
432
- assert.expect(2);
433
- using(assert)
434
- .setCookie('[', 'v')
435
- .then(function (decodedValue, plainValue) {
436
- assert.strictEqual(decodedValue, 'v', 'should handle the opening square brackets character');
437
- assert.strictEqual(plainValue, '%5B=v', 'opening square brackets is not allowed, need to encode');
438
- });
439
- });
440
-
441
- QUnit.test('RFC 6265 - character not allowed in the cookie-name "]"', function (assert) {
442
- assert.expect(2);
443
- using(assert)
444
- .setCookie(']', 'v')
445
- .then(function (decodedValue, plainValue) {
446
- assert.strictEqual(decodedValue, 'v', 'should handle the closing square brackets character');
447
- assert.strictEqual(plainValue, '%5D=v', 'closing square brackets is not allowed, need to encode');
448
- });
449
- });
450
-
451
- QUnit.test('RFC 6265 - character not allowed in the cookie-name "?"', function (assert) {
452
- assert.expect(2);
453
- using(assert)
454
- .setCookie('?', 'v')
455
- .then(function (decodedValue, plainValue) {
456
- assert.strictEqual(decodedValue, 'v', 'should handle the question mark character');
457
- assert.strictEqual(plainValue, '%3F=v', 'question mark is not allowed, need to encode');
458
- });
459
- });
460
-
461
- QUnit.test('RFC 6265 - character not allowed in the cookie-name "="', function (assert) {
462
- assert.expect(2);
463
- using(assert)
464
- .setCookie('=', 'v')
465
- .then(function (decodedValue, plainValue) {
466
- assert.strictEqual(decodedValue, 'v', 'should handle the equal sign character');
467
- assert.strictEqual(plainValue, '%3D=v', 'equal sign is not allowed, need to encode');
468
- });
469
- });
470
-
471
- QUnit.test('RFC 6265 - character not allowed in the cookie-name "{"', function (assert) {
472
- assert.expect(2);
473
- using(assert)
474
- .setCookie('{', 'v')
475
- .then(function (decodedValue, plainValue) {
476
- assert.strictEqual(decodedValue, 'v', 'should handle the opening curly brackets character');
477
- assert.strictEqual(plainValue, '%7B=v', 'opening curly brackets is not allowed, need to encode');
478
- });
479
- });
480
-
481
- QUnit.test('RFC 6265 - character not allowed in the cookie-name "}"', function (assert) {
482
- assert.expect(2);
483
- using(assert)
484
- .setCookie('}', 'v')
485
- .then(function (decodedValue, plainValue) {
486
- assert.strictEqual(decodedValue, 'v', 'should handle the closing curly brackets character');
487
- assert.strictEqual(plainValue, '%7D=v', 'closing curly brackets is not allowed, need to encode');
488
- });
489
- });
490
-
491
- QUnit.test('RFC 6265 - character not allowed in the cookie-name "\\t"', function (assert) {
492
- assert.expect(2);
493
- using(assert)
494
- .setCookie(' ', 'v')
495
- .then(function (decodedValue, plainValue) {
496
- assert.strictEqual(decodedValue, 'v', 'should handle the horizontal tab character');
497
- assert.strictEqual(plainValue, '%09=v', 'horizontal tab is not allowed, need to encode');
498
- });
499
- });
500
-
501
- QUnit.test('RFC 6265 - character not allowed in the cookie-name " "', function (assert) {
502
- assert.expect(2);
503
- using(assert)
504
- .setCookie(' ', 'v')
505
- .then(function (decodedValue, plainValue) {
506
- assert.strictEqual(decodedValue, 'v', 'should handle the whitespace character');
507
- assert.strictEqual(plainValue, '%20=v', 'whitespace is not allowed, need to encode');
508
- });
509
- });
510
-
511
- QUnit.test('RFC 6265 - character allowed in the cookie-name "#"', function (assert) {
512
- assert.expect(2);
513
- using(assert)
514
- .setCookie('#', 'v')
515
- .then(function (decodedValue, plainValue) {
516
- assert.strictEqual(decodedValue, 'v', 'should handle the sharp character');
517
- assert.strictEqual(plainValue, '#=v', 'sharp is allowed, should not encode');
518
- });
519
- });
520
-
521
- QUnit.test('RFC 6265 - character allowed in the cookie-name "$"', function (assert) {
522
- assert.expect(2);
523
- using(assert)
524
- .setCookie('$', 'v')
525
- .then(function (decodedValue, plainValue) {
526
- assert.strictEqual(decodedValue, 'v', 'should handle the dollar sign character');
527
- assert.strictEqual(plainValue, '$=v', 'dollar sign is allowed, should not encode');
528
- });
529
- });
530
-
531
- QUnit.test('RFC 6265 - character allowed in cookie-name "%"', function (assert) {
532
- assert.expect(2);
533
- using(assert)
534
- .setCookie('%', 'v')
535
- .then(function (decodedValue, plainValue) {
536
- assert.strictEqual(decodedValue, 'v', 'should handle the percent character');
537
- assert.strictEqual(plainValue, '%25=v', 'percent is allowed, but need to be escaped');
538
- });
539
- });
540
-
541
- QUnit.test('RFC 6265 - character allowed in the cookie-name "&"', function (assert) {
542
- assert.expect(2);
543
- using(assert)
544
- .setCookie('&', 'v')
545
- .then(function (decodedValue, plainValue) {
546
- assert.strictEqual(decodedValue, 'v', 'should handle the ampersand character');
547
- assert.strictEqual(plainValue, '&=v', 'ampersand is allowed, should not encode');
548
- });
549
- });
550
-
551
- QUnit.test('RFC 6265 - character allowed in the cookie-name "+"', function (assert) {
552
- assert.expect(2);
553
- using(assert)
554
- .setCookie('+', 'v')
555
- .then(function (decodedValue, plainValue) {
556
- assert.strictEqual(decodedValue, 'v', 'should handle the plus character');
557
- assert.strictEqual(plainValue, '+=v', 'plus is allowed, should not encode');
558
- });
559
- });
560
-
561
- QUnit.test('RFC 6265 - character allowed in the cookie-name "^"', function (assert) {
562
- assert.expect(2);
563
- using(assert)
564
- .setCookie('^', 'v')
565
- .then(function (decodedValue, plainValue) {
566
- assert.strictEqual(decodedValue, 'v', 'should handle the caret character');
567
- assert.strictEqual(plainValue, '^=v', 'caret is allowed, should not encode');
568
- });
569
- });
570
-
571
- QUnit.test('RFC 6265 - character allowed in the cookie-name "`"', function (assert) {
572
- assert.expect(2);
573
- using(assert)
574
- .setCookie('`', 'v')
575
- .then(function (decodedValue, plainValue) {
576
- assert.strictEqual(decodedValue, 'v', 'should handle the grave accent character');
577
- assert.strictEqual(plainValue, '`=v', 'grave accent is allowed, should not encode');
578
- });
579
- });
580
-
581
- QUnit.test('RFC 6265 - character allowed in the cookie-name "|"', function (assert) {
582
- assert.expect(2);
583
- using(assert)
584
- .setCookie('|', 'v')
585
- .then(function (decodedValue, plainValue) {
586
- assert.strictEqual(decodedValue, 'v', 'should handle the pipe character');
587
- assert.strictEqual(plainValue, '|=v', 'pipe is allowed, should not encode');
588
- });
589
- });
590
-
591
- QUnit.test('RFC 6265 - characters allowed in the cookie-name should globally not be encoded', function (assert) {
592
- assert.expect(1);
593
- using(assert)
594
- .setCookie('||', 'v')
595
- .then(function (decodedValue, plainValue) {
596
- assert.strictEqual(plainValue, '||=v', 'should not encode all character occurrences');
597
- });
598
- });
599
-
600
- QUnit.test('cookie-name - 2 bytes characters', function (assert) {
601
- assert.expect(2);
602
- using(assert)
603
- .setCookie('ã', 'v')
604
- .then(function (decodedValue, plainValue) {
605
- assert.strictEqual(decodedValue, 'v', 'should handle the ã character');
606
- assert.strictEqual(plainValue, '%C3%A3=v', 'should encode the ã character');
607
- });
608
- });
609
-
610
- QUnit.test('cookie-name - 3 bytes characters', function (assert) {
611
- assert.expect(2);
612
- using(assert)
613
- .setCookie('₯', 'v')
614
- .then(function (decodedValue, plainValue) {
615
- assert.strictEqual(decodedValue, 'v', 'should handle the ₯ character');
616
- assert.strictEqual(plainValue, '%E2%82%AF=v', 'should encode the ₯ character');
617
- });
618
- });
619
-
620
- QUnit.test('cookie-name - 4 bytes characters', function (assert) {
621
- assert.expect(2);
622
- using(assert)
623
- .setCookie('𩸽', 'v')
624
- .then(function (decodedValue, plainValue) {
625
- assert.strictEqual(decodedValue, 'v', 'should_handle the 𩸽 character');
626
- assert.strictEqual(plainValue, '%F0%A9%B8%BD=v', 'should encode the 𩸽 character');
627
- });
628
- });
package/test/index.html DELETED
@@ -1,18 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <title>JavaScript Cookie Test Suite</title>
6
- <link href="../node_modules/qunitjs/qunit/qunit.css" rel="stylesheet">
7
- <script src="../node_modules/qunitjs/qunit/qunit.js"></script>
8
- <script>Cookies = 'existent global'</script>
9
- <script src="../src/js.cookie.js"></script>
10
- <script src="polyfill.js"></script>
11
- <script src="utils.js"></script>
12
- <script src="tests.js"></script>
13
- </head>
14
- <body>
15
- <div id="qunit"></div>
16
- <div id="qunit-fixture"></div>
17
- </body>
18
- </html>
@@ -1,17 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title></title>
5
- <script src="../src/js.cookie.js"></script>
6
- <script>
7
- try {
8
- Object.defineProperty(document, "cookie", { get: function() { return "first=one; ; second=two"; } });
9
- window.testValue = Cookies.get("second");
10
- window.ok = true;
11
- } catch (er) {
12
- }
13
- </script>
14
- </head>
15
- <body>
16
- </body>
17
- </html>
@@ -1,24 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <title></title>
6
- <link href="../node_modules/qunitjs/qunit/qunit.css" rel="stylesheet">
7
- <script src="../node_modules/qunitjs/qunit/qunit.js"></script>
8
- <script src="utils.js"></script>
9
- <script>
10
- (function() {
11
- var contents = window.loadFileSync('../src/js.cookie.js');
12
-
13
- if (contents !== null) {
14
- var script = document.createElement('script');
15
- script.innerHTML = '(function (){ return {}; })() ' + contents;
16
- document.getElementsByTagName('head')[0].appendChild(script);
17
- }
18
- })();
19
- </script>
20
- </head>
21
- <body>
22
-
23
- </body>
24
- </html>