Skip to content

Commit 5c70ff3

Browse files
This belongs to the cookie value encoding module
1 parent 2f2be3d commit 5c70ff3

1 file changed

Lines changed: 24 additions & 27 deletions

File tree

‎test/encoding.js‎

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,30 @@ test('RFC 6265 - characters allowed in the cookie value should not be encoded gl
193193
strictEqual(document.cookie, 'c={{', 'should not encode all the character occurrences');
194194
});
195195

196+
test('cookie-value - 2 bytes character (ã)', function () {
197+
expect(2);
198+
199+
Cookies.set('c', 'ã');
200+
strictEqual(Cookies.get('c'), 'ã', 'should handle the ã character');
201+
strictEqual(document.cookie, 'c=%C3%A3', 'should encode the ã character');
202+
});
203+
204+
test('cookie-value - 3 bytes character (₯)', function () {
205+
expect(2);
206+
207+
Cookies.set('c', '₯');
208+
strictEqual(Cookies.get('c'), '₯', 'should handle the ₯ character');
209+
strictEqual(document.cookie, 'c=%E2%82%AF', 'should encode the ₯ character');
210+
});
211+
212+
test('cookie-value - 4 bytes character (𩸽)', function () {
213+
expect(2);
214+
215+
Cookies.set('c', '𩸽');
216+
strictEqual(Cookies.get('c'), '𩸽', 'should handle the 𩸽 character');
217+
strictEqual(document.cookie, 'c=%F0%A9%B8%BD', 'should encode the 𩸽 character');
218+
});
219+
196220
module('cookie-name encoding', lifecycle);
197221

198222
test('RFC 6265 - unallowed characters in cookie-name', function () {
@@ -320,30 +344,3 @@ test('cookie-name - 4 bytes characters', function () {
320344
strictEqual(document.cookie, '%F0%A9%B8%BD=v', 'should encode the 𩸽 character');
321345
Cookies.remove('𩸽');
322346
});
323-
324-
test('cookie-value - 2 bytes characters', function () {
325-
expect(2);
326-
327-
Cookies.set('c', 'ã');
328-
strictEqual(Cookies.get('c'), 'ã', 'should handle the ã character');
329-
strictEqual(document.cookie, 'c=%C3%A3', 'should encode the ã character');
330-
Cookies.remove('c');
331-
});
332-
333-
test('cookie-value - 3 bytes characters', function () {
334-
expect(2);
335-
336-
Cookies.set('c', '₯');
337-
strictEqual(Cookies.get('c'), '₯', 'should handle the ₯ character');
338-
strictEqual(document.cookie, 'c=%E2%82%AF', 'should encode the ₯ character');
339-
Cookies.remove('c');
340-
});
341-
342-
test('cookie-value - 4 bytes characters', function () {
343-
expect(2);
344-
345-
Cookies.set('c', '𩸽');
346-
strictEqual(Cookies.get('c'), '𩸽', 'should handle the 𩸽 character');
347-
strictEqual(document.cookie, 'c=%F0%A9%B8%BD', 'should encode the 𩸽 character');
348-
Cookies.remove('c');
349-
});

0 commit comments

Comments
 (0)